Skip to content

Commit 986afa0

Browse files
craig[bot]dhartunianAndrew Baptist
committed
118681: oidc: init in test after all settings are set r=maryliag a=dhartunian We've had some intermittent failures with OIDC tests that look like the configuration change in the final setting has not been propagated through to the config. This test modifies the configuration to be enabled at the end of the cluster setting changes to reduce the chance of this happening. Resolves: #118568 Resolves: #115908 Epic: None Release note: None 118829: kvclient: simplify test r=arulajmani a=andrewbaptist The test was previously using the index and getting the node id from that. This approach made it hard to avoid off-by-one errors. Using the node id directly makes the test easier to read. Epic: none Release note: None Co-authored-by: David Hartunian <[email protected]> Co-authored-by: Andrew Baptist <[email protected]>
3 parents ef369f2 + cad0fb7 + 572300e commit 986afa0

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

pkg/ccl/oidcccl/authentication_oidc_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ func TestOIDCEnabled(t *testing.T) {
129129
sqlDB.Exec(t, `SET CLUSTER SETTING server.oidc_authentication.redirect_url = "https://cockroachlabs.com/oidc/v1/callback"`)
130130
sqlDB.Exec(t, `set cluster setting server.oidc_authentication.claim_json_key = "email"`)
131131
sqlDB.Exec(t, `set cluster setting server.oidc_authentication.principal_regex = '^([^@]+)@[^@]+$'`)
132-
sqlDB.Exec(t, `SET CLUSTER SETTING server.oidc_authentication.enabled = "true"`)
133132
sqlDB.Exec(t, fmt.Sprintf(`SET CLUSTER SETTING server.http.base_path = "%s"`, basePath))
133+
sqlDB.Exec(t, `SET CLUSTER SETTING server.oidc_authentication.enabled = "true"`)
134134

135135
testCertsContext := s.NewClientRPCContext(ctx, username.TestUserName())
136136
client, err := testCertsContext.GetHTTPClient()
@@ -203,7 +203,7 @@ func TestOIDCEnabled(t *testing.T) {
203203
t.Fatalf("expected 307 status code but got: %d", resp.StatusCode)
204204
}
205205
if resp.Header.Get("Location") != basePath {
206-
t.Fatalf("expected to be redirected to root")
206+
t.Fatalf("expected to be redirected to %s", basePath)
207207
}
208208
foundCookie := false
209209
for _, c := range resp.Cookies() {

pkg/kv/kvclient/kvcoord/dist_sender_ambiguous_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
361361
Insecure: true,
362362
Knobs: base.TestingKnobs{
363363
KVClient: &kvcoord.ClientTestingKnobs{
364-
TransportFactory: getInterceptingTransportFactory(roachpb.NodeID(1)),
364+
TransportFactory: getInterceptingTransportFactory(1),
365365
},
366366
Store: &kvserver.StoreTestingKnobs{
367367
EvalKnobs: kvserverbase.BatchEvalTestingKnobs{
@@ -517,7 +517,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
517517
execLeaseMover := func(t *testing.T, name string) error {
518518
desc, err := tc.LookupRange(keyB)
519519
assert.NoError(t, err)
520-
t.Logf("Transferring r%d lease to n%d", desc.RangeID, tc.Target(0).NodeID)
520+
t.Logf("Transferring r%d lease to n%d", desc.RangeID, 1)
521521
assert.NoError(t, tc.TransferRangeLease(desc, tc.Target(0)))
522522
return nil
523523
}
@@ -585,7 +585,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
585585
// 3. txn1->n1: Put(a), EndTxn(parallel commit) -- Puts txn1 in STAGING.
586586
// 4. txn1->n2: Put(b) -- Send the request, but pause before returning
587587
// the response so we can inject network failure.
588-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
588+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
589589
// Once we have seen the write on txn1 to n2 that we will fail, txn2
590590
// can start.
591591
close(txn2Ready)
@@ -607,7 +607,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
607607
// <transfer b's lease to n1>
608608
// <inject a network failure and finally allow (4) txn1->n2: Put(b) to
609609
// return with error>
610-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
610+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
611611
// Hold the operation open until we are ready to retry on the new
612612
// replica, after which we will return the injected failure.
613613
req.pauseUntil(t, leaseMoveComplete, cp)
@@ -774,7 +774,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
774774
// 3. txn1->n1: Put(a), EndTxn(parallel commit) -- Puts txn1 in STAGING.
775775
// 4. txn1->n2: Put(b) -- Send the request, but pause before returning
776776
// the response so we can inject network failure.
777-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
777+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
778778
// Once we have seen the write on txn1 to n2 that we will fail, txn2
779779
// can start.
780780
close(txn2Ready)
@@ -796,7 +796,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
796796
// <transfer b's lease to n1>
797797
// <inject a network failure and finally allow (4) txn1->n2: Put(b) to
798798
// return with error>
799-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
799+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
800800
// Hold the operation open until we are ready to retry on the new
801801
// replica, after which we will return the injected failure.
802802
req.pauseUntil(t, leaseMoveComplete, cp)
@@ -937,7 +937,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
937937
// 3. txn1->n1: Put(a), EndTxn(parallel commit) -- Puts txn1 in STAGING.
938938
// 4. txn1->n2: Put(b) -- Send the request, but pause before returning
939939
// the response so we can inject network failure.
940-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
940+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
941941
// Once we have seen the write on txn1 to n2 that we will fail, we can
942942
// move the lease.
943943
close(txn2Ready)
@@ -958,7 +958,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
958958
// <transfer b's lease to n1>
959959
// <inject a network failure and finally allow (4) txn1->n2: Put(b) to
960960
// return with error>
961-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
961+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
962962
// Hold the operation open until we are ready to retry on the new
963963
// replica, after which we will return the injected failure.
964964
req.pauseUntil(t, leaseMoveComplete, cp)
@@ -1073,7 +1073,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
10731073
// 3. txn1->n1: Put(a), EndTxn(parallel commit) -- Puts txn1 in STAGING.
10741074
// 4. txn1->n2: Put(b) -- Send the request, but pause before returning the
10751075
// response so we can inject network failure.
1076-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
1076+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
10771077
// Once we have seen the write on txn1 to n2 that we will fail, txn2/txn3 can start.
10781078
close(otherTxnsReady)
10791079
}
@@ -1095,7 +1095,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
10951095
// <transfer b's lease to n1>
10961096
// <inject a network failure and finally allow (4) txn1->n2: Put(b) to
10971097
// return with error>
1098-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
1098+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
10991099
// Hold the operation open until we are ready to retry on the new
11001100
// replica, after which we will return the injected failure.
11011101
req.pauseUntil(t, leaseMoveComplete, cp)
@@ -1192,7 +1192,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
11921192
// 4. txn1->n2: Put(b) -- Send the request, but pause before returning the
11931193
// response so we can inject network failure.
11941194
// <transfer b's lease to n1>
1195-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
1195+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
11961196
close(leaseMoveReady)
11971197
req.pauseUntil(t, leaseMoveComplete, cp)
11981198
close(txn2Ready)
@@ -1210,7 +1210,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
12101210

12111211
// <inject a network failure and finally allow (4) txn1->n2: Put(b) to
12121212
// return with error>
1213-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
1213+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
12141214
// Hold the operation open until we are ready to retry on the new
12151215
// replica, after which we will return the injected failure.
12161216
req.pauseUntil(t, recoverComplete, cp)
@@ -1295,7 +1295,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
12951295
// 4. txn1->n2: Put(b) -- Send the request, but pause before returning the
12961296
// response so we can inject network failure.
12971297
// <transfer b's lease to n1>
1298-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
1298+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
12991299
close(leaseMoveReady)
13001300
req.pauseUntil(t, leaseMoveComplete, cp)
13011301
close(txn2Ready)
@@ -1317,7 +1317,7 @@ func TestTransactionUnexpectedlyCommitted(t *testing.T) {
13171317

13181318
// <inject a network failure and finally allow (4) txn1->n2: Put(b) to
13191319
// return with error>
1320-
if req.txnName == "txn1" && hasPut && req.toNodeID == tc.Server(1).NodeID() && cp == AfterSending {
1320+
if req.txnName == "txn1" && hasPut && req.toNodeID == 2 && cp == AfterSending {
13211321
// Hold the operation open until we are ready to retry on the new
13221322
// replica, after which we will return the injected failure.
13231323
req.pauseUntil(t, txn2ETReady, cp)

0 commit comments

Comments
 (0)