{code:shell}ext/bin/pdb-dataset import --timeshift-to now DUMPFILE {code} which would: * Refuse to run if it detects that the postgres associated with the PDBBOX already has a puppetdb database (perhaps just by checking via psql if the migrations table exists, for example). (In the longer run, we might add a {{\-\-force}} option to allow clobbering.) * Run a {{pgrestore}} of the {{pgdump}} {{DUMPFILE}}. (We might eventually support a {{--format}} option to allow other kinds of import, e.g. {{\-\-format pgdump}} {{\-\-format basebackup}} ...) * Time shift the database as indicated here: [slv-setup|https://github.com/puppetlabs/gatling-puppet-load-test/blob/master/docs/load_save_dbs.md]. The {{\-\-timeshift}} argument could eventually be optional (i.e. to support not timeshifting), but it's fine for it to be required for now. (The argument in favor of {{\-\-timeshift-to now}} instead of a boolean argument is that we may want to support other time shifting strategies in the future, and/or different offsets.) * Run a {{vacuum full}}. Later, we might want to support inverse {{\-\-vacuum}} and {{--no-vacuum}} options, but for now it's fine to just unconditionally vacuum.
We might also consider putting the timeshift script (if it ends up being in a standalone .sql file), in resources/ somewhere, say {{resources/puppetlabs/puppetdb/timeshift.sql}} or something, which means it'll end up in the jar, which shouldn't hurt, and might be handy someday.
If we want a "top level" test for this, could model it after those run by ext/bin/run-external-tests and add it there.
And if the top level command ends up being a shell script, there's plenty of prior "art" in {{ext/bin}} that might or might not be helpful. |
|
|