Skip to content

Consolidate test server configuration into InitTestServerFactory #158004

@Nukitt

Description

@Nukitt

Currently, test packages configure global tenant options and DRPC using deferred cleanup functions in TestMain:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-db-server

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions