pglift-cli 2.6.1__tar.gz → 3.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/PKG-INFO +1 -1
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/instance.py +1 -1
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/model.py +23 -5
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/prometheus.py +7 -3
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/role.py +2 -2
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/test-cli-walkthrough.t +52 -42
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/test-demote.t +8 -7
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/test-help.t +34 -20
- pglift_cli-3.1.0/tests/expect/test-instance-name.t +45 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/test-port-validation.t +18 -15
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/test-prometheus.t +3 -3
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/test-standby-pgbackrest.t +20 -17
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/test-standby.t +8 -6
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/test-transactions.t +0 -1
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/test-upgrade.t +6 -4
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/unit/test_model.py +51 -1
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/unit/test_util.py +2 -2
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/.gitignore +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/README.md +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/hatch.toml +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/pyproject.toml +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/pytest.ini +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/__init__.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/__main__.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/_settings.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/_site.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/base.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/console.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/database.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/hookspecs.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/main.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/patroni.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/pgbackrest/__init__.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/pgbackrest/repo_path.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/pgconf.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/pghba.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/pm.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/postgres.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/py.typed +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/util.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/src/pglift_cli/wal.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/.gitignore +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/expect/test-base.t +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/unit/__init__.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/unit/conftest.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/unit/test__site.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/unit/test_audit.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/unit/test_cli.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/unit/test_main.py +0 -0
- {pglift_cli-2.6.1 → pglift_cli-3.1.0}/tests/unit/test_pm.py +0 -0
|
@@ -197,7 +197,7 @@ async def apply(
|
|
|
197
197
|
obj.lock,
|
|
198
198
|
audit(dry_run=dry_run),
|
|
199
199
|
diff.enabled(diff_format),
|
|
200
|
-
manager.from_manifest(
|
|
200
|
+
manager.from_manifest(instance, settings=_site.SETTINGS, actual=actual),
|
|
201
201
|
):
|
|
202
202
|
ret = await instances.apply(_site.SETTINGS, instance)
|
|
203
203
|
if output_format == "json":
|
|
@@ -22,6 +22,7 @@ from pglift.annotations import cli
|
|
|
22
22
|
from pglift.exceptions import MutuallyExclusiveError
|
|
23
23
|
from pglift.models.helpers import is_optional, optional_type
|
|
24
24
|
from pglift.models.interface import PresenceState
|
|
25
|
+
from pglift.settings import Settings
|
|
25
26
|
from pglift.types import (
|
|
26
27
|
Operation,
|
|
27
28
|
field_annotation,
|
|
@@ -33,6 +34,7 @@ from . import _site, logger
|
|
|
33
34
|
|
|
34
35
|
ModelType = type[pydantic.BaseModel]
|
|
35
36
|
T = TypeVar("T", bound=pydantic.BaseModel)
|
|
37
|
+
V = TypeVar("V")
|
|
36
38
|
Callback = Callable[..., Any]
|
|
37
39
|
ClickDecorator = Callable[[Callback], Callback]
|
|
38
40
|
DEFAULT = object()
|
|
@@ -296,6 +298,15 @@ def _paramspecs_from_model(
|
|
|
296
298
|
return DEFAULT
|
|
297
299
|
return value
|
|
298
300
|
|
|
301
|
+
def default_factory(
|
|
302
|
+
_ctx: click.Context,
|
|
303
|
+
_param: click.Argument,
|
|
304
|
+
value: V,
|
|
305
|
+
*,
|
|
306
|
+
callback: Callable[[Settings, V], V],
|
|
307
|
+
) -> V:
|
|
308
|
+
return callback(_site.SETTINGS, value)
|
|
309
|
+
|
|
299
310
|
def add_state_field_callback(
|
|
300
311
|
ctx: click.Context,
|
|
301
312
|
_param: click.Argument,
|
|
@@ -377,6 +388,17 @@ def _paramspecs_from_model(
|
|
|
377
388
|
),
|
|
378
389
|
)
|
|
379
390
|
|
|
391
|
+
elif config is not None and isinstance(config, cli.OptionalArgument):
|
|
392
|
+
attrs["required"] = False
|
|
393
|
+
attrs["callback"] = functools.partial(
|
|
394
|
+
default_factory,
|
|
395
|
+
callback=config.default_factory,
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
yield (
|
|
399
|
+
(modelname, argname),
|
|
400
|
+
ArgumentSpec((argname,), field, attrs, loc=(modelname,)),
|
|
401
|
+
)
|
|
380
402
|
else:
|
|
381
403
|
yield (
|
|
382
404
|
(modelname, argname),
|
|
@@ -386,11 +408,7 @@ def _paramspecs_from_model(
|
|
|
386
408
|
)
|
|
387
409
|
|
|
388
410
|
else:
|
|
389
|
-
if (
|
|
390
|
-
config
|
|
391
|
-
and isinstance(config, cli.Argument | cli.Option)
|
|
392
|
-
and config.metavar is not None
|
|
393
|
-
):
|
|
411
|
+
if config and isinstance(config, cli.Option) and config.metavar is not None:
|
|
394
412
|
metavar = config.metavar
|
|
395
413
|
else:
|
|
396
414
|
metavar = argname
|
|
@@ -71,7 +71,7 @@ async def apply(
|
|
|
71
71
|
dry_run: bool,
|
|
72
72
|
diff_format: diff.Format | None,
|
|
73
73
|
) -> None:
|
|
74
|
-
"""Apply manifest as a Prometheus postgres_exporter."""
|
|
74
|
+
"""Apply manifest as a Prometheus postgres_exporter (DEPRECATED)."""
|
|
75
75
|
settings = prometheus.get_settings(_site.SETTINGS)
|
|
76
76
|
name = data["name"]
|
|
77
77
|
op: types.Operation = "update" if impl.exists(name, settings) else "create"
|
|
@@ -93,7 +93,7 @@ async def apply(
|
|
|
93
93
|
@click.pass_obj
|
|
94
94
|
@async_command
|
|
95
95
|
async def install(obj: Obj, postgresexporter: PostgresExporter) -> None:
|
|
96
|
-
"""Install the service for a (non-local) instance."""
|
|
96
|
+
"""Install the service for a (non-local) instance (DEPRECATED)."""
|
|
97
97
|
settings = prometheus.get_settings(_site.SETTINGS)
|
|
98
98
|
with obj.lock, audit():
|
|
99
99
|
async with task.async_transaction():
|
|
@@ -105,7 +105,7 @@ async def install(obj: Obj, postgresexporter: PostgresExporter) -> None:
|
|
|
105
105
|
@click.pass_obj
|
|
106
106
|
@async_command
|
|
107
107
|
async def uninstall(obj: Obj, name: str) -> None:
|
|
108
|
-
"""Uninstall the service."""
|
|
108
|
+
"""Uninstall the service (DEPRECATED)."""
|
|
109
109
|
with obj.lock, audit():
|
|
110
110
|
await impl.drop(_site.SETTINGS, name)
|
|
111
111
|
|
|
@@ -121,6 +121,8 @@ async def start(obj: Obj, name: str, foreground: bool) -> None:
|
|
|
121
121
|
The NAME argument is a local identifier for the postgres_exporter
|
|
122
122
|
service. If the service is bound to a local instance, it should be
|
|
123
123
|
<version>-<name>.
|
|
124
|
+
|
|
125
|
+
Deprecation warning: in a future version, only local instances will be handled.
|
|
124
126
|
"""
|
|
125
127
|
settings = prometheus.get_settings(_site.SETTINGS)
|
|
126
128
|
with obj.lock, audit():
|
|
@@ -140,6 +142,8 @@ async def stop(obj: Obj, name: str) -> None:
|
|
|
140
142
|
The NAME argument is a local identifier for the postgres_exporter
|
|
141
143
|
service. If the service is bound to a local instance, it should be
|
|
142
144
|
<version>-<name>.
|
|
145
|
+
|
|
146
|
+
Deprecation warning: in a future version, only local instances will be handled.
|
|
143
147
|
"""
|
|
144
148
|
settings = prometheus.get_settings(_site.SETTINGS)
|
|
145
149
|
with obj.lock, audit():
|
|
@@ -173,7 +173,7 @@ async def ls(instance: PostgreSQLInstance, output_format: OutputFormat | None) -
|
|
|
173
173
|
partial(
|
|
174
174
|
model_dump,
|
|
175
175
|
context={"pretty": True},
|
|
176
|
-
exclude={"hba_records"
|
|
176
|
+
exclude={"hba_records"},
|
|
177
177
|
),
|
|
178
178
|
)
|
|
179
179
|
|
|
@@ -198,7 +198,7 @@ async def get(
|
|
|
198
198
|
partial(
|
|
199
199
|
model_dump,
|
|
200
200
|
context={"pretty": True},
|
|
201
|
-
exclude={"hba_records"
|
|
201
|
+
exclude={"hba_records"},
|
|
202
202
|
),
|
|
203
203
|
box=None,
|
|
204
204
|
)
|
|
@@ -26,7 +26,7 @@ Site settings:
|
|
|
26
26
|
> postgresql:
|
|
27
27
|
> auth:
|
|
28
28
|
> local: md5
|
|
29
|
-
> passfile: '$TMPDIR/.pgpass'
|
|
29
|
+
> passfile: '$TMPDIR/pgpass/.pgpass'
|
|
30
30
|
> password_command:
|
|
31
31
|
> - jq
|
|
32
32
|
> - -r
|
|
@@ -65,7 +65,7 @@ Make sure password_command works:
|
|
|
65
65
|
"local": "md5",
|
|
66
66
|
"host": "trust",
|
|
67
67
|
"hostssl": "trust",
|
|
68
|
-
"passfile": "$TMPDIR/.pgpass",
|
|
68
|
+
"passfile": "$TMPDIR/pgpass/.pgpass",
|
|
69
69
|
"password_command": [
|
|
70
70
|
"jq",
|
|
71
71
|
"-r",
|
|
@@ -89,10 +89,11 @@ Make sure password_command works:
|
|
|
89
89
|
$ pglift site-configure install
|
|
90
90
|
INFO creating base pgBackRest configuration directory: $TMPDIR/etc/pgbackrest
|
|
91
91
|
INFO installing base pgBackRest configuration
|
|
92
|
-
INFO creating pgBackRest include directory
|
|
92
|
+
INFO creating pgBackRest include directory: $TMPDIR/etc/pgbackrest/conf.d
|
|
93
93
|
INFO creating pgBackRest repository backups and archive directory: $TMPDIR/pgbackrest
|
|
94
94
|
INFO creating pgBackRest log directory: $TMPDIR/log/pgbackrest
|
|
95
95
|
INFO creating pgBackRest spool directory: $TMPDIR/srv/pgbackrest/spool
|
|
96
|
+
INFO creating pgpass file directory: $TMPDIR/pgpass
|
|
96
97
|
INFO creating PostgreSQL log directory: $TMPDIR/log/postgresql
|
|
97
98
|
|
|
98
99
|
$ trap "pglift --non-interactive instance drop main; \
|
|
@@ -116,10 +117,11 @@ Audit log:
|
|
|
116
117
|
DEBUG - pglift.util - using 'pgbackrest/pgbackrest.conf' configuration file from distribution
|
|
117
118
|
INFO - pglift.util - creating base pgBackRest configuration directory: $TMPDIR/etc/pgbackrest
|
|
118
119
|
INFO - pglift.pgbackrest - installing base pgBackRest configuration
|
|
119
|
-
INFO - pglift.
|
|
120
|
+
INFO - pglift.util - creating pgBackRest include directory: $TMPDIR/etc/pgbackrest/conf.d
|
|
120
121
|
INFO - pglift.util - creating pgBackRest repository backups and archive directory: $TMPDIR/pgbackrest
|
|
121
122
|
INFO - pglift.util - creating pgBackRest log directory: $TMPDIR/log/pgbackrest
|
|
122
123
|
INFO - pglift.util - creating pgBackRest spool directory: $TMPDIR/srv/pgbackrest/spool
|
|
124
|
+
INFO - pglift.util - creating pgpass file directory: $TMPDIR/pgpass
|
|
123
125
|
INFO - pglift.util - creating PostgreSQL log directory: $TMPDIR/log/postgresql
|
|
124
126
|
INFO - pglift_cli.audit - command completed \(\d+.\d+ seconds\) (re)
|
|
125
127
|
|
|
@@ -166,13 +168,13 @@ Error cases for instance operations
|
|
|
166
168
|
Error: instance already exists
|
|
167
169
|
[1]
|
|
168
170
|
$ pglift instance create 'in/va/lid' --pgbackrest-stanza=xxx --surole-password=s3per
|
|
169
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
171
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
170
172
|
Try 'pglift instance create --help' for help.
|
|
171
173
|
|
|
172
|
-
Error: Invalid value for 'NAME': String should match pattern '^[^/-]+$'
|
|
174
|
+
Error: Invalid value for '[NAME]': String should match pattern '^[^/-]+$'
|
|
173
175
|
[2]
|
|
174
176
|
$ pglift instance create stdby --standby-for='port 1234' --pgbackrest-stanza=stddy --surole-password=s3per
|
|
175
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
177
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
176
178
|
Try 'pglift instance create --help' for help.
|
|
177
179
|
|
|
178
180
|
Error: Invalid value for '--standby-for': missing "=" after "port" in connection info string
|
|
@@ -218,7 +220,7 @@ List instances
|
|
|
218
220
|
$ pglift instance list -o json | jq '.[] | .name, .status'
|
|
219
221
|
"main"
|
|
220
222
|
"running"
|
|
221
|
-
$ pglift instance list --version=
|
|
223
|
+
$ pglift instance list --version=15
|
|
222
224
|
|
|
223
225
|
Get the status of an instance:
|
|
224
226
|
|
|
@@ -235,6 +237,15 @@ Reload, restart:
|
|
|
235
237
|
|
|
236
238
|
$ pglift instance reload
|
|
237
239
|
INFO reloading PostgreSQL configuration for 1\d\/main (re)
|
|
240
|
+
$ pglift instance stop
|
|
241
|
+
INFO stopping PostgreSQL 1\d\/main (re)
|
|
242
|
+
INFO stopping Prometheus postgres_exporter 1\d-main (re)
|
|
243
|
+
$ pglift instance restart
|
|
244
|
+
INFO restarting instance 1\d\/main (re)
|
|
245
|
+
INFO restarting PostgreSQL
|
|
246
|
+
INFO stopping PostgreSQL 1\d\/main (re)
|
|
247
|
+
INFO starting PostgreSQL 1\d\/main (re)
|
|
248
|
+
INFO starting Prometheus postgres_exporter 1\d-main (re)
|
|
238
249
|
$ pglift instance restart
|
|
239
250
|
INFO restarting instance 1\d\/main (re)
|
|
240
251
|
INFO stopping Prometheus postgres_exporter 1\d-main (re)
|
|
@@ -251,19 +262,20 @@ Stop, alter, (re)start an instance:
|
|
|
251
262
|
$ pglift instance alter --no-data-checksums
|
|
252
263
|
INFO configuring PostgreSQL
|
|
253
264
|
INFO disabling data checksums
|
|
254
|
-
$ pglift instance alter --prometheus-port=$PGEPORT1
|
|
265
|
+
$ pglift instance alter --prometheus-port=$PGEPORT1 -o json --diff
|
|
255
266
|
INFO configuring PostgreSQL
|
|
256
|
-
INFO starting PostgreSQL 1\d\/main (re)
|
|
257
267
|
INFO reconfiguring Prometheus postgres_exporter 1\d-main (re)
|
|
258
|
-
|
|
268
|
+
{
|
|
269
|
+
"change_state": "changed",
|
|
270
|
+
"diff": [
|
|
271
|
+
"--- $TMPDIR/etc/prometheus/postgres_exporter-1*-main.conf\n+++ $TMPDIR/etc/prometheus/postgres_exporter-1*-main.conf\n@@ -1,2 +1,2 @@\n DATA_SOURCE_NAME=postgresql://prometheus@:*/postgres?*\n-POSTGRES_EXPORTER_OPTS='--web.listen-address :* --log.level info'\n+POSTGRES_EXPORTER_OPTS='--web.listen-address :* --log.level info'" (glob)
|
|
272
|
+
],
|
|
273
|
+
"pending_restart": false
|
|
274
|
+
}
|
|
275
|
+
$ pglift instance alter --state=started --powa-password=p0W@ --diff
|
|
276
|
+
INFO configuring PostgreSQL
|
|
277
|
+
INFO starting PostgreSQL 1\d\/main (re)
|
|
259
278
|
INFO starting Prometheus postgres_exporter 1\d-main (re)
|
|
260
|
-
--- $TMPDIR/etc/prometheus/postgres_exporter-1*-main.conf (glob)
|
|
261
|
-
+++ $TMPDIR/etc/prometheus/postgres_exporter-1*-main.conf (glob)
|
|
262
|
-
@@ -1,2 +1,2 @@
|
|
263
|
-
DATA_SOURCE_NAME=postgresql://prometheus@:*/postgres?host=* (glob)
|
|
264
|
-
*%2Fpostgresql&sslmode=disable (glob)
|
|
265
|
-
-POSTGRES_EXPORTER_OPTS='--web.listen-address :\d+ --log.level info' (re)
|
|
266
|
-
\+POSTGRES_EXPORTER_OPTS='--web.listen-address :\d+ --log.level info' (re)
|
|
267
279
|
--- /dev/null
|
|
268
280
|
+++ $TMPDIR/run/prometheus/1*-main.pid (glob)
|
|
269
281
|
@@ -0,0 +1 @@
|
|
@@ -330,7 +342,7 @@ Stop, alter, (re)start an instance:
|
|
|
330
342
|
Instance environment, and program execution:
|
|
331
343
|
|
|
332
344
|
$ pglift instance env | grep PASSFILE
|
|
333
|
-
PGPASSFILE=$TMPDIR/.pgpass
|
|
345
|
+
PGPASSFILE=$TMPDIR/pgpass/.pgpass
|
|
334
346
|
$ pglift instance env -o json | jq '.PGBACKREST_STANZA, .PGHOST, .PGPASSWORD'
|
|
335
347
|
"main"
|
|
336
348
|
"$TMPDIR/run/postgresql"
|
|
@@ -378,6 +390,10 @@ PostgreSQL configuration
|
|
|
378
390
|
$ pglift --non-interactive pgconf remove fsync
|
|
379
391
|
Error: 'fsync' not found in managed configuration
|
|
380
392
|
[1]
|
|
393
|
+
$ pglift --non-interactive pgconf set Port=9988
|
|
394
|
+
INFO configuring PostgreSQL
|
|
395
|
+
Error: invalid postgresql configuration, Bad line: 'Port = 9988\n'.
|
|
396
|
+
[1]
|
|
381
397
|
$ pglift --non-interactive pgconf remove --dry-run log_statement
|
|
382
398
|
WARNING failed to get data_checksums status: 'Data page checksum version' not found in controldata
|
|
383
399
|
INFO configuring PostgreSQL
|
|
@@ -398,6 +414,7 @@ PostgreSQL configuration
|
|
|
398
414
|
INFO reconfiguring Prometheus postgres_exporter 1\d-main (re)
|
|
399
415
|
INFO restarting Prometheus postgres_exporter 1\d-main (re)
|
|
400
416
|
INFO configuring pgBackRest stanza 'main' for pg1-path=\$TMPDIR\/srv\/pgsql\/1\d\/main\/data (re)
|
|
417
|
+
WARNING Due to 'port' change, the instance may be in an unstable state until it is restarted.
|
|
401
418
|
port: \d+ -> 1234 (re)
|
|
402
419
|
DRY RUN: no changes made
|
|
403
420
|
|
|
@@ -502,14 +519,14 @@ Add and manipulate roles:
|
|
|
502
519
|
|
|
503
520
|
$ pglift role -i main create dba --login --pgpass --password=qwerty --in-role=pg_read_all_stats --dry-run
|
|
504
521
|
INFO creating role 'dba'
|
|
505
|
-
INFO adding an entry for 'dba' in \$TMPDIR\/.pgpass \(port=\d+\) (re)
|
|
522
|
+
INFO adding an entry for 'dba' in \$TMPDIR\/pgpass\/.pgpass \(port=\d+\) (re)
|
|
506
523
|
DRY RUN: no changes made
|
|
507
524
|
|
|
508
525
|
$ pglift role -i main create dba --login --pgpass --password=qwerty --in-role=pg_read_all_stats
|
|
509
526
|
INFO creating role 'dba'
|
|
510
|
-
INFO adding an entry for 'dba' in \$TMPDIR\/.pgpass \(port=\d+\) (re)
|
|
527
|
+
INFO adding an entry for 'dba' in \$TMPDIR\/pgpass\/.pgpass \(port=\d+\) (re)
|
|
511
528
|
|
|
512
|
-
$ cat $TMPDIR/.pgpass
|
|
529
|
+
$ cat $TMPDIR/pgpass/.pgpass
|
|
513
530
|
\*:\d+:\*:dba:qwerty (re)
|
|
514
531
|
|
|
515
532
|
$ pglift role get dba
|
|
@@ -539,8 +556,8 @@ Add and manipulate roles:
|
|
|
539
556
|
|
|
540
557
|
$ pglift role alter dba --connection-limit=10 --inherit --no-pgpass --no-login --revoke=pg_read_all_stats --grant=pg_monitor --valid-until=2026-01-01 --dry-run
|
|
541
558
|
INFO altering role 'dba'
|
|
542
|
-
INFO removing entry for 'dba' in \$TMPDIR\/.pgpass \(port=\d+\) (re)
|
|
543
|
-
INFO removing now empty $TMPDIR/.pgpass
|
|
559
|
+
INFO removing entry for 'dba' in \$TMPDIR\/pgpass\/.pgpass \(port=\d+\) (re)
|
|
560
|
+
INFO removing now empty $TMPDIR/pgpass/.pgpass
|
|
544
561
|
DRY RUN: no changes made
|
|
545
562
|
|
|
546
563
|
$ pglift role -i main create dba --password=qwerty --encrypted-password=md5azerty
|
|
@@ -552,8 +569,8 @@ Add and manipulate roles:
|
|
|
552
569
|
|
|
553
570
|
$ pglift role alter dba --connection-limit=10 --inherit --no-pgpass --no-login --revoke=pg_read_all_stats --grant=pg_monitor --valid-until=2026-01-01
|
|
554
571
|
INFO altering role 'dba'
|
|
555
|
-
INFO removing entry for 'dba' in \$TMPDIR\/.pgpass \(port=\d+\) (re)
|
|
556
|
-
INFO removing now empty $TMPDIR/.pgpass
|
|
572
|
+
INFO removing entry for 'dba' in \$TMPDIR\/pgpass\/.pgpass \(port=\d+\) (re)
|
|
573
|
+
INFO removing now empty $TMPDIR/pgpass/.pgpass
|
|
557
574
|
|
|
558
575
|
$ pglift role get dba -o json
|
|
559
576
|
{
|
|
@@ -567,7 +584,6 @@ Add and manipulate roles:
|
|
|
567
584
|
"replication": false,
|
|
568
585
|
"connection_limit": 10,
|
|
569
586
|
"valid_until": "2026-01-01T00:00:00Z",
|
|
570
|
-
"validity": "2026-01-01T00:00:00Z",
|
|
571
587
|
"memberships": [
|
|
572
588
|
{
|
|
573
589
|
"role": "pg_monitor"
|
|
@@ -647,7 +663,6 @@ Add and manipulate roles:
|
|
|
647
663
|
"replication": false,
|
|
648
664
|
"connection_limit": 3,
|
|
649
665
|
"valid_until": null,
|
|
650
|
-
"validity": null,
|
|
651
666
|
"memberships": [
|
|
652
667
|
{
|
|
653
668
|
"role": "pg_monitor"
|
|
@@ -703,7 +718,6 @@ Add and manipulate roles:
|
|
|
703
718
|
"replication": false,
|
|
704
719
|
"connection_limit": null,
|
|
705
720
|
"valid_until": null,
|
|
706
|
-
"validity": null,
|
|
707
721
|
"memberships": [],
|
|
708
722
|
"hba_records": []
|
|
709
723
|
},
|
|
@@ -718,7 +732,6 @@ Add and manipulate roles:
|
|
|
718
732
|
"replication": false,
|
|
719
733
|
"connection_limit": 10,
|
|
720
734
|
"valid_until": "2026-01-01T00:00:00Z",
|
|
721
|
-
"validity": "2026-01-01T00:00:00Z",
|
|
722
735
|
"memberships": [
|
|
723
736
|
{
|
|
724
737
|
"role": "pg_monitor"
|
|
@@ -737,7 +750,6 @@ Add and manipulate roles:
|
|
|
737
750
|
"replication": false,
|
|
738
751
|
"connection_limit": null,
|
|
739
752
|
"valid_until": null,
|
|
740
|
-
"validity": null,
|
|
741
753
|
"memberships": [],
|
|
742
754
|
"hba_records": []
|
|
743
755
|
},
|
|
@@ -752,7 +764,6 @@ Add and manipulate roles:
|
|
|
752
764
|
"replication": true,
|
|
753
765
|
"connection_limit": null,
|
|
754
766
|
"valid_until": null,
|
|
755
|
-
"validity": null,
|
|
756
767
|
"memberships": [],
|
|
757
768
|
"hba_records": []
|
|
758
769
|
},
|
|
@@ -767,7 +778,6 @@ Add and manipulate roles:
|
|
|
767
778
|
"replication": false,
|
|
768
779
|
"connection_limit": null,
|
|
769
780
|
"valid_until": null,
|
|
770
|
-
"validity": null,
|
|
771
781
|
"memberships": [
|
|
772
782
|
{
|
|
773
783
|
"role": "pg_monitor"
|
|
@@ -786,7 +796,6 @@ Add and manipulate roles:
|
|
|
786
796
|
"replication": false,
|
|
787
797
|
"connection_limit": null,
|
|
788
798
|
"valid_until": null,
|
|
789
|
-
"validity": null,
|
|
790
799
|
"memberships": [],
|
|
791
800
|
"hba_records": []
|
|
792
801
|
},
|
|
@@ -801,7 +810,6 @@ Add and manipulate roles:
|
|
|
801
810
|
"replication": false,
|
|
802
811
|
"connection_limit": 3,
|
|
803
812
|
"valid_until": null,
|
|
804
|
-
"validity": null,
|
|
805
813
|
"memberships": [
|
|
806
814
|
{
|
|
807
815
|
"role": "pg_monitor"
|
|
@@ -1282,11 +1290,13 @@ Cleanup.
|
|
|
1282
1290
|
INFO deconfiguring Prometheus postgres_exporter 1\d-main (re)
|
|
1283
1291
|
INFO deleting pgBackRest stanza 'main'
|
|
1284
1292
|
INFO deconfiguring pgBackRest stanza 'main'
|
|
1285
|
-
INFO removing entries matching port=\d+ from \$TMPDIR\/.pgpass (re)
|
|
1286
|
-
INFO deleting PostgreSQL data
|
|
1287
|
-
INFO deleting
|
|
1293
|
+
INFO removing entries matching port=\d+ from \$TMPDIR\/pgpass\/.pgpass (re)
|
|
1294
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/srv\/pgsql\/1\d\/main/data (re)
|
|
1295
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/srv\/pgsql\/1\d\/main/wal (re)
|
|
1296
|
+
INFO deleting pgBackRest include directory: $TMPDIR/etc/pgbackrest/conf.d
|
|
1288
1297
|
INFO uninstalling base pgBackRest configuration
|
|
1289
|
-
INFO deleting pgBackRest log directory
|
|
1290
|
-
INFO deleting pgBackRest spool directory
|
|
1291
|
-
INFO deleting
|
|
1292
|
-
INFO deleting PostgreSQL
|
|
1298
|
+
INFO deleting pgBackRest log directory: $TMPDIR/log/pgbackrest
|
|
1299
|
+
INFO deleting pgBackRest spool directory: $TMPDIR/srv/pgbackrest/spool
|
|
1300
|
+
INFO deleting pgpass file parent directory
|
|
1301
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/log/postgresql
|
|
1302
|
+
INFO deleting PostgreSQL socket directory: $TMPDIR/run/postgresql (no-eol)
|
|
@@ -143,7 +143,6 @@ Check this role from the standby
|
|
|
143
143
|
"replication": true,
|
|
144
144
|
"connection_limit": null,
|
|
145
145
|
"valid_until": null,
|
|
146
|
-
"validity": null,
|
|
147
146
|
"memberships": [],
|
|
148
147
|
"hba_records": []
|
|
149
148
|
}
|
|
@@ -221,11 +220,13 @@ And finally check replication is functional
|
|
|
221
220
|
|
|
222
221
|
INFO dropping instance 1\d\/pg1 (re)
|
|
223
222
|
INFO stopping PostgreSQL 1\d\/pg1 (re)
|
|
224
|
-
INFO deleting PostgreSQL data
|
|
223
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/1\/srv\/pgsql\/1\d\/pg1\/data (re)
|
|
224
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/1\/srv\/pgsql\/1\d\/pg1\/wal (re)
|
|
225
225
|
INFO dropping instance 1\d\/pg2 (re)
|
|
226
226
|
INFO stopping PostgreSQL 1\d\/pg2 (re)
|
|
227
|
-
INFO deleting PostgreSQL data
|
|
228
|
-
INFO deleting PostgreSQL
|
|
229
|
-
INFO deleting PostgreSQL
|
|
230
|
-
INFO deleting PostgreSQL
|
|
231
|
-
INFO deleting PostgreSQL
|
|
227
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/2\/srv\/pgsql\/1\d\/pg2\/data (re)
|
|
228
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/2\/srv\/pgsql\/1\d\/pg2\/wal (re)
|
|
229
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/1/log/postgresql
|
|
230
|
+
INFO deleting PostgreSQL socket directory: $TMPDIR/1/run/postgresql
|
|
231
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/2/log/postgresql
|
|
232
|
+
INFO deleting PostgreSQL socket directory: $TMPDIR/2/run/postgresql (no-eol)
|
|
@@ -12,9 +12,9 @@ Site settings
|
|
|
12
12
|
$ export PGLIFT_RUN_PREFIX=$TMPDIR/run
|
|
13
13
|
|
|
14
14
|
$ bindir=$TMPDIR/$TESTFILE/bin
|
|
15
|
-
$ mkdir -p $bindir/pgsql/
|
|
16
|
-
$ touch $bindir/pgsql/
|
|
17
|
-
$ chmod +x $bindir/pgsql/
|
|
15
|
+
$ mkdir -p $bindir/pgsql/18/bin
|
|
16
|
+
$ touch $bindir/pgsql/18/bin/pg_ctl
|
|
17
|
+
$ chmod +x $bindir/pgsql/18/bin/pg_ctl
|
|
18
18
|
$ export PGLIFT_POSTGRESQL__BINDIR=$bindir/pgsql/{version}/bin \
|
|
19
19
|
> PGLIFT_POSTGRESQL__AUTH__PASSFILE="null" \
|
|
20
20
|
> PGLIFT_POSTGRESQL__REPLROLE="replication"
|
|
@@ -32,13 +32,23 @@ Site settings
|
|
|
32
32
|
$ export PGLIFT_POWA='{}'
|
|
33
33
|
|
|
34
34
|
$ pglift site-settings --no-defaults -o json \
|
|
35
|
-
> | jq '.postgresql, .pgbackrest, .prometheus, .prefix, .run_prefix'
|
|
35
|
+
> | jq '.patroni, .postgresql, .pgbackrest, .prometheus, .prefix, .run_prefix'
|
|
36
36
|
{
|
|
37
|
-
"
|
|
37
|
+
"execpath": "$TMPDIR/test-help.t/bin/patroni",
|
|
38
|
+
"ctlpath": "$TMPDIR/test-help.t/bin/patronictl",
|
|
39
|
+
"configpath": "$TMPDIR/etc/patroni/{name}.yaml",
|
|
40
|
+
"logpath": "$TMPDIR/log/patroni",
|
|
41
|
+
"pid_file": "$TMPDIR/run/patroni/{name}.pid",
|
|
42
|
+
"postgresql": {
|
|
43
|
+
"passfile": "$TMPDIR/etc/patroni/{name}.pgpass"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
{
|
|
47
|
+
"bindir": "$TMPDIR/test-help.t/bin/pgsql/{version}/bin",
|
|
38
48
|
"versions": [
|
|
39
49
|
{
|
|
40
|
-
"version": "
|
|
41
|
-
"bindir": "$TMPDIR/*/bin/pgsql/
|
|
50
|
+
"version": "18",
|
|
51
|
+
"bindir": "$TMPDIR/*/bin/pgsql/18/bin" (glob)
|
|
42
52
|
}
|
|
43
53
|
],
|
|
44
54
|
"auth": {
|
|
@@ -218,12 +228,12 @@ Instance commands
|
|
|
218
228
|
-o, --output-format [json] Specify the output format.
|
|
219
229
|
--help Show this message and exit.
|
|
220
230
|
$ pglift instance create --help
|
|
221
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
231
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
222
232
|
|
|
223
233
|
Initialize a PostgreSQL instance
|
|
224
234
|
|
|
225
235
|
Options:
|
|
226
|
-
--version [17|16|15|14
|
|
236
|
+
--version [18|17|16|15|14] PostgreSQL version; if unspecified,
|
|
227
237
|
determined from site settings or most recent
|
|
228
238
|
PostgreSQL installation available on site.
|
|
229
239
|
--standby-for DSN DSN of primary for streaming replication.
|
|
@@ -363,7 +373,7 @@ Instance commands
|
|
|
363
373
|
List the available instances
|
|
364
374
|
|
|
365
375
|
Options:
|
|
366
|
-
--version [17|16|15|14
|
|
376
|
+
--version [18|17|16|15|14] Only list instances of specified version.
|
|
367
377
|
-o, --output-format [json] Specify the output format.
|
|
368
378
|
--help Show this message and exit.
|
|
369
379
|
$ pglift instance logs --help
|
|
@@ -525,7 +535,7 @@ Instance commands
|
|
|
525
535
|
Required if there is more than one instance on system.
|
|
526
536
|
|
|
527
537
|
Options:
|
|
528
|
-
--version [17|16|15|14
|
|
538
|
+
--version [18|17|16|15|14] PostgreSQL version of the new instance (default
|
|
529
539
|
to site-configured value).
|
|
530
540
|
--name TEXT Name of the new instance (default to old
|
|
531
541
|
instance name).
|
|
@@ -617,7 +627,6 @@ Role commands
|
|
|
617
627
|
make.
|
|
618
628
|
--valid-until VALID_UNTIL Date and time after which the role's
|
|
619
629
|
password is no longer valid.
|
|
620
|
-
--validity VALIDITY DEPRECATED. Use 'valid_until' instead.
|
|
621
630
|
--grant ROLE Grant membership of the given role. (Can be
|
|
622
631
|
used multiple times.)
|
|
623
632
|
--revoke ROLE Revoke membership of the given role. (Can be
|
|
@@ -646,7 +655,6 @@ Role commands
|
|
|
646
655
|
make.
|
|
647
656
|
--valid-until VALID_UNTIL Date and time after which the role's
|
|
648
657
|
password is no longer valid.
|
|
649
|
-
--validity VALIDITY DEPRECATED. Use 'valid_until' instead.
|
|
650
658
|
--in-role ROLE Roles which this role should be a member of.
|
|
651
659
|
(Can be used multiple times.)
|
|
652
660
|
--dry-run Simulate change operations.
|
|
@@ -904,7 +912,7 @@ PostgreSQL configuration commands
|
|
|
904
912
|
Options:
|
|
905
913
|
--help Show this message and exit.
|
|
906
914
|
|
|
907
|
-
|
|
915
|
+
HBA configuration management commands
|
|
908
916
|
|
|
909
917
|
$ pglift pghba --help
|
|
910
918
|
Usage: pglift pghba [OPTIONS] COMMAND [ARGS]...
|
|
@@ -1012,15 +1020,15 @@ Patroni commands:
|
|
|
1012
1020
|
--help Show this message and exit.
|
|
1013
1021
|
|
|
1014
1022
|
Commands:
|
|
1015
|
-
apply Apply manifest as a Prometheus postgres_exporter.
|
|
1016
|
-
install Install the service for a (non-local) instance.
|
|
1023
|
+
apply Apply manifest as a Prometheus postgres_exporter (DEPRECATED).
|
|
1024
|
+
install Install the service for a (non-local) instance (DEPRECATED).
|
|
1017
1025
|
start Start postgres_exporter service NAME.
|
|
1018
1026
|
stop Stop postgres_exporter service NAME.
|
|
1019
|
-
uninstall Uninstall the service.
|
|
1027
|
+
uninstall Uninstall the service (DEPRECATED).
|
|
1020
1028
|
$ pglift postgres_exporter apply --help
|
|
1021
1029
|
Usage: pglift postgres_exporter apply [OPTIONS]
|
|
1022
1030
|
|
|
1023
|
-
Apply manifest as a Prometheus postgres_exporter.
|
|
1031
|
+
Apply manifest as a Prometheus postgres_exporter (DEPRECATED).
|
|
1024
1032
|
|
|
1025
1033
|
Options:
|
|
1026
1034
|
-f, --file MANIFEST [required]
|
|
@@ -1032,7 +1040,7 @@ Patroni commands:
|
|
|
1032
1040
|
$ pglift postgres_exporter install --help
|
|
1033
1041
|
Usage: pglift postgres_exporter install [OPTIONS] NAME DSN PORT
|
|
1034
1042
|
|
|
1035
|
-
Install the service for a (non-local) instance.
|
|
1043
|
+
Install the service for a (non-local) instance (DEPRECATED).
|
|
1036
1044
|
|
|
1037
1045
|
Options:
|
|
1038
1046
|
--password PASSWORD Connection password.
|
|
@@ -1046,6 +1054,9 @@ Patroni commands:
|
|
|
1046
1054
|
The NAME argument is a local identifier for the postgres_exporter service.
|
|
1047
1055
|
If the service is bound to a local instance, it should be <version>-<name>.
|
|
1048
1056
|
|
|
1057
|
+
Deprecation warning: in a future version, only local instances will be
|
|
1058
|
+
handled.
|
|
1059
|
+
|
|
1049
1060
|
Options:
|
|
1050
1061
|
--foreground Start the program in foreground.
|
|
1051
1062
|
--help Show this message and exit.
|
|
@@ -1057,12 +1068,15 @@ Patroni commands:
|
|
|
1057
1068
|
The NAME argument is a local identifier for the postgres_exporter service.
|
|
1058
1069
|
If the service is bound to a local instance, it should be <version>-<name>.
|
|
1059
1070
|
|
|
1071
|
+
Deprecation warning: in a future version, only local instances will be
|
|
1072
|
+
handled.
|
|
1073
|
+
|
|
1060
1074
|
Options:
|
|
1061
1075
|
--help Show this message and exit.
|
|
1062
1076
|
$ pglift postgres_exporter uninstall --help
|
|
1063
1077
|
Usage: pglift postgres_exporter uninstall [OPTIONS] NAME
|
|
1064
1078
|
|
|
1065
|
-
Uninstall the service.
|
|
1079
|
+
Uninstall the service (DEPRECATED).
|
|
1066
1080
|
|
|
1067
1081
|
Options:
|
|
1068
1082
|
--help Show this message and exit.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Dalibo
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
4
|
+
|
|
5
|
+
Site settings and configuration
|
|
6
|
+
|
|
7
|
+
$ export PGLIFT_CLI__LOG_FORMAT="%(levelname)-4s %(message)s"
|
|
8
|
+
$ export PGLIFT_CLI__LOG_LEVEL=info
|
|
9
|
+
$ export PGLIFT_POSTGRESQL__AUTH__PASSFILE=$TMPDIR/pgpass/.pgpass
|
|
10
|
+
$ export PGLIFT_INSTANCE_DEFAULT_NAME=myinstance
|
|
11
|
+
$ export PGLIFT_PREFIX=$TMPDIR
|
|
12
|
+
$ export PGLIFT_RUN_PREFIX=$TMPDIR/run
|
|
13
|
+
$ alias pglift="pglift --log-level=INFO --non-interactive"
|
|
14
|
+
|
|
15
|
+
$ pglift site-configure install
|
|
16
|
+
INFO creating pgpass file directory: $TMPDIR/pgpass
|
|
17
|
+
INFO creating PostgreSQL log directory: $TMPDIR/log/postgresql
|
|
18
|
+
|
|
19
|
+
(Cleanup steps)
|
|
20
|
+
$ trap "pglift --non-interactive instance drop; \
|
|
21
|
+
> pglift --non-interactive site-configure uninstall; \
|
|
22
|
+
> port-for -u postgres" \
|
|
23
|
+
> EXIT
|
|
24
|
+
|
|
25
|
+
Define ports:
|
|
26
|
+
$ PGPORT=$(port-for pg1)
|
|
27
|
+
|
|
28
|
+
Create an instance without a name
|
|
29
|
+
$ pglift instance create --port=$PGPORT
|
|
30
|
+
INFO initializing PostgreSQL
|
|
31
|
+
INFO configuring PostgreSQL authentication
|
|
32
|
+
INFO configuring PostgreSQL
|
|
33
|
+
INFO creating PostgreSQL socket directory directory: $TMPDIR/run/postgresql
|
|
34
|
+
INFO starting PostgreSQL 1\d\/myinstance (re)
|
|
35
|
+
INFO creating instance dumps directory: \$TMPDIR\/srv\/dumps\/1\d-myinstance (re)
|
|
36
|
+
|
|
37
|
+
Cleanup.
|
|
38
|
+
INFO dropping instance 1\d\/myinstance (re)
|
|
39
|
+
INFO stopping PostgreSQL 1\d\/myinstance (re)
|
|
40
|
+
INFO removing entries matching port=\d+ from \$TMPDIR\/pgpass/.pgpass (re)
|
|
41
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/srv\/pgsql\/1\d\/myinstance/data (re)
|
|
42
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/srv\/pgsql\/1\d\/myinstance/wal (re)
|
|
43
|
+
INFO deleting pgpass file parent directory
|
|
44
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/log/postgresql
|
|
45
|
+
INFO deleting PostgreSQL socket directory: $TMPDIR/run/postgresql (no-eol)
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
$ pglift site-configure install
|
|
28
28
|
INFO creating base pgBackRest configuration directory: $TMPDIR/etc/pgbackrest
|
|
29
29
|
INFO installing base pgBackRest configuration
|
|
30
|
-
INFO creating pgBackRest include directory
|
|
30
|
+
INFO creating pgBackRest include directory: $TMPDIR/etc/pgbackrest/conf.d
|
|
31
31
|
INFO creating pgBackRest repository backups and archive directory: $TMPDIR/pgbackrest-not-used
|
|
32
32
|
INFO creating pgBackRest log directory: $TMPDIR/log/pgbackrest
|
|
33
33
|
INFO creating pgBackRest spool directory: $TMPDIR/srv/pgbackrest/spool
|
|
@@ -57,19 +57,19 @@ With custom ports
|
|
|
57
57
|
INFO creating instance dumps directory: \$TMPDIR\/srv\/dumps\/1\d-main (re)
|
|
58
58
|
INFO starting Prometheus postgres_exporter 1\d-main (re)
|
|
59
59
|
$ pglift instance create other --port=$PG2PORT --prometheus-port=$PGE1PORT
|
|
60
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
60
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
61
61
|
Try 'pglift instance create --help' for help.
|
|
62
62
|
|
|
63
63
|
Error: Invalid value for '--prometheus-port': port \d+ already in use (re)
|
|
64
64
|
[2]
|
|
65
65
|
$ pglift instance create other --port=$PG1PORT --prometheus-port=$PGE2PORT
|
|
66
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
66
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
67
67
|
Try 'pglift instance create --help' for help.
|
|
68
68
|
|
|
69
69
|
Error: Invalid value for '--port': port \d+ already in use (re)
|
|
70
70
|
[2]
|
|
71
71
|
$ pglift instance create other --port=$PG1PORT --prometheus-port=$PGE1PORT
|
|
72
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
72
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
73
73
|
Try 'pglift instance create --help' for help.
|
|
74
74
|
|
|
75
75
|
Error: Invalid value for '--prometheus-port': port \d+ already in use (re)
|
|
@@ -79,7 +79,8 @@ With custom ports
|
|
|
79
79
|
INFO stopping PostgreSQL 1\d\/main (re)
|
|
80
80
|
INFO stopping Prometheus postgres_exporter 1\d-main (re)
|
|
81
81
|
INFO deconfiguring Prometheus postgres_exporter 1\d-main (re)
|
|
82
|
-
INFO deleting PostgreSQL data
|
|
82
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/srv\/pgsql\/1\d\/main\/data (re)
|
|
83
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/srv\/pgsql\/1\d\/main\/wal (re)
|
|
83
84
|
|
|
84
85
|
With a port set in postgresql.conf template
|
|
85
86
|
|
|
@@ -99,13 +100,13 @@ With a port set in postgresql.conf template
|
|
|
99
100
|
INFO creating instance dumps directory: \$TMPDIR\/srv\/dumps\/1\d-main (re)
|
|
100
101
|
INFO starting Prometheus postgres_exporter 1\d-main (re)
|
|
101
102
|
$ pglift instance create other --prometheus-port=$PGE2PORT
|
|
102
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
103
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
103
104
|
Try 'pglift instance create --help' for help.
|
|
104
105
|
|
|
105
106
|
Error: Invalid value for '--port': port \d+ already in use (re)
|
|
106
107
|
[2]
|
|
107
108
|
$ pglift instance create other --port=$PG2PORT --prometheus-port=$PGE1PORT
|
|
108
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
109
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
109
110
|
Try 'pglift instance create --help' for help.
|
|
110
111
|
|
|
111
112
|
Error: Invalid value for '--prometheus-port': port \d+ already in use (re)
|
|
@@ -116,7 +117,8 @@ With a port set in postgresql.conf template
|
|
|
116
117
|
INFO stopping PostgreSQL 1\d\/main (re)
|
|
117
118
|
INFO stopping Prometheus postgres_exporter 1\d-main (re)
|
|
118
119
|
INFO deconfiguring Prometheus postgres_exporter 1\d-main (re)
|
|
119
|
-
INFO deleting PostgreSQL data
|
|
120
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/srv\/pgsql\/1\d\/main\/data (re)
|
|
121
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/srv\/pgsql\/1\d\/main\/wal (re)
|
|
120
122
|
$ rm -rf $PGLIFT_CONFIG_DIR/postgresql
|
|
121
123
|
|
|
122
124
|
With default ports
|
|
@@ -131,7 +133,7 @@ With default ports
|
|
|
131
133
|
INFO creating instance dumps directory: \$TMPDIR\/srv\/dumps\/1\d-main (re)
|
|
132
134
|
INFO starting Prometheus postgres_exporter 1\d-main (re)
|
|
133
135
|
$ pglift instance create other
|
|
134
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
136
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
135
137
|
Try 'pglift instance create --help' for help.
|
|
136
138
|
|
|
137
139
|
Error: Invalid value for '--port': port 5432 already in use
|
|
@@ -142,12 +144,13 @@ With default ports
|
|
|
142
144
|
INFO stopping PostgreSQL 1\d\/main (re)
|
|
143
145
|
INFO stopping Prometheus postgres_exporter 1\d-main (re)
|
|
144
146
|
INFO deconfiguring Prometheus postgres_exporter 1\d-main (re)
|
|
145
|
-
INFO deleting PostgreSQL data
|
|
147
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/srv\/pgsql\/1\d\/main\/data (re)
|
|
148
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/srv\/pgsql\/1\d\/main\/wal (re)
|
|
146
149
|
|
|
147
150
|
(cleanup)
|
|
148
|
-
INFO deleting pgBackRest include directory
|
|
151
|
+
INFO deleting pgBackRest include directory: $TMPDIR/etc/pgbackrest/conf.d
|
|
149
152
|
INFO uninstalling base pgBackRest configuration
|
|
150
|
-
INFO deleting pgBackRest log directory
|
|
151
|
-
INFO deleting pgBackRest spool directory
|
|
152
|
-
INFO deleting PostgreSQL log directory
|
|
153
|
-
INFO deleting PostgreSQL socket directory (no-eol)
|
|
153
|
+
INFO deleting pgBackRest log directory: $TMPDIR/log/pgbackrest
|
|
154
|
+
INFO deleting pgBackRest spool directory: $TMPDIR/srv/pgbackrest/spool
|
|
155
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/log/postgresql
|
|
156
|
+
INFO deleting PostgreSQL socket directory: $TMPDIR/run/postgresql (no-eol)
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
{
|
|
45
45
|
"before_header": "$TMPDIR/etc/prometheus/postgres_exporter-test.conf",
|
|
46
46
|
"after_header": "$TMPDIR/etc/prometheus/postgres_exporter-test.conf",
|
|
47
|
-
"before": "DATA_SOURCE_NAME=postgresql://:5432/monitoring\nPOSTGRES_EXPORTER_OPTS='--web.listen-address :* --log.level info'", (glob)
|
|
48
|
-
"after": "DATA_SOURCE_NAME=postgresql://prometheus@:5432/monitoring\nPOSTGRES_EXPORTER_OPTS='--web.listen-address :* --log.level info'" (glob)
|
|
47
|
+
"before": "DATA_SOURCE_NAME=postgresql://:5432/monitoring\nPOSTGRES_EXPORTER_OPTS='--web.listen-address :* --log.level info'\n", (glob)
|
|
48
|
+
"after": "DATA_SOURCE_NAME=postgresql://prometheus@:5432/monitoring\nPOSTGRES_EXPORTER_OPTS='--web.listen-address :* --log.level info'\n" (glob)
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"before_header": "$TMPDIR/run/prometheus/test.pid deleted",
|
|
@@ -100,4 +100,4 @@ Check port conflicts
|
|
|
100
100
|
INFO deconfiguring Prometheus postgres_exporter test
|
|
101
101
|
|
|
102
102
|
(cleanup)
|
|
103
|
-
INFO deleting PostgreSQL log directory (no-eol)
|
|
103
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/log/postgresql (no-eol)
|
|
@@ -60,7 +60,7 @@ Site settings and configuration
|
|
|
60
60
|
$ pglift1 site-configure install
|
|
61
61
|
INFO creating base pgBackRest configuration directory: $TMPDIR/1/etc/pgbackrest
|
|
62
62
|
INFO installing base pgBackRest configuration
|
|
63
|
-
INFO creating pgBackRest include directory
|
|
63
|
+
INFO creating pgBackRest include directory: $TMPDIR/1/etc/pgbackrest/conf.d
|
|
64
64
|
INFO creating pgBackRest repository backups and archive directory: $TMPDIR/test-standby-pgbackrest/backups
|
|
65
65
|
INFO creating pgBackRest log directory: $TMPDIR/1/log/pgbackrest
|
|
66
66
|
INFO creating pgBackRest spool directory: $TMPDIR/1/srv/pgbackrest/spool
|
|
@@ -68,7 +68,7 @@ Site settings and configuration
|
|
|
68
68
|
$ pglift2 site-configure install
|
|
69
69
|
INFO creating base pgBackRest configuration directory: $TMPDIR/2/etc/pgbackrest
|
|
70
70
|
INFO installing base pgBackRest configuration
|
|
71
|
-
INFO creating pgBackRest include directory
|
|
71
|
+
INFO creating pgBackRest include directory: $TMPDIR/2/etc/pgbackrest/conf.d
|
|
72
72
|
INFO creating pgBackRest log directory: $TMPDIR/2/log/pgbackrest
|
|
73
73
|
INFO creating pgBackRest spool directory: $TMPDIR/2/srv/pgbackrest/spool
|
|
74
74
|
INFO creating PostgreSQL log directory: $TMPDIR/2/log/postgresql
|
|
@@ -143,7 +143,7 @@ Cannot create a standby with --slot option
|
|
|
143
143
|
> --pgbackrest-stanza=stnz \
|
|
144
144
|
> --standby-for="host=hst" \
|
|
145
145
|
> --slot=slt
|
|
146
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
146
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
147
147
|
Try 'pglift instance create --help' for help.
|
|
148
148
|
|
|
149
149
|
Error: Invalid value for '--slot': replication slots cannot be set on a standby instance
|
|
@@ -184,7 +184,7 @@ Try to create primary instance with same stanza
|
|
|
184
184
|
$ pglift1 instance create err \
|
|
185
185
|
> --port=$PG3PORT --pgbackrest-stanza=app \
|
|
186
186
|
> --surole-password=s3per --pgbackrest-password=b@ckUp
|
|
187
|
-
Usage: pglift instance create [OPTIONS] NAME
|
|
187
|
+
Usage: pglift instance create [OPTIONS] [NAME]
|
|
188
188
|
Try 'pglift instance create --help' for help.
|
|
189
189
|
|
|
190
190
|
Error: Invalid value for '--pgbackrest-stanza': Stanza 'app' already bound to another instance \(datadir=\$TMPDIR\/1\/srv\/pgsql\/1\d\/pg1\/data\) (re)
|
|
@@ -301,7 +301,8 @@ new slot on the new primary
|
|
|
301
301
|
INFO dropping instance 1\d\/pg1 (re)
|
|
302
302
|
WARNING instance 1\d\/pg1 is already stopped (re)
|
|
303
303
|
INFO deconfiguring pgBackRest stanza 'app'
|
|
304
|
-
INFO deleting PostgreSQL data
|
|
304
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/1\/srv\/pgsql\/1\d\/pg1\/data (re)
|
|
305
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/1\/srv\/pgsql\/1\d\/pg1\/wal (re)
|
|
305
306
|
$ pglift1 instance create pg3 \
|
|
306
307
|
> --standby-for="host=$RUN_PREFIX2/postgresql port=$PG2PORT user=replication" \
|
|
307
308
|
> --standby-password=r3pl \
|
|
@@ -352,20 +353,22 @@ Restore on (new) primary:
|
|
|
352
353
|
INFO dropping instance 1\d\/pg3 (re)
|
|
353
354
|
INFO stopping PostgreSQL 1\d\/pg3 (re)
|
|
354
355
|
INFO deconfiguring pgBackRest stanza 'app'
|
|
355
|
-
INFO deleting PostgreSQL data
|
|
356
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/1\/srv\/pgsql\/1\d\/pg3\/data (re)
|
|
357
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/1\/srv\/pgsql\/1\d\/pg3\/wal (re)
|
|
356
358
|
INFO dropping instance 1\d\/pg2 (re)
|
|
357
359
|
WARNING instance 1\d\/pg2 is already stopped (re)
|
|
358
360
|
INFO deconfiguring pgBackRest stanza 'app'
|
|
359
|
-
INFO deleting PostgreSQL data
|
|
360
|
-
INFO deleting
|
|
361
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/2\/srv\/pgsql\/1\d\/pg2\/data (re)
|
|
362
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/2\/srv\/pgsql\/1\d\/pg2\/wal (re)
|
|
363
|
+
INFO deleting pgBackRest include directory: $TMPDIR/1/etc/pgbackrest/conf.d
|
|
361
364
|
INFO uninstalling base pgBackRest configuration
|
|
362
|
-
INFO deleting pgBackRest log directory
|
|
363
|
-
INFO deleting pgBackRest spool directory
|
|
364
|
-
INFO deleting PostgreSQL log directory
|
|
365
|
-
INFO deleting PostgreSQL socket directory
|
|
366
|
-
INFO deleting pgBackRest include directory
|
|
365
|
+
INFO deleting pgBackRest log directory: $TMPDIR/1/log/pgbackrest
|
|
366
|
+
INFO deleting pgBackRest spool directory: $TMPDIR/1/srv/pgbackrest/spool
|
|
367
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/1/log/postgresql
|
|
368
|
+
INFO deleting PostgreSQL socket directory: $TMPDIR/1/run/postgresql
|
|
369
|
+
INFO deleting pgBackRest include directory: $TMPDIR/2/etc/pgbackrest/conf.d
|
|
367
370
|
INFO uninstalling base pgBackRest configuration
|
|
368
|
-
INFO deleting pgBackRest log directory
|
|
369
|
-
INFO deleting pgBackRest spool directory
|
|
370
|
-
INFO deleting PostgreSQL log directory
|
|
371
|
-
INFO deleting PostgreSQL socket directory (no-eol)
|
|
371
|
+
INFO deleting pgBackRest log directory: $TMPDIR/2/log/pgbackrest
|
|
372
|
+
INFO deleting pgBackRest spool directory: $TMPDIR/2/srv/pgbackrest/spool
|
|
373
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/2/log/postgresql
|
|
374
|
+
INFO deleting PostgreSQL socket directory: $TMPDIR/2/run/postgresql (no-eol)
|
|
@@ -111,11 +111,13 @@ Try to pause/resume WAL replay on primary
|
|
|
111
111
|
|
|
112
112
|
INFO dropping instance 1\d\/pg1 (re)
|
|
113
113
|
INFO stopping PostgreSQL 1\d\/pg1 (re)
|
|
114
|
-
INFO deleting PostgreSQL data
|
|
114
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/primary\/srv\/pgsql\/1\d\/pg1\/data (re)
|
|
115
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/primary\/srv\/pgsql\/1\d\/pg1\/wal (re)
|
|
115
116
|
INFO dropping instance 1\d\/pg2 (re)
|
|
116
117
|
INFO stopping PostgreSQL 1\d\/pg2 (re)
|
|
117
|
-
INFO deleting PostgreSQL data
|
|
118
|
-
INFO deleting PostgreSQL
|
|
119
|
-
INFO deleting PostgreSQL
|
|
120
|
-
INFO deleting PostgreSQL
|
|
121
|
-
INFO deleting PostgreSQL
|
|
118
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/secondary\/srv\/pgsql\/1\d\/pg2\/data (re)
|
|
119
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/secondary\/srv\/pgsql\/1\d\/pg2\/wal (re)
|
|
120
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/primary/log/postgresql
|
|
121
|
+
INFO deleting PostgreSQL socket directory: $TMPDIR/primary/run/postgresql
|
|
122
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/secondary/log/postgresql
|
|
123
|
+
INFO deleting PostgreSQL socket directory: $TMPDIR/secondary/run/postgresql (no-eol)
|
|
@@ -41,7 +41,6 @@ Try to create an instance with a non-existing encoding, triggering a failure in
|
|
|
41
41
|
INFO initializing PostgreSQL
|
|
42
42
|
WARNING Command '['*/bin/pg_ctl', 'init', '-D', '$TMPDIR/srv/pgsql/test/data', '-o', '--auth-host=trust --auth-local=trust --encoding=notanencoding --locale=C --username=postgres --waldir=$TMPDIR/srv/pgsql/test/wal']' returned non-zero exit status 1. (glob)
|
|
43
43
|
WARNING reverting: initializing PostgreSQL
|
|
44
|
-
INFO deleting PostgreSQL data and WAL directories
|
|
45
44
|
Error: Command '['*/bin/pg_ctl', 'init', '-D', '$TMPDIR/srv/pgsql/test/data', '-o', '--auth-host=trust --auth-local=trust --encoding=notanencoding --locale=C --username=postgres --waldir=$TMPDIR/srv/pgsql/test/wal']' returned non-zero exit status 1. (glob)
|
|
46
45
|
initdb: error: "notanencoding" is not a valid server encoding name
|
|
47
46
|
pg_ctl: database system initialization failed
|
|
@@ -66,9 +66,11 @@ Create an instance with "password" local authentication method, and upgrade it:
|
|
|
66
66
|
(cleanup)
|
|
67
67
|
INFO dropping instance 1\d\/old (re)
|
|
68
68
|
WARNING instance 1\d\/old is already stopped (re)
|
|
69
|
-
INFO deleting PostgreSQL data
|
|
69
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/srv\/pgsql\/1\d\/old\/data (re)
|
|
70
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/srv\/pgsql\/1\d\/old\/wal (re)
|
|
70
71
|
INFO dropping instance 1\d\/new (re)
|
|
71
72
|
INFO stopping PostgreSQL 1\d\/new (re)
|
|
72
|
-
INFO deleting PostgreSQL data
|
|
73
|
-
INFO deleting PostgreSQL
|
|
74
|
-
INFO deleting PostgreSQL
|
|
73
|
+
INFO deleting PostgreSQL data directory: \$TMPDIR\/srv\/pgsql\/1\d\/new\/data (re)
|
|
74
|
+
INFO deleting PostgreSQL WAL directory: \$TMPDIR\/srv\/pgsql\/1\d\/new\/wal (re)
|
|
75
|
+
INFO deleting PostgreSQL log directory: $TMPDIR/log/postgresql
|
|
76
|
+
INFO deleting PostgreSQL socket directory: $TMPDIR/run/postgresql (no-eol)
|
|
@@ -115,7 +115,6 @@ def test_as_parameters(runner: CliRunner) -> None:
|
|
|
115
115
|
"--nickname=aaa",
|
|
116
116
|
"--phone-numbers=12345",
|
|
117
117
|
],
|
|
118
|
-
input="alc\nalc\n",
|
|
119
118
|
)
|
|
120
119
|
assert result.exit_code == 0, click_result_traceback(result)
|
|
121
120
|
assert json.loads(result.stderr) == {
|
|
@@ -363,3 +362,54 @@ def test_parse_params_as() -> None:
|
|
|
363
362
|
}
|
|
364
363
|
params_nested.update({f"address_{k}": v for k, v in address_params.items()})
|
|
365
364
|
assert model.parse_params_as(models.Person, params_nested) == person
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def test_as_parameters_unrequired_argument(runner: CliRunner) -> None:
|
|
368
|
+
@click.command("add-product")
|
|
369
|
+
@model.as_parameters(models.Product, "create")
|
|
370
|
+
@click.option("--indent", type=int)
|
|
371
|
+
def add_product(product: models.Product, indent: int) -> None:
|
|
372
|
+
"""Add a new product."""
|
|
373
|
+
click.echo(
|
|
374
|
+
product.model_dump_json(by_alias=True, indent=indent),
|
|
375
|
+
err=True,
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
result = runner.invoke(add_product, ["--help"])
|
|
379
|
+
assert result.exit_code == 0, click_result_traceback(result)
|
|
380
|
+
assert result.stdout == (
|
|
381
|
+
"Usage: add-product [OPTIONS] [NAME]\n"
|
|
382
|
+
"\n"
|
|
383
|
+
" Add a new product.\n"
|
|
384
|
+
"\n"
|
|
385
|
+
"Options:\n"
|
|
386
|
+
" --price TEXT Price. [required]\n"
|
|
387
|
+
" --description DESCRIPTION Description for the product.\n"
|
|
388
|
+
" --indent INTEGER\n"
|
|
389
|
+
" --help Show this message and exit.\n"
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
result = runner.invoke(
|
|
393
|
+
add_product,
|
|
394
|
+
[
|
|
395
|
+
"--price=19.5",
|
|
396
|
+
"--description=useless stuff",
|
|
397
|
+
],
|
|
398
|
+
)
|
|
399
|
+
assert result.exit_code == 0, click_result_traceback(result)
|
|
400
|
+
assert json.loads(result.stderr) == {
|
|
401
|
+
"description": "useless stuff",
|
|
402
|
+
"name": "Unnamed product",
|
|
403
|
+
"price": 19.5,
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
result = runner.invoke(
|
|
407
|
+
add_product,
|
|
408
|
+
["--price=19.5", "--description=useless stuff", "The Product Name"],
|
|
409
|
+
)
|
|
410
|
+
assert result.exit_code == 0, click_result_traceback(result)
|
|
411
|
+
assert json.loads(result.stderr) == {
|
|
412
|
+
"description": "useless stuff",
|
|
413
|
+
"name": "The Product Name",
|
|
414
|
+
"price": 19.5,
|
|
415
|
+
}
|
|
@@ -367,6 +367,6 @@ def test_get_instance(
|
|
|
367
367
|
):
|
|
368
368
|
util.get_instance("foo", None, settings)
|
|
369
369
|
assert [call.args for call in system_lookup.call_args_list] == [
|
|
370
|
-
("foo", "
|
|
371
|
-
("foo", "
|
|
370
|
+
("foo", "15", settings),
|
|
371
|
+
("foo", "18", settings),
|
|
372
372
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|