finish inequality conversions

Signed-off-by: redwrasse <mail@redwrasse.io>
This commit is contained in:
redwrasse 2024-09-23 21:51:58 -07:00
parent 5e63c25039
commit e3319c595f
9 changed files with 21 additions and 17 deletions

View File

@ -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

View File

@ -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)
}

View File

@ -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)

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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)
}

View File

@ -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):