Skip to content

Commit fabce25

Browse files
TakoB222dragomirp
andauthored
Added timescaledb plugin/extension (#470)
* 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]>
1 parent f72cf20 commit fabce25

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ options:
299299
default: false
300300
type: boolean
301301
description: Enable pgvector extension
302+
plugin_timescaledb_enable:
303+
default: false
304+
type: boolean
305+
description: Enable timescaledb extension
302306
profile:
303307
description: |
304308
Profile representing the scope of deployment, and used to tune resource allocation.

src/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class CharmConfig(BaseConfigModel):
7979
plugin_icu_ext_enable: bool
8080
plugin_pltcl_enable: bool
8181
plugin_postgis_enable: bool
82+
plugin_timescaledb_enable: bool
8283
plugin_address_standardizer_enable: bool
8384
plugin_address_standardizer_data_us_enable: bool
8485
plugin_postgis_tiger_geocoder_enable: bool

src/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
SNAP_PACKAGES = [
3737
(
3838
POSTGRESQL_SNAP_NAME,
39-
{"revision": {"aarch64": "112", "x86_64": "113"}, "channel": "14/stable"},
39+
{"revision": {"aarch64": "114", "x86_64": "115"}, "channel": "14/stable"},
4040
)
4141
]
4242

templates/patroni.yml.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ bootstrap:
9191
log_truncate_on_rotation: 'on'
9292
logging_collector: 'on'
9393
wal_level: logical
94+
shared_preload_libraries: 'timescaledb'
9495
{%- if pg_parameters %}
9596
{%- for key, value in pg_parameters.items() %}
9697
{{key}}: {{value}}

tests/integration/test_plugins.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@
7878
ADDRESS_STANDARDIZER_EXTENSION_STATEMENT = "SELECT num, street, city, zip, zipplus FROM parse_address('1 Devonshire Place, Boston, MA 02109-1234');"
7979
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');"
8080
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');"
81-
POSTGIS_TOPOLOGY_STATEMENT = "SELECT topology.CreateTopology('nyc_topo', 26918, 0.5);"
82-
POSTGIS_RASTER_STATEMENT = "CREATE TABLE test_postgis_raster (name varchar, rast raster);"
81+
POSTGIS_TOPOLOGY_EXTENSION_STATEMENT = "SELECT topology.CreateTopology('nyc_topo', 26918, 0.5);"
82+
POSTGIS_RASTER_EXTENSION_STATEMENT = (
83+
"CREATE TABLE test_postgis_raster (name varchar, rast raster);"
84+
)
8385
VECTOR_EXTENSION_STATEMENT = (
8486
"CREATE TABLE vector_test (id bigserial PRIMARY KEY, embedding vector(3));"
8587
)
88+
TIMESCALEDB_EXTENSION_STATEMENT = "CREATE TABLE test_timescaledb (time TIMESTAMPTZ NOT NULL); SELECT create_hypertable('test_timescaledb', 'time');"
8689

8790

8891
@pytest.mark.group(1)
@@ -153,9 +156,10 @@ async def test_plugins(ops_test: OpsTest) -> None:
153156
"plugin_address_standardizer_enable": ADDRESS_STANDARDIZER_EXTENSION_STATEMENT,
154157
"plugin_address_standardizer_data_us_enable": ADDRESS_STANDARDIZER_DATA_US_EXTENSION_STATEMENT,
155158
"plugin_postgis_tiger_geocoder_enable": POSTGIS_TIGER_GEOCODER_EXTENSION_STATEMENT,
156-
"plugin_postgis_raster_enable": POSTGIS_RASTER_STATEMENT,
157-
"plugin_postgis_topology_enable": POSTGIS_TOPOLOGY_STATEMENT,
159+
"plugin_postgis_raster_enable": POSTGIS_RASTER_EXTENSION_STATEMENT,
160+
"plugin_postgis_topology_enable": POSTGIS_TOPOLOGY_EXTENSION_STATEMENT,
158161
"plugin_vector_enable": VECTOR_EXTENSION_STATEMENT,
162+
"plugin_timescaledb_enable": TIMESCALEDB_EXTENSION_STATEMENT,
159163
}
160164

161165
def enable_disable_config(enabled: False):

tests/unit/test_charm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,9 @@ def test_enable_disable_extensions(harness, caplog):
530530
plugin_vector_enable:
531531
default: false
532532
type: boolean
533+
plugin_timescaledb_enable:
534+
default: false
535+
type: boolean
533536
profile:
534537
default: production
535538
type: string"""

0 commit comments

Comments
 (0)