Skip to content

Commit

Permalink
Added timescaledb plugin/extension (#470)
Browse files Browse the repository at this point in the history
* Added `timescaledb` plugin/extension

* fixed unit test `test_enable_disable_extensions`

* Fixed snap revision

Co-authored-by: Dragomir Penev <[email protected]>

---------

Co-authored-by: Dragomir Penev <[email protected]>
  • Loading branch information
TakoB222 and dragomirp authored Jun 4, 2024
1 parent f72cf20 commit fabce25
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ options:
default: false
type: boolean
description: Enable pgvector extension
plugin_timescaledb_enable:
default: false
type: boolean
description: Enable timescaledb extension
profile:
description: |
Profile representing the scope of deployment, and used to tune resource allocation.
Expand Down
1 change: 1 addition & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class CharmConfig(BaseConfigModel):
plugin_icu_ext_enable: bool
plugin_pltcl_enable: bool
plugin_postgis_enable: bool
plugin_timescaledb_enable: bool
plugin_address_standardizer_enable: bool
plugin_address_standardizer_data_us_enable: bool
plugin_postgis_tiger_geocoder_enable: bool
Expand Down
2 changes: 1 addition & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
SNAP_PACKAGES = [
(
POSTGRESQL_SNAP_NAME,
{"revision": {"aarch64": "112", "x86_64": "113"}, "channel": "14/stable"},
{"revision": {"aarch64": "114", "x86_64": "115"}, "channel": "14/stable"},
)
]

Expand Down
1 change: 1 addition & 0 deletions templates/patroni.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ bootstrap:
log_truncate_on_rotation: 'on'
logging_collector: 'on'
wal_level: logical
shared_preload_libraries: 'timescaledb'
{%- if pg_parameters %}
{%- for key, value in pg_parameters.items() %}
{{key}}: {{value}}
Expand Down
12 changes: 8 additions & 4 deletions tests/integration/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@
ADDRESS_STANDARDIZER_EXTENSION_STATEMENT = "SELECT num, street, city, zip, zipplus FROM parse_address('1 Devonshire Place, Boston, MA 02109-1234');"
ADDRESS_STANDARDIZER_DATA_US_EXTENSION_STATEMENT = "SELECT house_num, name, suftype, city, country, state, unit FROM standardize_address('us_lex', 'us_gaz', 'us_rules', 'One Devonshire Place, PH 301, Boston, MA 02109');"
POSTGIS_TIGER_GEOCODER_EXTENSION_STATEMENT = "SELECT * FROM standardize_address('tiger.pagc_lex', 'tiger.pagc_gaz', 'tiger.pagc_rules', 'One Devonshire Place, PH 301, Boston, MA 02109-1234');"
POSTGIS_TOPOLOGY_STATEMENT = "SELECT topology.CreateTopology('nyc_topo', 26918, 0.5);"
POSTGIS_RASTER_STATEMENT = "CREATE TABLE test_postgis_raster (name varchar, rast raster);"
POSTGIS_TOPOLOGY_EXTENSION_STATEMENT = "SELECT topology.CreateTopology('nyc_topo', 26918, 0.5);"
POSTGIS_RASTER_EXTENSION_STATEMENT = (
"CREATE TABLE test_postgis_raster (name varchar, rast raster);"
)
VECTOR_EXTENSION_STATEMENT = (
"CREATE TABLE vector_test (id bigserial PRIMARY KEY, embedding vector(3));"
)
TIMESCALEDB_EXTENSION_STATEMENT = "CREATE TABLE test_timescaledb (time TIMESTAMPTZ NOT NULL); SELECT create_hypertable('test_timescaledb', 'time');"


@pytest.mark.group(1)
Expand Down Expand Up @@ -153,9 +156,10 @@ async def test_plugins(ops_test: OpsTest) -> None:
"plugin_address_standardizer_enable": ADDRESS_STANDARDIZER_EXTENSION_STATEMENT,
"plugin_address_standardizer_data_us_enable": ADDRESS_STANDARDIZER_DATA_US_EXTENSION_STATEMENT,
"plugin_postgis_tiger_geocoder_enable": POSTGIS_TIGER_GEOCODER_EXTENSION_STATEMENT,
"plugin_postgis_raster_enable": POSTGIS_RASTER_STATEMENT,
"plugin_postgis_topology_enable": POSTGIS_TOPOLOGY_STATEMENT,
"plugin_postgis_raster_enable": POSTGIS_RASTER_EXTENSION_STATEMENT,
"plugin_postgis_topology_enable": POSTGIS_TOPOLOGY_EXTENSION_STATEMENT,
"plugin_vector_enable": VECTOR_EXTENSION_STATEMENT,
"plugin_timescaledb_enable": TIMESCALEDB_EXTENSION_STATEMENT,
}

def enable_disable_config(enabled: False):
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ def test_enable_disable_extensions(harness, caplog):
plugin_vector_enable:
default: false
type: boolean
plugin_timescaledb_enable:
default: false
type: boolean
profile:
default: production
type: string"""
Expand Down

0 comments on commit fabce25

Please sign in to comment.