diff --git a/tests/integration/clientv3/connectivity/network_partition_test.go b/tests/integration/clientv3/connectivity/network_partition_test.go index b46804d3a8e..cb421a84e4b 100644 --- a/tests/integration/clientv3/connectivity/network_partition_test.go +++ b/tests/integration/clientv3/connectivity/network_partition_test.go @@ -145,7 +145,7 @@ func testBalancerUnderNetworkPartition(t *testing.T, op func(*clientv3.Client, c if err == nil { break } - if err != errExpected { + if !errors.Is(err, errExpected) { t.Errorf("#%d: expected '%v', got '%v'", i, errExpected, err) } // give enough time for endpoint switch diff --git a/tests/integration/clientv3/experimental/recipes/v3_double_barrier_test.go b/tests/integration/clientv3/experimental/recipes/v3_double_barrier_test.go index 120e4bed8af..f4fbfcb2457 100644 --- a/tests/integration/clientv3/experimental/recipes/v3_double_barrier_test.go +++ b/tests/integration/clientv3/experimental/recipes/v3_double_barrier_test.go @@ -16,6 +16,7 @@ package recipes_test import ( "context" + "errors" "sync" "testing" "time" @@ -149,7 +150,7 @@ func TestDoubleBarrierTooManyClients(t *testing.T) { // no any other client can enter the barrier. wgEntered.Wait() t.Log("Try to enter into double barrier") - if err = b.Enter(); err != recipe.ErrTooManyClients { + if err = b.Enter(); !errors.Is(err, recipe.ErrTooManyClients) { t.Errorf("Unexcepted error, expected: ErrTooManyClients, got: %v", err) } diff --git a/tests/integration/clientv3/lease/leasing_test.go b/tests/integration/clientv3/lease/leasing_test.go index 2164e8f5b18..40113d0aa13 100644 --- a/tests/integration/clientv3/lease/leasing_test.go +++ b/tests/integration/clientv3/lease/leasing_test.go @@ -16,6 +16,7 @@ package lease_test import ( "context" + "errors" "fmt" "math/rand" "reflect" @@ -895,7 +896,7 @@ func TestLeasingTxnCancel(t *testing.T) { time.Sleep(100 * time.Millisecond) cancel() }() - if _, err := lkv2.Txn(ctx).Then(clientv3.OpPut("k", "v")).Commit(); err != context.Canceled { + if _, err := lkv2.Txn(ctx).Then(clientv3.OpPut("k", "v")).Commit(); !errors.Is(err, context.Canceled) { t.Fatalf("expected %v, got %v", context.Canceled, err) } } @@ -2017,7 +2018,7 @@ func TestLeasingSessionExpireCancel(t *testing.T) { select { case err := <-errc: - if err != ctx.Err() { + if !errors.Is(err, ctx.Err()) { t.Errorf("#%d: expected %v of server unavailable, got %v", i, ctx.Err(), err) } case <-time.After(5 * time.Second): @@ -2048,7 +2049,7 @@ func waitForExpireAck(t *testing.T, kv clientv3.KV) { ctx, cancel := context.WithTimeout(context.TODO(), time.Second) _, err := kv.Get(ctx, "abc") cancel() - if err == ctx.Err() { + if errors.Is(err, ctx.Err()) { return } else if err != nil { t.Logf("current error: %v", err) diff --git a/tests/integration/clientv3/maintenance_test.go b/tests/integration/clientv3/maintenance_test.go index 475fc9e18bd..3de3d389cff 100644 --- a/tests/integration/clientv3/maintenance_test.go +++ b/tests/integration/clientv3/maintenance_test.go @@ -187,7 +187,7 @@ func TestMaintenanceSnapshotCancel(t *testing.T) { cancel() _, err = io.Copy(io.Discard, rc1) - if err != context.Canceled { + if !errors.Is(err, context.Canceled) { t.Errorf("expected %v, got %v", context.Canceled, err) } } diff --git a/tests/integration/clientv3/ordering_kv_test.go b/tests/integration/clientv3/ordering_kv_test.go index c539199ff6a..1d667b44dac 100644 --- a/tests/integration/clientv3/ordering_kv_test.go +++ b/tests/integration/clientv3/ordering_kv_test.go @@ -89,7 +89,7 @@ func TestDetectKvOrderViolation(t *testing.T) { t.Logf("Quering m2 after restart") v, err = orderingKv.Get(ctx, "foo", clientv3.WithSerializable()) t.Logf("Quering m2 returned: v:%v err:%v ", v, err) - if err != errOrderViolation { + if !errors.Is(err, errOrderViolation) { t.Fatalf("expected %v, got err:%v v:%v", errOrderViolation, err, v) } } @@ -155,7 +155,7 @@ func TestDetectTxnOrderViolation(t *testing.T) { cli.SetEndpoints(clus.Members[2].GRPCURL) time.Sleep(2 * time.Second) // FIXME: Figure out how pause SetEndpoints sufficiently that this is not needed _, err = orderingKv.Get(ctx, "foo", clientv3.WithSerializable()) - if err != errOrderViolation { + if !errors.Is(err, errOrderViolation) { t.Fatalf("expected %v, got %v", errOrderViolation, err) } orderingTxn = orderingKv.Txn(ctx) @@ -164,7 +164,7 @@ func TestDetectTxnOrderViolation(t *testing.T) { ).Then( clientv3.OpGet("foo", clientv3.WithSerializable()), ).Commit() - if err != errOrderViolation { + if !errors.Is(err, errOrderViolation) { t.Fatalf("expected %v, got %v", errOrderViolation, err) } } diff --git a/tests/integration/clientv3/ordering_util_test.go b/tests/integration/clientv3/ordering_util_test.go index ebac39981a9..6313957bf3f 100644 --- a/tests/integration/clientv3/ordering_util_test.go +++ b/tests/integration/clientv3/ordering_util_test.go @@ -16,6 +16,7 @@ package clientv3test import ( "context" + "errors" "testing" "time" @@ -78,7 +79,7 @@ func TestEndpointSwitchResolvesViolation(t *testing.T) { cli.SetEndpoints(clus.Members[2].GRPCURL) time.Sleep(1 * time.Second) // give enough time for the operation _, err = orderingKv.Get(ctx, "foo", clientv3.WithSerializable()) - if err != ordering.ErrNoGreaterRev { + if !errors.Is(err, ordering.ErrNoGreaterRev) { t.Fatal("While speaking to partitioned leader, we should get ErrNoGreaterRev error") } @@ -156,7 +157,7 @@ func TestUnresolvableOrderViolation(t *testing.T) { time.Sleep(1 * time.Second) // give enough time for operation _, err = OrderingKv.Get(ctx, "foo", clientv3.WithSerializable()) - if err != ordering.ErrNoGreaterRev { + if !errors.Is(err, ordering.ErrNoGreaterRev) { t.Fatalf("expected %v, got %v", ordering.ErrNoGreaterRev, err) } } diff --git a/tests/integration/clientv3/txn_test.go b/tests/integration/clientv3/txn_test.go index d1517bda493..221247d2f7a 100644 --- a/tests/integration/clientv3/txn_test.go +++ b/tests/integration/clientv3/txn_test.go @@ -46,7 +46,7 @@ func TestTxnError(t *testing.T) { ops[i] = clientv3.OpPut(fmt.Sprintf("foo%d", i), "") } _, err = kv.Txn(ctx).Then(ops...).Commit() - if err != rpctypes.ErrTooManyOps { + if !errors.Is(err, rpctypes.ErrTooManyOps) { t.Fatalf("expected %v, got %v", rpctypes.ErrTooManyOps, err) } } diff --git a/tests/integration/clientv3/user_test.go b/tests/integration/clientv3/user_test.go index c0126915d49..7ed13e7ed44 100644 --- a/tests/integration/clientv3/user_test.go +++ b/tests/integration/clientv3/user_test.go @@ -117,7 +117,7 @@ func TestUserErrorAuth(t *testing.T) { authSetupRoot(t, authapi.Auth) // unauthenticated client - if _, err := authapi.UserAdd(context.TODO(), "foo", "bar"); err != rpctypes.ErrUserEmpty { + if _, err := authapi.UserAdd(context.TODO(), "foo", "bar"); !errors.Is(err, rpctypes.ErrUserEmpty) { t.Fatalf("expected %v, got %v", rpctypes.ErrUserEmpty, err) } @@ -128,11 +128,11 @@ func TestUserErrorAuth(t *testing.T) { DialOptions: []grpc.DialOption{grpc.WithBlock()}, } cfg.Username, cfg.Password = "wrong-id", "123" - if _, err := integration2.NewClient(t, cfg); err != rpctypes.ErrAuthFailed { + if _, err := integration2.NewClient(t, cfg); !errors.Is(err, rpctypes.ErrAuthFailed) { t.Fatalf("expected %v, got %v", rpctypes.ErrAuthFailed, err) } cfg.Username, cfg.Password = "root", "wrong-pass" - if _, err := integration2.NewClient(t, cfg); err != rpctypes.ErrAuthFailed { + if _, err := integration2.NewClient(t, cfg); !errors.Is(err, rpctypes.ErrAuthFailed) { t.Fatalf("expected %v, got %v", rpctypes.ErrAuthFailed, err) } diff --git a/tests/integration/v3_grpc_test.go b/tests/integration/v3_grpc_test.go index 2cc4ab66032..60b5eaccb64 100644 --- a/tests/integration/v3_grpc_test.go +++ b/tests/integration/v3_grpc_test.go @@ -17,6 +17,7 @@ package integration import ( "bytes" "context" + "errors" "fmt" "math/rand" "os" @@ -1599,7 +1600,7 @@ func TestTLSGRPCRejectSecureClient(t *testing.T) { if client != nil || err == nil { client.Close() t.Fatalf("expected no client") - } else if err != context.DeadlineExceeded { + } else if !errors.Is(err, context.DeadlineExceeded) { t.Fatalf("unexpected error (%v)", err) } } @@ -1776,7 +1777,7 @@ func testTLSReload( // 5. expect dial time-out when loading expired certs select { case gerr := <-errc: - if gerr != context.DeadlineExceeded { + if !errors.Is(gerr, context.DeadlineExceeded) { t.Fatalf("expected %v, got %v", context.DeadlineExceeded, gerr) } case <-time.After(5 * time.Second):