-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Currently, test packages configure global tenant options and DRPC using deferred cleanup functions in TestMain:
cockroach/pkg/server/main_test.go
Lines 28 to 36 in a325c69
| defer serverutils.TestingSetDefaultTenantSelectionOverride( | |
| base.TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet(156304), | |
| )() | |
| defer serverutils.TestingGlobalDRPCOption( | |
| base.TestDRPCEnabledRandomly, | |
| )() | |
This ticket comes up after the discussions in this PR to enable DRPC for sql tests where it was concluded that there is not much value in actually performing the cleanup function to reset the global state option in a defer, since the test process exits immediately after finishing the tests.
A proposed solution for this was to modify serverutils.InitTestServerFactory to accept optional configuration parameters, and then set the override option through it. It can look something like:
func InitTestServerFactory(
impl TestServerFactory,
opts ...interface{}, // Can have base.DefaultTestDRPCOption or base.DefaultTestTenantOptions or both
) and its usage could look something like:
serverutils.InitTestServerFactory(
server.TestServerFactory,
base.TestDRPCEnabledRandomly,
base.TestTenantProbabilisticOnly,
)This should maintain backward compatibility for existing tests, while we migrate the packages to have the above usage for overriding. Also, it would make modification clearer such that only packages that actually instantiate test servers (via InitTestServerFactory) will configure the DRPC/tenant behaviour.
Epic: None
Jira issue: CRDB-57059