An interrupted test run leaves its roles in the shared test cluster, and test/reset-test-db.sh drops none #266

Open
opened 2026-10-24 06:52:46 +00:00 by cgalo5758 · 0 comments
Owner

What a contributor runs into

Roles belong to the cluster, not to one database, and a test whose subject is a login or a role owner has to commit the role outside its transaction. These tests do, and drop the role in a t.Cleanup:

  • newBootBox and bootBox.thirdRole in cmd/database_db_test.go (logins named mc_rt_ plus a number, with a password from the test source, and roles named mc_third_ plus a number);
  • committedRole and committedRoleNamed in internal/db/runtime_user_test.go (mc_owner_ and Mc-Owner- names);
  • poolTestRole in internal/db/migration_pool_test.go (mc_pool_role_ names).

A run that is interrupted (Ctrl-C, a -timeout panic, a killed or crashed test binary) runs no cleanup, so those roles stay. test/reset-test-db.sh, which make test runs first, drops and recreates the two test databases and drops no role, so leftovers accumulate from run to run. Scratch databases from dbtest.Scratch (mc_scratch_ names) are left the same way, and a leftover role that owns one cannot be dropped until the database is.

Role memberships are cluster-wide as well. bootClosesASetRoleChain (cmd/database_db_test.go) grants a committed test role to console_runtime with SET TRUE; a run interrupted before the boot under test revokes it leaves console_runtime holding that role in every database of the cluster, the test databases included.

Why it costs

Leftover roles and databases pile up in a contributor's stack until someone finds and drops them by hand, a leftover login keeps a password that is in the repository, and a leftover membership changes what console_runtime reaches in the next run's tests.

Where

test/reset-test-db.sh

Done when

  • The reset that make test runs first drops every role and scratch database an earlier run left behind, recognised by the name prefixes the tests give them, and the memberships those roles held go with them.
  • Every test that commits a role names it with one of those prefixes.
### What a contributor runs into Roles belong to the cluster, not to one database, and a test whose subject is a login or a role owner has to commit the role outside its transaction. These tests do, and drop the role in a `t.Cleanup`: - `newBootBox` and `bootBox.thirdRole` in `cmd/database_db_test.go` (logins named `mc_rt_` plus a number, with a password from the test source, and roles named `mc_third_` plus a number); - `committedRole` and `committedRoleNamed` in `internal/db/runtime_user_test.go` (`mc_owner_` and `Mc-Owner-` names); - `poolTestRole` in `internal/db/migration_pool_test.go` (`mc_pool_role_` names). A run that is interrupted (Ctrl-C, a `-timeout` panic, a killed or crashed test binary) runs no cleanup, so those roles stay. `test/reset-test-db.sh`, which `make test` runs first, drops and recreates the two test databases and drops no role, so leftovers accumulate from run to run. Scratch databases from `dbtest.Scratch` (`mc_scratch_` names) are left the same way, and a leftover role that owns one cannot be dropped until the database is. Role memberships are cluster-wide as well. `bootClosesASetRoleChain` (`cmd/database_db_test.go`) grants a committed test role to `console_runtime` with `SET TRUE`; a run interrupted before the boot under test revokes it leaves `console_runtime` holding that role in every database of the cluster, the test databases included. ### Why it costs Leftover roles and databases pile up in a contributor's stack until someone finds and drops them by hand, a leftover login keeps a password that is in the repository, and a leftover membership changes what `console_runtime` reaches in the next run's tests. ### Where `test/reset-test-db.sh` ### Done when - The reset that `make test` runs first drops every role and scratch database an earlier run left behind, recognised by the name prefixes the tests give them, and the memberships those roles held go with them. - Every test that commits a role names it with one of those prefixes.
cgalo5758 added the
kind
debt
area/testing
priority
low
labels 2026-10-24 06:52:46 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wiki-cafe/member-console#266