Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
135319: pkg/ccl/testccl/sqlccl/sqlccl_test: TestShowTransferState flake fix r=Dedej-Bergin a=Dedej-Bergin

This used to happen later in the test.
These code changes make it happen earlier.
```
	testutils.SucceedsSoon(t, func() error {
		// Waiting for the cluster setting to propagate to the tenant.
		var enabled bool
		if err := tenantDB.QueryRow(
			`SHOW CLUSTER SETTING server.user_login.session_revival_token.enabled`,
		).Scan(&enabled); err != nil {
			return err
		}
		if !enabled {
			return errors.New("cluster setting not yet propagated")
		}
		return nil
	})
```

Having these code changes later would case a flake.

Fixes: cockroachdb#133403
Release note: None

Co-authored-by: Bergin Dedej <[email protected]>
  • Loading branch information
craig[bot] and Dedej-Bergin committed Nov 15, 2024
2 parents b5c6f23 + f055c80 commit f0b4601
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions pkg/ccl/testccl/sqlccl/show_transfer_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ func TestShowTransferState(t *testing.T) {
_, err = tenantDB.Exec("GRANT SELECT ON tab TO testuser")
require.NoError(t, err)

testutils.SucceedsSoon(t, func() error {
// Waiting for the cluster setting to propagate to the tenant.
var enabled bool
if err := tenantDB.QueryRow(
`SHOW CLUSTER SETTING server.user_login.session_revival_token.enabled`,
).Scan(&enabled); err != nil {
return err
}
if !enabled {
return errors.New("cluster setting not yet propagated")
}
return nil
})

testUserConn := tenant.SQLConn(t, serverutils.User(username.TestUser))

t.Run("without_transfer_key", func(t *testing.T) {
Expand Down Expand Up @@ -211,19 +225,7 @@ func TestShowTransferState(t *testing.T) {
t.Run("root_user", func(t *testing.T) {
var key string
var errVal, sessionState, sessionRevivalToken gosql.NullString
testutils.SucceedsSoon(t, func() error {
// Waiting for the cluster setting to propagate to the tenant.
var enabled bool
if err := tenantDB.QueryRow(
`SHOW CLUSTER SETTING server.user_login.session_revival_token.enabled`,
).Scan(&enabled); err != nil {
return err
}
if !enabled {
return errors.New("cluster setting not yet propagated")
}
return nil
})

err := tenantDB.QueryRow(`SHOW TRANSFER STATE WITH 'bar'`).Scan(&errVal, &sessionState, &sessionRevivalToken, &key)
require.NoError(t, err)
require.True(t, errVal.Valid)
Expand Down

0 comments on commit f0b4601

Please sign in to comment.