Skip to content

Commit

Permalink
server: make tenant tests faster
Browse files Browse the repository at this point in the history
This ensures that `WaitForTenantReadiness` doesn't have to wait for
the full closed timestamp interval.

Release note: None
  • Loading branch information
knz committed Jul 25, 2023
1 parent 9829038 commit 8ebfacd
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -952,11 +952,6 @@ func (ts *TestServer) StartSharedProcessTenant(
}
}

// Wait for the rangefeed to catch up.
if err := ts.WaitForTenantReadiness(ctx, tenantID); err != nil {
return nil, nil, err
}

if justCreated {
// Also mark it for shared-process execution.
_, err := ts.InternalExecutor().(*sql.InternalExecutor).ExecEx(
Expand All @@ -972,6 +967,11 @@ func (ts *TestServer) StartSharedProcessTenant(
}
}

// Wait for the rangefeed to catch up.
if err := ts.WaitForTenantReadiness(ctx, tenantID); err != nil {
return nil, nil, err
}

// Instantiate the tenant server.
s, err := ts.Server.serverController.startAndWaitForRunningServer(ctx, args.TenantName)
if err != nil {
Expand Down Expand Up @@ -1020,6 +1020,11 @@ func (t *TestTenant) HTTPAuthServer() interface{} {

// WaitForTenantReadiness is part of TestServerInterface.
func (ts *TestServer) WaitForTenantReadiness(ctx context.Context, tenantID roachpb.TenantID) error {
// Restarting the watcher forces a new initial scan which is
// faster than waiting out the closed timestamp interval
// required to see new updates.
ts.node.tenantInfoWatcher.TestingRestart()

log.Infof(ctx, "waiting for rangefeed to catch up with record for tenant %v", tenantID)
_, infoWatcher, err := ts.node.waitForTenantWatcherReadiness(ctx)
if err != nil {
Expand Down Expand Up @@ -1220,10 +1225,9 @@ func (ts *TestServer) StartTenant(
return nil, err
}
} else {
// Restart the capabilities watcher. Restarting the
// watcher forces a new initial scan which is faster
// than waiting out the closed timestamp interval
// required to see new updates.
// Restart the capabilities watcher. Restarting the watcher
// forces a new initial scan which is faster than waiting out
// the closed timestamp interval required to see new updates.
ts.tenantCapabilitiesWatcher.TestingRestart()
if err := testutils.SucceedsSoonError(func() error {
capabilities, found := ts.TenantCapabilitiesReader().GetCapabilities(params.TenantID)
Expand Down

0 comments on commit 8ebfacd

Please sign in to comment.