How do I bootstrap a smoke-test system?

Table of Contents

The lightweight smoke that predates the provision porcelain: it exercises multi-tenant behaviour with raw tenants add / account_operations save-account commands rather than the wizards. The ores-shell block is tangled into the runnable library as bootstrap_smoke.ores.

1. Question

How do I bootstrap a minimal multi-tenant system from the shell for a smoke test?

2. Answer

Create the initial super_admin, two tenants (acme and example), one account in each, and print the role-grant commands each account needs. An error-free run leaves a system two admins can log into.

Expectations: services up, and a database that has not been bootstrapped yet. connect takes the endpoint from $ORES_NATS_URL.

2.1. Running it a second time

The recipe is not repeatable, and it cannot be made so from inside a recipe. Three of its steps refuse a system that already holds what they create: bootstrap create-initial-admin refuses a second initial administrator, and each tenants add and account_operations save-account refuses a code or a username it already holds. A shell recipe has no conditional and no way to tolerate one command's failure, so no recipe can ask whether a row is already there before creating it or carry on past the refusal.

To run it again, reset the system first, which is destructive and returns the database to the state this recipe expects:

reset reset-system

A recipe that needs a conditional is a gap in the script language rather than in this document; the tolerance a caller might reach for, --continue-on-error, is a flag the argument parser knows and the script runner never reads.

connect $ORES_NATS_URL

bootstrap create-initial-admin super_admin Secure-Password-123 super_admin@localhost.com
accounts login super_admin Secure-Password-123

tenants add acme "Acme Corp" evaluation "Acme Corporation tenant" acme.com active false system.new_record "Smoke test tenant"

account_operations save-account newuser61@acme.com Secure-Password-123 567 newuser61@acme.com user
tenants add example "Example Corp" evaluation "Example Corporation tenant" example.com active false system.new_record "Smoke test tenant"
account_operations save-account newuser60@example.com Secure-Password-123 567 newuser60@example.com user

permissions suggest newuser60 example.com
permissions suggest newuser61 acme.com

exit
./ores.shell ${log_args} ${connect_args} << 'EOF'
<<bootstrap-smoke>>
EOF

3. Script

projects/ores.shell/scripts/library/provisioning/bootstrap_smoke.ores — generated from this recipe by compass build --direct tangle_shell_scripts (do not edit the .ores by hand).

4. Tested by

Manual: compass shell -f bootstrap_smoke.ores against a freshly recreated database.

5. See also

Emacs 29.3 (Org mode 9.6.15)