Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status: fix TestTenantStatusAPI test #126498

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions pkg/ccl/serverccl/statusccl/tenant_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,16 @@ func selectClusterSessionIDs(t *testing.T, conn *sqlutils.SQLRunner) []string {

func testTenantStatusCancelSession(t *testing.T, helper serverccl.TenantTestHelper) {
// Open a SQL session on tenant SQL pod 0.
sqlPod0 := helper.TestCluster().TenantConn(0)
sqlPod0.Exec(t, "SELECT 1")
ctx := context.Background()
// Open two different SQL sessions on tenant SQL pod 0.
sqlPod0 := helper.TestCluster().TenantDB(0)
sqlPod0SessionToCancel, err := sqlPod0.Conn(ctx)
require.NoError(t, err)
sqlPod0SessionForIntrospection, err := sqlPod0.Conn(ctx)
require.NoError(t, err)
_, err = sqlPod0SessionToCancel.ExecContext(ctx, "SELECT 1")
require.NoError(t, err)
introspectionRunner := sqlutils.MakeSQLRunner(sqlPod0SessionForIntrospection)

// See the session over HTTP on tenant SQL pod 1.
httpPod1 := helper.TestCluster().TenantAdminHTTPClient(t, 1)
Expand All @@ -1122,7 +1130,7 @@ func testTenantStatusCancelSession(t *testing.T, helper serverccl.TenantTestHelp
// See the session over SQL on tenant SQL pod 0.
sessionID := hex.EncodeToString(session.ID)
require.Eventually(t, func() bool {
return strings.Contains(strings.Join(selectClusterSessionIDs(t, sqlPod0), ","), sessionID)
return strings.Contains(strings.Join(selectClusterSessionIDs(t, introspectionRunner), ","), sessionID)
}, 5*time.Second, 100*time.Millisecond)

// Cancel the session over HTTP from tenant SQL pod 1.
Expand All @@ -1134,7 +1142,7 @@ func testTenantStatusCancelSession(t *testing.T, helper serverccl.TenantTestHelp
// No longer see the session over SQL from tenant SQL pod 0.
// (The SQL client maintains an internal connection pool and automatically reconnects.)
require.Eventually(t, func() bool {
return !strings.Contains(strings.Join(selectClusterSessionIDs(t, sqlPod0), ","), sessionID)
return !strings.Contains(strings.Join(selectClusterSessionIDs(t, introspectionRunner), ","), sessionID)
}, 5*time.Second, 100*time.Millisecond)

// Attempt to cancel the session again over HTTP from tenant SQL pod 1, so that we can see the error message.
Expand Down
Loading