diff --git a/auth/store_test.go b/auth/store_test.go index 1d4ad7d2741..a7cae29a829 100644 --- a/auth/store_test.go +++ b/auth/store_test.go @@ -751,10 +751,10 @@ func TestHammerSimpleAuthenticate(t *testing.T) { token := fmt.Sprintf("%s(%d)", user, i) ctx := context.WithValue(context.WithValue(context.TODO(), AuthenticateParamIndex{}, uint64(1)), AuthenticateParamSimpleTokenPrefix{}, token) if _, err := as.Authenticate(ctx, user, "123"); err != nil { - t.Fatal(err) + t.Error(err) } if _, err := as.AuthInfoFromCtx(ctx); err != nil { - t.Fatal(err) + t.Error(err) } }(u) } diff --git a/client/client.go b/client/client.go index 6f1270f8a2a..de9ab798e48 100644 --- a/client/client.go +++ b/client/client.go @@ -640,11 +640,11 @@ func (r *redirectFollowingHTTPClient) Do(ctx context.Context, act httpAction) (* if resp.StatusCode/100 == 3 { hdr := resp.Header.Get("Location") if hdr == "" { - return nil, nil, fmt.Errorf("Location header not set") + return nil, nil, fmt.Errorf("location header not set") } loc, err := url.Parse(hdr) if err != nil { - return nil, nil, fmt.Errorf("Location header not valid URL: %s", hdr) + return nil, nil, fmt.Errorf("location header not valid URL: %s", hdr) } next = &redirectedHTTPAction{ action: act, diff --git a/client/client_test.go b/client/client_test.go index 2b4ae4d82a9..fff6e6629aa 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -691,7 +691,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) { }, }, }, - wantErr: errors.New("Location header not set"), + wantErr: errors.New("location header not set"), }, // fail if Location header is invalid @@ -707,7 +707,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) { }, }, }, - wantErr: errors.New("Location header not valid URL: :"), + wantErr: errors.New("location header not valid URL: :"), }, // fail if redirects checked way too many times @@ -795,7 +795,7 @@ func TestHTTPClusterClientSync(t *testing.T) { want = []string{"http://127.0.0.1:2379", "http://127.0.0.1:4001", "http://127.0.0.1:4002", "http://127.0.0.1:4003"} got = hc.Endpoints() - sort.Sort(sort.StringSlice(got)) + sort.Strings(got) if !reflect.DeepEqual(want, got) { t.Fatalf("incorrect endpoints post-Sync: want=%#v got=%#v", want, got) } diff --git a/client/keys.go b/client/keys.go index d0350b8d2eb..ec53830c7f0 100644 --- a/client/keys.go +++ b/client/keys.go @@ -62,7 +62,7 @@ func (e Error) Error() string { } var ( - ErrInvalidJSON = errors.New("client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint.") + ErrInvalidJSON = errors.New("client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint") ErrEmptyBody = errors.New("client: response body is empty") ) diff --git a/clientv3/balancer/balancer.go b/clientv3/balancer/balancer.go index 54c405b0a14..c39702ec47c 100644 --- a/clientv3/balancer/balancer.go +++ b/clientv3/balancer/balancer.go @@ -221,7 +221,6 @@ func (bb *baseBalancer) HandleSubConnStateChange(sc balancer.SubConn, s connecti } bb.currentConn.UpdateBalancerState(bb.currentState, bb.Picker) - return } func (bb *baseBalancer) regeneratePicker() { diff --git a/clientv3/balancer/grpc1.7-health_test.go b/clientv3/balancer/grpc1.7-health_test.go index 186de7a36d6..1ebd205bbd0 100644 --- a/clientv3/balancer/grpc1.7-health_test.go +++ b/clientv3/balancer/grpc1.7-health_test.go @@ -281,7 +281,7 @@ func (kcl *killConnListener) listen(l net.Listener) { default: } if err != nil { - kcl.t.Fatal(err) + kcl.t.Error(err) } time.Sleep(1 * time.Millisecond) conn.Close() diff --git a/clientv3/client.go b/clientv3/client.go index f078f6f8eeb..b91cbf958ef 100644 --- a/clientv3/client.go +++ b/clientv3/client.go @@ -77,7 +77,6 @@ type Client struct { cfg Config creds *credentials.TransportCredentials - balancer balancer.Balancer resolverGroup *endpoint.ResolverGroup mu *sync.RWMutex diff --git a/clientv3/concurrency/session.go b/clientv3/concurrency/session.go index 598ec0e4ffd..97eb7631067 100644 --- a/clientv3/concurrency/session.go +++ b/clientv3/concurrency/session.go @@ -47,7 +47,7 @@ func NewSession(client *v3.Client, opts ...SessionOption) (*Session, error) { if err != nil { return nil, err } - id = v3.LeaseID(resp.ID) + id = resp.ID } ctx, cancel := context.WithCancel(ops.ctx) diff --git a/clientv3/integration/kv_test.go b/clientv3/integration/kv_test.go index 3a461d6d8bd..b31fd0920bf 100644 --- a/clientv3/integration/kv_test.go +++ b/clientv3/integration/kv_test.go @@ -463,7 +463,7 @@ func TestKVGetErrConnClosed(t *testing.T) { defer close(donec) _, err := cli.Get(context.TODO(), "foo") if !clientv3.IsConnCanceled(err) { - t.Fatalf("expected %v or %v, got %v", context.Canceled, grpc.ErrClientConnClosing, err) + t.Errorf("expected %v or %v, got %v", context.Canceled, grpc.ErrClientConnClosing, err) } }() @@ -490,7 +490,7 @@ func TestKVNewAfterClose(t *testing.T) { go func() { _, err := cli.Get(context.TODO(), "foo") if !clientv3.IsConnCanceled(err) { - t.Fatalf("expected %v or %v, got %v", context.Canceled, grpc.ErrClientConnClosing, err) + t.Errorf("expected %v or %v, got %v", context.Canceled, grpc.ErrClientConnClosing, err) } close(donec) }() @@ -704,7 +704,7 @@ func TestKVGetRetry(t *testing.T) { // Get will fail, but reconnect will trigger gresp, gerr := kv.Get(ctx, "foo") if gerr != nil { - t.Fatal(gerr) + t.Error(gerr) } wkvs := []*mvccpb.KeyValue{ { @@ -716,7 +716,7 @@ func TestKVGetRetry(t *testing.T) { }, } if !reflect.DeepEqual(gresp.Kvs, wkvs) { - t.Fatalf("bad get: got %v, want %v", gresp.Kvs, wkvs) + t.Errorf("bad get: got %v, want %v", gresp.Kvs, wkvs) } donec <- struct{}{} }() @@ -754,10 +754,10 @@ func TestKVPutFailGetRetry(t *testing.T) { // Get will fail, but reconnect will trigger gresp, gerr := kv.Get(context.TODO(), "foo") if gerr != nil { - t.Fatal(gerr) + t.Error(gerr) } if len(gresp.Kvs) != 0 { - t.Fatalf("bad get kvs: got %+v, want empty", gresp.Kvs) + t.Errorf("bad get kvs: got %+v, want empty", gresp.Kvs) } donec <- struct{}{} }() diff --git a/clientv3/integration/lease_test.go b/clientv3/integration/lease_test.go index 6fd8f4306aa..111739d396f 100644 --- a/clientv3/integration/lease_test.go +++ b/clientv3/integration/lease_test.go @@ -86,7 +86,7 @@ func TestLeaseRevoke(t *testing.T) { t.Errorf("failed to create lease %v", err) } - _, err = lapi.Revoke(context.Background(), clientv3.LeaseID(resp.ID)) + _, err = lapi.Revoke(context.Background(), resp.ID) if err != nil { t.Errorf("failed to revoke lease %v", err) } @@ -302,7 +302,7 @@ func TestLeaseGrantErrConnClosed(t *testing.T) { if !clientv3.IsConnCanceled(err) { // grpc.ErrClientConnClosing if grpc-go balancer calls 'Get' after client.Close. // context.Canceled if grpc-go balancer calls 'Get' with an inflight client.Close. - t.Fatalf("expected %v, %v or server unavailable, got %v", err != context.Canceled, grpc.ErrClientConnClosing, err) + t.Errorf("expected %v, %v or server unavailable, got %v", err != context.Canceled, grpc.ErrClientConnClosing, err) } }() @@ -372,7 +372,7 @@ func TestLeaseGrantNewAfterClose(t *testing.T) { go func() { _, err := cli.Grant(context.TODO(), 5) if !clientv3.IsConnCanceled(err) { - t.Fatalf("expected %v, %v or server unavailable, got %v", err != context.Canceled, grpc.ErrClientConnClosing, err) + t.Errorf("expected %v, %v or server unavailable, got %v", err != context.Canceled, grpc.ErrClientConnClosing, err) } close(donec) }() @@ -767,7 +767,7 @@ func TestV3LeaseFailureOverlap(t *testing.T) { if err == nil || err == rpctypes.ErrTimeoutDueToConnectionLost { return } - t.Fatal(err) + t.Error(err) }() } } diff --git a/clientv3/integration/leasing_test.go b/clientv3/integration/leasing_test.go index 5c4bab1cf4d..cc3ecffcd54 100644 --- a/clientv3/integration/leasing_test.go +++ b/clientv3/integration/leasing_test.go @@ -114,7 +114,7 @@ func TestLeasingInterval(t *testing.T) { } // load into cache - if resp, err = lkv.Get(context.TODO(), "abc/a"); err != nil { + if _, err = lkv.Get(context.TODO(), "abc/a"); err != nil { t.Fatal(err) } @@ -389,7 +389,7 @@ func TestLeasingConcurrentPut(t *testing.T) { go func() { resp, perr := lkv.Put(context.TODO(), "k", "abc") if perr != nil { - t.Fatal(perr) + t.Error(perr) } putc <- resp }() @@ -559,7 +559,7 @@ func TestLeasingOwnerPutResponse(t *testing.T) { if _, err = clus.Client(0).Put(context.TODO(), "k", "abc"); err != nil { t.Fatal(err) } - gresp, gerr := lkv.Get(context.TODO(), "k") + _, gerr := lkv.Get(context.TODO(), "k") if gerr != nil { t.Fatal(gerr) } @@ -573,7 +573,7 @@ func TestLeasingOwnerPutResponse(t *testing.T) { clus.Members[0].Stop(t) - gresp, gerr = lkv.Get(context.TODO(), "k") + gresp, gerr := lkv.Get(context.TODO(), "k") if gerr != nil { t.Fatal(gerr) } @@ -992,7 +992,7 @@ func TestLeasingTxnRandIfThenOrElse(t *testing.T) { for i := 0; i < keyCount/2; i++ { k := fmt.Sprintf("k-%d", rand.Intn(keyCount)) if _, err := kv.Get(context.TODO(), k); err != nil { - t.Fatal(err) + t.Error(err) } getc <- struct{}{} } @@ -1399,10 +1399,10 @@ func TestLeasingReconnectOwnerRevoke(t *testing.T) { // blocks until lkv1 connection comes back resp, err := lkv1.Get(cctx, "k") if err != nil { - t.Fatal(err) + t.Error(err) } if string(resp.Kvs[0].Value) != "v" { - t.Fatalf(`expected "v" value, got %+v`, resp) + t.Errorf(`expected "v" value, got %+v`, resp) } }() select { @@ -1440,11 +1440,11 @@ func TestLeasingReconnectOwnerRevokeCompact(t *testing.T) { clus.WaitLeader(t) // put some more revisions for compaction - presp, err := clus.Client(1).Put(context.TODO(), "a", "123") + _, err := clus.Client(1).Put(context.TODO(), "a", "123") if err != nil { t.Fatal(err) } - presp, err = clus.Client(1).Put(context.TODO(), "a", "123") + presp, err := clus.Client(1).Put(context.TODO(), "a", "123") if err != nil { t.Fatal(err) } @@ -1595,7 +1595,7 @@ func TestLeasingTxnAtomicCache(t *testing.T) { } tresp, err := lkv.Txn(context.TODO()).Then(gets...).Commit() if err != nil { - t.Fatal(err) + t.Error(err) } revs := make([]int64, len(gets)) for i, resp := range tresp.Responses { @@ -1604,7 +1604,7 @@ func TestLeasingTxnAtomicCache(t *testing.T) { } for i := 1; i < len(revs); i++ { if revs[i] != revs[i-1] { - t.Fatalf("expected matching revisions, got %+v", revs) + t.Errorf("expected matching revisions, got %+v", revs) } } } diff --git a/clientv3/integration/metrics_test.go b/clientv3/integration/metrics_test.go index 1b73af9d78d..ba02e351429 100644 --- a/clientv3/integration/metrics_test.go +++ b/clientv3/integration/metrics_test.go @@ -54,12 +54,12 @@ func TestV3ClientMetrics(t *testing.T) { ln, err = transport.NewUnixListener(addr) if err != nil { - t.Fatalf("Error: %v occurred while listening on addr: %v", err, addr) + t.Errorf("Error: %v occurred while listening on addr: %v", err, addr) } err = srv.Serve(ln) if err != nil && !transport.IsClosedConnError(err) { - t.Fatalf("Err serving http requests: %v", err) + t.Errorf("Err serving http requests: %v", err) } }() diff --git a/clientv3/integration/mirror_test.go b/clientv3/integration/mirror_test.go index 46b312ff9f5..a82678e3632 100644 --- a/clientv3/integration/mirror_test.go +++ b/clientv3/integration/mirror_test.go @@ -90,7 +90,7 @@ func TestMirrorSyncBase(t *testing.T) { for key := range keyCh { if _, err := cli.Put(ctx, key, "test"); err != nil { - t.Fatal(err) + t.Error(err) } } }() diff --git a/clientv3/integration/server_shutdown_test.go b/clientv3/integration/server_shutdown_test.go index f7ce58c3672..e7cfeae9d33 100644 --- a/clientv3/integration/server_shutdown_test.go +++ b/clientv3/integration/server_shutdown_test.go @@ -75,16 +75,16 @@ func TestBalancerUnderServerShutdownWatch(t *testing.T) { select { case ev := <-wch: if werr := ev.Err(); werr != nil { - t.Fatal(werr) + t.Error(werr) } if len(ev.Events) != 1 { - t.Fatalf("expected one event, got %+v", ev) + t.Errorf("expected one event, got %+v", ev) } if !bytes.Equal(ev.Events[0].Kv.Value, []byte(val)) { - t.Fatalf("expected %q, got %+v", val, ev.Events[0].Kv) + t.Errorf("expected %q, got %+v", val, ev.Events[0].Kv) } case <-time.After(7 * time.Second): - t.Fatal("took too long to receive events") + t.Error("took too long to receive events") } }() @@ -350,7 +350,7 @@ func testBalancerUnderServerStopInflightRangeOnRestart(t *testing.T, linearizabl } cancel() if err != nil { - t.Fatalf("unexpected error: %v", err) + t.Errorf("unexpected error: %v", err) } }() diff --git a/clientv3/integration/txn_test.go b/clientv3/integration/txn_test.go index af994adbe95..212ecdc3357 100644 --- a/clientv3/integration/txn_test.go +++ b/clientv3/integration/txn_test.go @@ -67,7 +67,7 @@ func TestTxnWriteFail(t *testing.T) { defer cancel() resp, err := kv.Txn(ctx).Then(clientv3.OpPut("foo", "bar")).Commit() if err == nil { - t.Fatalf("expected error, got response %v", resp) + t.Errorf("expected error, got response %v", resp) } close(txnc) }() @@ -76,16 +76,16 @@ func TestTxnWriteFail(t *testing.T) { defer close(getc) select { case <-time.After(5 * time.Second): - t.Fatalf("timed out waiting for txn fail") + t.Errorf("timed out waiting for txn fail") case <-txnc: } // and ensure the put didn't take gresp, gerr := clus.Client(1).Get(context.TODO(), "foo") if gerr != nil { - t.Fatal(gerr) + t.Error(gerr) } if len(gresp.Kvs) != 0 { - t.Fatalf("expected no keys, got %v", gresp.Kvs) + t.Errorf("expected no keys, got %v", gresp.Kvs) } }() @@ -123,7 +123,7 @@ func TestTxnReadRetry(t *testing.T) { go func() { _, err := kv.Txn(context.TODO()).Then(thenOps[i]...).Commit() if err != nil { - t.Fatalf("expected response, got error %v", err) + t.Errorf("expected response, got error %v", err) } donec <- struct{}{} }() diff --git a/clientv3/integration/watch_test.go b/clientv3/integration/watch_test.go index bf751d6793b..007cbc38ec6 100644 --- a/clientv3/integration/watch_test.go +++ b/clientv3/integration/watch_test.go @@ -80,13 +80,13 @@ func testWatchMultiWatcher(t *testing.T, wctx *watchctx) { go func(key string) { ch := wctx.w.Watch(context.TODO(), key) if ch == nil { - t.Fatalf("expected watcher channel, got nil") + t.Errorf("expected watcher channel, got nil") } readyc <- struct{}{} for i := 0; i < numKeyUpdates; i++ { resp, ok := <-ch if !ok { - t.Fatalf("watcher unexpectedly closed") + t.Errorf("watcher unexpectedly closed") } v := fmt.Sprintf("%s-%d", key, i) gotv := string(resp.Events[0].Kv.Value) @@ -101,14 +101,14 @@ func testWatchMultiWatcher(t *testing.T, wctx *watchctx) { go func() { prefixc := wctx.w.Watch(context.TODO(), "b", clientv3.WithPrefix()) if prefixc == nil { - t.Fatalf("expected watcher channel, got nil") + t.Errorf("expected watcher channel, got nil") } readyc <- struct{}{} evs := []*clientv3.Event{} for i := 0; i < numKeyUpdates*2; i++ { resp, ok := <-prefixc if !ok { - t.Fatalf("watcher unexpectedly closed") + t.Errorf("watcher unexpectedly closed") } evs = append(evs, resp.Events...) } @@ -134,9 +134,9 @@ func testWatchMultiWatcher(t *testing.T, wctx *watchctx) { select { case resp, ok := <-prefixc: if !ok { - t.Fatalf("watcher unexpectedly closed") + t.Errorf("watcher unexpectedly closed") } - t.Fatalf("unexpected event %+v", resp) + t.Errorf("unexpected event %+v", resp) case <-time.After(time.Second): } donec <- struct{}{} @@ -740,7 +740,7 @@ func TestWatchErrConnClosed(t *testing.T) { ch := cli.Watch(context.TODO(), "foo") if wr := <-ch; !isCanceled(wr.Err()) { - t.Fatalf("expected context canceled, got %v", wr.Err()) + t.Errorf("expected context canceled, got %v", wr.Err()) } }() @@ -772,7 +772,7 @@ func TestWatchAfterClose(t *testing.T) { go func() { cli.Watch(context.TODO(), "foo") if err := cli.Close(); err != nil && err != context.Canceled { - t.Fatalf("expected %v, got %v", context.Canceled, err) + t.Errorf("expected %v, got %v", context.Canceled, err) } close(donec) }() @@ -1036,7 +1036,7 @@ func testWatchOverlapContextCancel(t *testing.T, f func(*integration.ClusterV3)) select { case _, ok := <-wch: if !ok { - t.Fatalf("unexpected closed channel %p", wch) + t.Errorf("unexpected closed channel %p", wch) } // may take a second or two to reestablish a watcher because of // grpc back off policies for disconnects @@ -1078,10 +1078,10 @@ func TestWatchCancelAndCloseClient(t *testing.T) { select { case wr, ok := <-wch: if ok { - t.Fatalf("expected closed watch after cancel(), got resp=%+v err=%v", wr, wr.Err()) + t.Errorf("expected closed watch after cancel(), got resp=%+v err=%v", wr, wr.Err()) } case <-time.After(5 * time.Second): - t.Fatal("timed out waiting for closed channel") + t.Error("timed out waiting for closed channel") } }() cancel() diff --git a/clientv3/leasing/cache.go b/clientv3/leasing/cache.go index f4870c1fb2f..26f8a057873 100644 --- a/clientv3/leasing/cache.go +++ b/clientv3/leasing/cache.go @@ -256,7 +256,7 @@ func (lc *leaseCache) clearOldRevokes(ctx context.Context) { case <-time.After(time.Second): lc.mu.Lock() for k, lr := range lc.revokes { - if time.Now().Sub(lr.Add(revokeBackoff)) > 0 { + if time.Since(lr.Add(revokeBackoff)) > 0 { delete(lc.revokes, k) } } diff --git a/clientv3/mirror/syncer.go b/clientv3/mirror/syncer.go index e00af70ee51..a984105fe74 100644 --- a/clientv3/mirror/syncer.go +++ b/clientv3/mirror/syncer.go @@ -90,7 +90,7 @@ func (s *syncer) SyncBase(ctx context.Context) (<-chan clientv3.GetResponse, cha return } - respchan <- (clientv3.GetResponse)(*resp) + respchan <- *resp if !resp.More { return diff --git a/clientv3/op.go b/clientv3/op.go index 085dd28ab44..81ae31fd8f3 100644 --- a/clientv3/op.go +++ b/clientv3/op.go @@ -113,13 +113,13 @@ func (op Op) IsGet() bool { return op.t == tRange } func (op Op) IsDelete() bool { return op.t == tDeleteRange } // IsSerializable returns true if the serializable field is true. -func (op Op) IsSerializable() bool { return op.serializable == true } +func (op Op) IsSerializable() bool { return op.serializable } // IsKeysOnly returns whether keysOnly is set. -func (op Op) IsKeysOnly() bool { return op.keysOnly == true } +func (op Op) IsKeysOnly() bool { return op.keysOnly } // IsCountOnly returns whether countOnly is set. -func (op Op) IsCountOnly() bool { return op.countOnly == true } +func (op Op) IsCountOnly() bool { return op.countOnly } // MinModRev returns the operation's minimum modify revision. func (op Op) MinModRev() int64 { return op.minModRev } diff --git a/clientv3/options.go b/clientv3/options.go index 4660acea067..700714c0863 100644 --- a/clientv3/options.go +++ b/clientv3/options.go @@ -47,7 +47,7 @@ var ( // client-side streaming retry limit, only applied to requests where server responds with // a error code clearly indicating it was unable to process the request such as codes.Unavailable. // If set to 0, retry is disabled. - defaultStreamMaxRetries = uint(^uint(0)) // max uint + defaultStreamMaxRetries = ^uint(0) // max uint // client-side retry backoff wait between requests. defaultBackoffWaitBetween = 25 * time.Millisecond diff --git a/clientv3/ready_wait.go b/clientv3/ready_wait.go deleted file mode 100644 index c6ef585b5b4..00000000000 --- a/clientv3/ready_wait.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2017 The etcd Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package clientv3 - -import "context" - -// TODO: remove this when "FailFast=false" is fixed. -// See https://github.com/grpc/grpc-go/issues/1532. -func readyWait(rpcCtx, clientCtx context.Context, ready <-chan struct{}) error { - select { - case <-ready: - return nil - case <-rpcCtx.Done(): - return rpcCtx.Err() - case <-clientCtx.Done(): - return clientCtx.Err() - } -} diff --git a/clientv3/retry.go b/clientv3/retry.go index 6da7abf475c..7e855de066a 100644 --- a/clientv3/retry.go +++ b/clientv3/retry.go @@ -43,10 +43,6 @@ func (rp retryPolicy) String() string { } } -type rpcFunc func(ctx context.Context) error -type retryRPCFunc func(context.Context, rpcFunc, retryPolicy) error -type retryStopErrFunc func(error) bool - // isSafeRetryImmutableRPC returns "true" when an immutable request is safe for retry. // // immutable requests (e.g. Get) should be retried unless it's diff --git a/clientv3/retry_interceptor.go b/clientv3/retry_interceptor.go index 65a518d09d3..080490ae292 100644 --- a/clientv3/retry_interceptor.go +++ b/clientv3/retry_interceptor.go @@ -28,6 +28,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" ) // unaryClientInterceptor returns a new retrying unary client interceptor. @@ -109,7 +110,7 @@ func (c *Client) streamClientInterceptor(logger *zap.Logger, optFuncs ...retryOp return streamer(ctx, desc, cc, method, grpcOpts...) } if desc.ClientStreams { - return nil, grpc.Errorf(codes.Unimplemented, "clientv3/retry_interceptor: cannot retry on ClientStreams, set Disable()") + return nil, status.Errorf(codes.Unimplemented, "clientv3/retry_interceptor: cannot retry on ClientStreams, set Disable()") } newStreamer, err := streamer(ctx, desc, cc, method, grpcOpts...) logger.Warn("retry stream intercept", zap.Error(err)) @@ -296,11 +297,11 @@ func isContextError(err error) bool { func contextErrToGrpcErr(err error) error { switch err { case context.DeadlineExceeded: - return grpc.Errorf(codes.DeadlineExceeded, err.Error()) + return status.Errorf(codes.DeadlineExceeded, err.Error()) case context.Canceled: - return grpc.Errorf(codes.Canceled, err.Error()) + return status.Errorf(codes.Canceled, err.Error()) default: - return grpc.Errorf(codes.Unknown, err.Error()) + return status.Errorf(codes.Unknown, err.Error()) } } @@ -328,13 +329,6 @@ func withRetryPolicy(rp retryPolicy) retryOption { }} } -// withAuthRetry sets enables authentication retries. -func withAuthRetry(retryAuth bool) retryOption { - return retryOption{applyFunc: func(o *options) { - o.retryAuth = retryAuth - }} -} - // withMax sets the maximum number of retries on this call, or this interceptor. func withMax(maxRetries uint) retryOption { return retryOption{applyFunc: func(o *options) { diff --git a/clientv3/snapshot/v3_snapshot_test.go b/clientv3/snapshot/v3_snapshot_test.go index 8d2ee9d6aaa..0a4c3096c3a 100644 --- a/clientv3/snapshot/v3_snapshot_test.go +++ b/clientv3/snapshot/v3_snapshot_test.go @@ -295,7 +295,7 @@ func restoreCluster(t *testing.T, clusterN int, dbPath string) ( go func(idx int) { srv, err := embed.StartEtcd(cfgs[idx]) if err != nil { - t.Fatal(err) + t.Error(err) } <-srv.Server.ReadyNotify() diff --git a/contrib/raftexample/raftexample_test.go b/contrib/raftexample/raftexample_test.go index 91c1f34f03d..e6c56cee166 100644 --- a/contrib/raftexample/raftexample_test.go +++ b/contrib/raftexample/raftexample_test.go @@ -117,7 +117,7 @@ func TestProposeOnCommit(t *testing.T) { case pC <- *s: continue case err := <-eC: - t.Fatalf("eC message (%v)", err) + t.Errorf("eC message (%v)", err) } } donec <- struct{}{} diff --git a/etcdserver/server_test.go b/etcdserver/server_test.go index 36550ba4c3d..e7cde53b4b8 100644 --- a/etcdserver/server_test.go +++ b/etcdserver/server_test.go @@ -995,7 +995,7 @@ func TestSnapshot(t *testing.T) { defer func() { ch <- struct{}{} }() if len(gaction) != 1 { - t.Fatalf("len(action) = %d, want 1", len(gaction)) + t.Errorf("len(action) = %d, want 1", len(gaction)) } if !reflect.DeepEqual(gaction[0], testutil.Action{Name: "SaveSnap"}) { t.Errorf("action = %s, want SaveSnap", gaction[0]) @@ -1007,7 +1007,7 @@ func TestSnapshot(t *testing.T) { defer func() { ch <- struct{}{} }() if len(gaction) != 2 { - t.Fatalf("len(action) = %d, want 2", len(gaction)) + t.Errorf("len(action) = %d, want 2", len(gaction)) } if !reflect.DeepEqual(gaction[0], testutil.Action{Name: "Clone"}) { t.Errorf("action = %s, want Clone", gaction[0]) @@ -1140,7 +1140,7 @@ func TestTriggerSnap(t *testing.T) { // each operation is recorded as a Save // (SnapshotCount+1) * Puts + SaveSnap = (SnapshotCount+1) * Save + SaveSnap if len(gaction) != wcnt { - t.Fatalf("len(action) = %d, want %d", len(gaction), wcnt) + t.Errorf("len(action) = %d, want %d", len(gaction), wcnt) } if !reflect.DeepEqual(gaction[wcnt-1], testutil.Action{Name: "SaveSnap"}) { t.Errorf("action = %s, want SaveSnap", gaction[wcnt-1]) diff --git a/functional/tester/cluster_read_config.go b/functional/tester/cluster_read_config.go index 4ce9d076e67..df0dc667a10 100644 --- a/functional/tester/cluster_read_config.go +++ b/functional/tester/cluster_read_config.go @@ -53,7 +53,7 @@ func read(lg *zap.Logger, fpath string) (*Cluster, error) { } if len(clus.Tester.Cases) == 0 { - return nil, errors.New("Cases not found") + return nil, errors.New("cases not found") } if clus.Tester.DelayLatencyMs <= clus.Tester.DelayLatencyMsRv*5 { return nil, fmt.Errorf("delay latency %d ms must be greater than 5x of delay latency random variable %d ms", clus.Tester.DelayLatencyMs, clus.Tester.DelayLatencyMsRv) @@ -227,7 +227,7 @@ func read(lg *zap.Logger, fpath string) (*Cluster, error) { return nil, fmt.Errorf("Etcd.PeerClientCertAuth and Etcd.PeerAutoTLS cannot be both 'true'") } if (mem.Etcd.PeerCertFile == "") != (mem.Etcd.PeerKeyFile == "") { - return nil, fmt.Errorf("Both Etcd.PeerCertFile %q and Etcd.PeerKeyFile %q must be either empty or non-empty", mem.Etcd.PeerCertFile, mem.Etcd.PeerKeyFile) + return nil, fmt.Errorf("both Etcd.PeerCertFile %q and Etcd.PeerKeyFile %q must be either empty or non-empty", mem.Etcd.PeerCertFile, mem.Etcd.PeerKeyFile) } if mem.Etcd.ClientCertAuth && mem.Etcd.ClientAutoTLS { return nil, fmt.Errorf("Etcd.ClientCertAuth and Etcd.ClientAutoTLS cannot be both 'true'") @@ -251,7 +251,7 @@ func read(lg *zap.Logger, fpath string) (*Cluster, error) { return nil, fmt.Errorf("Etcd.ClientCertAuth 'false', but Etcd.ClientTrustedCAFile is %q", mem.Etcd.PeerCertFile) } if (mem.Etcd.ClientCertFile == "") != (mem.Etcd.ClientKeyFile == "") { - return nil, fmt.Errorf("Both Etcd.ClientCertFile %q and Etcd.ClientKeyFile %q must be either empty or non-empty", mem.Etcd.ClientCertFile, mem.Etcd.ClientKeyFile) + return nil, fmt.Errorf("both Etcd.ClientCertFile %q and Etcd.ClientKeyFile %q must be either empty or non-empty", mem.Etcd.ClientCertFile, mem.Etcd.ClientKeyFile) } peerTLS := mem.Etcd.PeerAutoTLS || diff --git a/integration/v2_http_kv_test.go b/integration/v2_http_kv_test.go index c42e5a87395..62ee92bfc46 100644 --- a/integration/v2_http_kv_test.go +++ b/integration/v2_http_kv_test.go @@ -891,7 +891,7 @@ func TestV2WatchWithIndex(t *testing.T) { go func() { resp, err := tc.Get(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar?wait=true&waitIndex=5")) if err != nil { - t.Fatalf("watch err = %v, want nil", err) + t.Errorf("watch err = %v, want nil", err) } body = tc.ReadBodyJSON(resp) c <- true @@ -979,7 +979,7 @@ func TestV2WatchKeyInDir(t *testing.T) { // Expect a notification when watching the node resp, err := tc.Get(fmt.Sprintf("%s%s", u, "/v2/keys/keyindir/bar?wait=true")) if err != nil { - t.Fatalf("watch err = %v, want nil", err) + t.Errorf("watch err = %v, want nil", err) } body = tc.ReadBodyJSON(resp) c <- true diff --git a/integration/v3_alarm_test.go b/integration/v3_alarm_test.go index 7d9adf956d7..e547a3eb146 100644 --- a/integration/v3_alarm_test.go +++ b/integration/v3_alarm_test.go @@ -159,7 +159,7 @@ func TestV3CorruptAlarm(t *testing.T) { go func() { defer wg.Done() if _, err := clus.Client(0).Put(context.TODO(), "k", "v"); err != nil { - t.Fatal(err) + t.Error(err) } }() } diff --git a/integration/v3_barrier_test.go b/integration/v3_barrier_test.go index 54fa3be665e..1fbc78b3c6a 100644 --- a/integration/v3_barrier_test.go +++ b/integration/v3_barrier_test.go @@ -51,7 +51,7 @@ func testBarrier(t *testing.T, waiters int, chooseClient func() *clientv3.Client go func() { br := recipe.NewBarrier(chooseClient(), "test-barrier") if err := br.Wait(); err != nil { - t.Fatalf("could not wait on barrier (%v)", err) + t.Errorf("could not wait on barrier (%v)", err) } donec <- struct{}{} }() diff --git a/integration/v3_double_barrier_test.go b/integration/v3_double_barrier_test.go index dc5acd84ca4..c4bf4ac684e 100644 --- a/integration/v3_double_barrier_test.go +++ b/integration/v3_double_barrier_test.go @@ -45,11 +45,11 @@ func TestDoubleBarrier(t *testing.T) { bb := recipe.NewDoubleBarrier(session, "test-barrier", waiters) if err := bb.Enter(); err != nil { - t.Fatalf("could not enter on barrier (%v)", err) + t.Errorf("could not enter on barrier (%v)", err) } donec <- struct{}{} if err := bb.Leave(); err != nil { - t.Fatalf("could not leave on barrier (%v)", err) + t.Errorf("could not leave on barrier (%v)", err) } donec <- struct{}{} }() @@ -115,7 +115,7 @@ func TestDoubleBarrierFailover(t *testing.T) { go func() { b := recipe.NewDoubleBarrier(s0, "test-barrier", waiters) if berr := b.Enter(); berr != nil { - t.Fatalf("could not enter on barrier (%v)", berr) + t.Errorf("could not enter on barrier (%v)", berr) } donec <- struct{}{} }() @@ -124,7 +124,7 @@ func TestDoubleBarrierFailover(t *testing.T) { go func() { b := recipe.NewDoubleBarrier(s1, "test-barrier", waiters) if berr := b.Enter(); berr != nil { - t.Fatalf("could not enter on barrier (%v)", berr) + t.Errorf("could not enter on barrier (%v)", berr) } donec <- struct{}{} b.Leave() diff --git a/integration/v3_election_test.go b/integration/v3_election_test.go index 4598448001b..835d3ebc0a2 100644 --- a/integration/v3_election_test.go +++ b/integration/v3_election_test.go @@ -53,7 +53,7 @@ func TestElectionWait(t *testing.T) { defer cancel() s, ok := <-b.Observe(cctx) if !ok { - t.Fatalf("could not observe election; channel closed") + t.Errorf("could not observe election; channel closed") } electedc <- string(s.Kvs[0].Value) // wait for next election round @@ -76,7 +76,7 @@ func TestElectionWait(t *testing.T) { e := concurrency.NewElection(session, "test-election") ev := fmt.Sprintf("electval-%v", time.Now().UnixNano()) if err := e.Campaign(context.TODO(), ev); err != nil { - t.Fatalf("failed volunteer (%v)", err) + t.Errorf("failed volunteer (%v)", err) } // wait for followers to accept leadership for j := 0; j < followers; j++ { @@ -87,7 +87,7 @@ func TestElectionWait(t *testing.T) { } // let next leader take over if err := e.Resign(context.TODO()); err != nil { - t.Fatalf("failed resign (%v)", err) + t.Errorf("failed resign (%v)", err) } // tell followers to start listening for next leader for j := 0; j < followers; j++ { diff --git a/integration/v3_grpc_inflight_test.go b/integration/v3_grpc_inflight_test.go index 1a0a11a8e1b..c89bc2c4acc 100644 --- a/integration/v3_grpc_inflight_test.go +++ b/integration/v3_grpc_inflight_test.go @@ -86,7 +86,7 @@ func TestV3KVInflightRangeRequests(t *testing.T) { errCode := status.Convert(err).Code() errDesc := rpctypes.ErrorDesc(err) if err != nil && !(errDesc == context.Canceled.Error() || errCode == codes.Unavailable) { - t.Fatalf("inflight request should be canceled with '%v' or code Unavailable, got '%v' with code '%s'", context.Canceled.Error(), errDesc, errCode) + t.Errorf("inflight request should be canceled with '%v' or code Unavailable, got '%v' with code '%s'", context.Canceled.Error(), errDesc, errCode) } } }() diff --git a/integration/v3_lease_test.go b/integration/v3_lease_test.go index 7b378f0c92f..6e20b01f40e 100644 --- a/integration/v3_lease_test.go +++ b/integration/v3_lease_test.go @@ -623,7 +623,7 @@ func TestV3LeaseRequireLeader(t *testing.T) { defer close(donec) resp, err := lac.Recv() if err == nil { - t.Fatalf("got response %+v, expected error", resp) + t.Errorf("got response %+v, expected error", resp) } if rpctypes.ErrorDesc(err) != rpctypes.ErrNoLeader.Error() { t.Errorf("err = %v, want %v", err, rpctypes.ErrNoLeader) diff --git a/integration/v3_lock_test.go b/integration/v3_lock_test.go index 10b501eafab..88e032796cd 100644 --- a/integration/v3_lock_test.go +++ b/integration/v3_lock_test.go @@ -57,7 +57,7 @@ func testMutex(t *testing.T, waiters int, chooseClient func() *clientv3.Client) } m := concurrency.NewMutex(session, "test-mutex") if err := m.Lock(context.TODO()); err != nil { - t.Fatalf("could not wait on lock (%v)", err) + t.Errorf("could not wait on lock (%v)", err) } lockedC <- m }() @@ -248,12 +248,12 @@ func testRWMutex(t *testing.T, waiters int, chooseClient func() *clientv3.Client rwm := recipe.NewRWMutex(session, "test-rwmutex") if rand.Intn(2) == 0 { if err := rwm.RLock(); err != nil { - t.Fatalf("could not rlock (%v)", err) + t.Errorf("could not rlock (%v)", err) } rlockedC <- rwm } else { if err := rwm.Lock(); err != nil { - t.Fatalf("could not lock (%v)", err) + t.Errorf("could not lock (%v)", err) } wlockedC <- rwm } diff --git a/integration/v3_queue_test.go b/integration/v3_queue_test.go index c7349fd8410..d64571996ad 100644 --- a/integration/v3_queue_test.go +++ b/integration/v3_queue_test.go @@ -42,7 +42,7 @@ func TestQueueOneReaderOneWriter(t *testing.T) { q := recipe.NewQueue(etcdc, "testq") for i := 0; i < 5; i++ { if err := q.Enqueue(fmt.Sprintf("%d", i)); err != nil { - t.Fatalf("error enqueuing (%v)", err) + t.Errorf("error enqueuing (%v)", err) } } }() diff --git a/integration/v3_stm_test.go b/integration/v3_stm_test.go index 25a1fd6c6d3..4ef82bacf7f 100644 --- a/integration/v3_stm_test.go +++ b/integration/v3_stm_test.go @@ -170,7 +170,7 @@ func TestSTMSerialize(t *testing.T) { ops = append(ops, v3.OpPut(k, s)) } if _, err := etcdc.Txn(context.TODO()).Then(ops...).Commit(); err != nil { - t.Fatalf("couldn't put keys (%v)", err) + t.Errorf("couldn't put keys (%v)", err) } updatec <- struct{}{} } @@ -220,7 +220,7 @@ func TestSTMApplyOnConcurrentDeletion(t *testing.T) { go func() { <-readyc if _, err := etcdc.Delete(context.TODO(), "foo"); err != nil { - t.Fatal(err) + t.Error(err) } close(donec) }() diff --git a/integration/v3_watch_test.go b/integration/v3_watch_test.go index da255d569e5..2de2db4c411 100644 --- a/integration/v3_watch_test.go +++ b/integration/v3_watch_test.go @@ -250,7 +250,7 @@ func TestV3WatchFromCurrentRevision(t *testing.T) { kvc := toGRPC(clus.RandClient()).KV req := &pb.PutRequest{Key: []byte(k), Value: []byte("bar")} if _, err := kvc.Put(context.TODO(), req); err != nil { - t.Fatalf("#%d: couldn't put key (%v)", i, err) + t.Errorf("#%d: couldn't put key (%v)", i, err) } } }() @@ -484,7 +484,7 @@ func TestV3WatchCurrentPutOverlap(t *testing.T) { kvc := toGRPC(clus.RandClient()).KV req := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")} if _, err := kvc.Put(context.TODO(), req); err != nil { - t.Fatalf("couldn't put key (%v)", err) + t.Errorf("couldn't put key (%v)", err) } }() } @@ -927,7 +927,7 @@ func testV3WatchMultipleStreams(t *testing.T, startRev int64) { wStream := streams[i] wresp, err := wStream.Recv() if err != nil { - t.Fatalf("wStream.Recv error: %v", err) + t.Errorf("wStream.Recv error: %v", err) } if wresp.WatchId != 0 { t.Errorf("watchId got = %d, want = 0", wresp.WatchId) @@ -1090,7 +1090,7 @@ func TestV3WatchWithFilter(t *testing.T) { // check received PUT resp, rerr := ws.Recv() if rerr != nil { - t.Fatal(rerr) + t.Error(rerr) } recv <- resp }() @@ -1183,7 +1183,7 @@ func TestV3WatchWithPrevKV(t *testing.T) { // check received PUT resp, rerr := ws.Recv() if rerr != nil { - t.Fatal(rerr) + t.Error(rerr) } recv <- resp }() diff --git a/integration/v3election_grpc_test.go b/integration/v3election_grpc_test.go index d49ad24fcb4..664b4f3139d 100644 --- a/integration/v3election_grpc_test.go +++ b/integration/v3election_grpc_test.go @@ -54,10 +54,10 @@ func TestV3ElectionCampaign(t *testing.T) { req2 := &epb.CampaignRequest{Name: []byte("foo"), Lease: lease2.ID, Value: []byte("def")} l2, lerr2 := lc.Campaign(context.TODO(), req2) if lerr2 != nil { - t.Fatal(lerr2) + t.Error(lerr2) } if l1.Header.Revision >= l2.Header.Revision { - t.Fatalf("expected l1 revision < l2 revision, got %d >= %d", l1.Header.Revision, l2.Header.Revision) + t.Errorf("expected l1 revision < l2 revision, got %d >= %d", l1.Header.Revision, l2.Header.Revision) } }() @@ -103,18 +103,18 @@ func TestV3ElectionObserve(t *testing.T) { s, err := lc.Observe(context.Background(), &epb.LeaderRequest{Name: []byte("foo")}) observec <- struct{}{} if err != nil { - t.Fatal(err) + t.Error(err) } for i := 0; i < 10; i++ { resp, rerr := s.Recv() if rerr != nil { - t.Fatal(rerr) + t.Error(rerr) } respV := 0 fmt.Sscanf(string(resp.Kv.Value), "%d", &respV) // leader transitions should not go backwards if respV < i { - t.Fatalf(`got observe value %q, expected >= "%d"`, string(resp.Kv.Value), i) + t.Errorf(`got observe value %q, expected >= "%d"`, string(resp.Kv.Value), i) } i = respV } @@ -142,17 +142,17 @@ func TestV3ElectionObserve(t *testing.T) { lease2, err2 := toGRPC(clus.RandClient()).Lease.LeaseGrant(context.TODO(), &pb.LeaseGrantRequest{TTL: 30}) if err2 != nil { - t.Fatal(err2) + t.Error(err2) } c2, cerr2 := lc.Campaign(context.TODO(), &epb.CampaignRequest{Name: []byte("foo"), Lease: lease2.ID, Value: []byte("5")}) if cerr2 != nil { - t.Fatal(cerr2) + t.Error(cerr2) } for i := 6; i < 10; i++ { v := []byte(fmt.Sprintf("%d", i)) req := &epb.ProclaimRequest{Leader: c2.Leader, Value: v} if _, err := lc.Proclaim(context.TODO(), req); err != nil { - t.Fatal(err) + t.Error(err) } } }() diff --git a/integration/v3lock_grpc_test.go b/integration/v3lock_grpc_test.go index 05276669f3a..0888704bc9c 100644 --- a/integration/v3lock_grpc_test.go +++ b/integration/v3lock_grpc_test.go @@ -50,10 +50,10 @@ func TestV3LockLockWaiter(t *testing.T) { go func() { l2, lerr2 := lc.Lock(context.TODO(), &lockpb.LockRequest{Name: []byte("foo"), Lease: lease2.ID}) if lerr2 != nil { - t.Fatal(lerr2) + t.Error(lerr2) } if l1.Header.Revision >= l2.Header.Revision { - t.Fatalf("expected l1 revision < l2 revision, got %d >= %d", l1.Header.Revision, l2.Header.Revision) + t.Errorf("expected l1 revision < l2 revision, got %d >= %d", l1.Header.Revision, l2.Header.Revision) } close(lockc) }() diff --git a/lease/lessor_test.go b/lease/lessor_test.go index f1330ed7ebb..c79c32e7cf3 100644 --- a/lease/lessor_test.go +++ b/lease/lessor_test.go @@ -433,7 +433,7 @@ func TestLessorExpire(t *testing.T) { go func() { // expired lease cannot be renewed if _, err := le.Renew(l.ID); err != ErrLeaseNotFound { - t.Fatalf("unexpected renew") + t.Errorf("unexpected renew") } donec <- struct{}{} }() @@ -486,7 +486,7 @@ func TestLessorExpireAndDemote(t *testing.T) { go func() { // expired lease cannot be renewed if _, err := le.Renew(l.ID); err != ErrNotPrimary { - t.Fatalf("unexpected renew: %v", err) + t.Errorf("unexpected renew: %v", err) } donec <- struct{}{} }() diff --git a/mvcc/kvstore_test.go b/mvcc/kvstore_test.go index 91183969901..ec04da78735 100644 --- a/mvcc/kvstore_test.go +++ b/mvcc/kvstore_test.go @@ -550,7 +550,7 @@ func TestHashKVWhenCompacting(t *testing.T) { for { hash, _, compactRev, err := s.HashByRev(int64(rev)) if err != nil { - t.Fatal(err) + t.Error(err) } select { case <-donec: @@ -570,7 +570,7 @@ func TestHashKVWhenCompacting(t *testing.T) { revHash[r.compactRev] = r.hash } if r.hash != revHash[r.compactRev] { - t.Fatalf("Hashes differ (current %v) != (saved %v)", r.hash, revHash[r.compactRev]) + t.Errorf("Hashes differ (current %v) != (saved %v)", r.hash, revHash[r.compactRev]) } } }() @@ -581,7 +581,7 @@ func TestHashKVWhenCompacting(t *testing.T) { for i := 100; i >= 0; i-- { _, err := s.Compact(int64(rev - 1 - i)) if err != nil { - t.Fatal(err) + t.Error(err) } time.Sleep(10 * time.Millisecond) } diff --git a/pkg/expect/expect_test.go b/pkg/expect/expect_test.go index d5cdaef5893..c5ed18ec60b 100644 --- a/pkg/expect/expect_test.go +++ b/pkg/expect/expect_test.go @@ -109,7 +109,7 @@ func TestSignal(t *testing.T) { defer close(donec) werr := "signal: interrupt" if cerr := ep.Close(); cerr == nil || cerr.Error() != werr { - t.Fatalf("got error %v, wanted error %s", cerr, werr) + t.Errorf("got error %v, wanted error %s", cerr, werr) } }() select { diff --git a/pkg/fileutil/lock_test.go b/pkg/fileutil/lock_test.go index 7c1dd864414..ded6051dccb 100644 --- a/pkg/fileutil/lock_test.go +++ b/pkg/fileutil/lock_test.go @@ -61,11 +61,11 @@ func TestLockAndUnlock(t *testing.T) { go func() { bl, blerr := LockFile(f.Name(), os.O_WRONLY, PrivateFileMode) if blerr != nil { - t.Fatal(blerr) + t.Error(blerr) } locked <- struct{}{} if blerr = bl.Close(); blerr != nil { - t.Fatal(blerr) + t.Error(blerr) } }() diff --git a/pkg/fileutil/purge_test.go b/pkg/fileutil/purge_test.go index fe313e50f13..908e5f8db2a 100644 --- a/pkg/fileutil/purge_test.go +++ b/pkg/fileutil/purge_test.go @@ -57,7 +57,7 @@ func TestPurgeFile(t *testing.T) { go func(n int) { f, ferr := os.Create(filepath.Join(dir, fmt.Sprintf("%d.test", n))) if ferr != nil { - t.Fatal(err) + t.Error(err) } f.Close() }(i) diff --git a/pkg/transport/timeout_dialer_test.go b/pkg/transport/timeout_dialer_test.go index c082ca374f4..92589cea5ff 100644 --- a/pkg/transport/timeout_dialer_test.go +++ b/pkg/transport/timeout_dialer_test.go @@ -95,7 +95,7 @@ func (ts *testBlockingServer) Start(t *testing.T) { for i := 0; i < ts.n; i++ { conn, err := ts.ln.Accept() if err != nil { - t.Fatal(err) + t.Error(err) } defer conn.Close() } diff --git a/pkg/transport/timeout_listener_test.go b/pkg/transport/timeout_listener_test.go index be2495d47b2..fe09fe31e1a 100644 --- a/pkg/transport/timeout_listener_test.go +++ b/pkg/transport/timeout_listener_test.go @@ -52,7 +52,7 @@ func TestWriteReadTimeoutListener(t *testing.T) { blocker := func() { conn, derr := net.Dial("tcp", ln.Addr().String()) if derr != nil { - t.Fatalf("unexpected dail error: %v", derr) + t.Errorf("unexpected dail error: %v", derr) } defer conn.Close() // block the receiver until the writer timeout diff --git a/pkg/transport/transport_test.go b/pkg/transport/transport_test.go index 33f3a266390..afd325da4f6 100644 --- a/pkg/transport/transport_test.go +++ b/pkg/transport/transport_test.go @@ -59,12 +59,12 @@ func TestNewTransportTLSInvalidCipherSuitesTLS12(t *testing.T) { tr, err := NewTransport(cliTLS, 3*time.Second) tr.TLSClientConfig.MaxVersion = tls.VersionTLS12 if err != nil { - t.Fatalf("unexpected NewTransport error: %v", err) + t.Errorf("unexpected NewTransport error: %v", err) } cli := &http.Client{Transport: tr} _, gerr := cli.Get("https://" + ln.Addr().String()) if gerr == nil || !strings.Contains(gerr.Error(), "tls: handshake failure") { - t.Fatal("expected client TLS handshake error") + t.Error("expected client TLS handshake error") } ln.Close() donec <- struct{}{} diff --git a/test b/test index a782abd3fcb..95c40ae1e2e 100755 --- a/test +++ b/test @@ -99,9 +99,8 @@ if [ "${VERBOSE}" == "1" ]; then echo "Running with TEST:" "${TEST[@]}" fi -# TODO: 'client' pkg fails with gosimple from generated files # TODO: 'rafttest' is failing with unused -STATIC_ANALYSIS_PATHS=$(find . -name \*.go ! -path './vendor/*' ! -path './gopath.proto/*' ! -path '*pb/*' | while read -r a; do dirname "$a"; done | sort | uniq | grep -vE "$IGNORE_PKGS" | grep -v 'client') +STATIC_ANALYSIS_PATHS=$(find . -name \*.go ! -path './vendor/*' ! -path './gopath.proto/*' ! -path '*pb/*' | while read -r a; do dirname "$a"; done | sort | uniq | grep -vE "$IGNORE_PKGS") # shellcheck disable=SC2206 STATIC_ANALYSIS_PATHS=($STATIC_ANALYSIS_PATHS) if [ "${VERBOSE}" == "1" ]; then @@ -459,30 +458,6 @@ function govet_shadow_pass { fi } -function gosimple_pass { - if command -v gosimple >/dev/null; then - gosimpleResult=$(gosimple "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true) - if [ -n "${gosimpleResult}" ]; then - echo -e "gosimple checking failed:\\n${gosimpleResult}" - exit 255 - fi - else - echo "Skipping gosimple..." - fi -} - -function unused_pass { - if command -v unused >/dev/null; then - unusedResult=$(unused "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true) - if [ -n "${unusedResult}" ]; then - echo -e "unused checking failed:\\n${unusedResult}" - exit 255 - fi - else - echo "Skipping unused..." - fi -} - function unparam_pass { if command -v unparam >/dev/null; then unparamResult=$(unparam "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true) @@ -501,7 +476,7 @@ function staticcheck_pass { if [ -n "${staticcheckResult}" ]; then # TODO: resolve these after go1.8 migration # See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck - STATIC_CHECK_MASK="SA(1012|1019|2002)" + STATIC_CHECK_MASK="S(A|T)(1002|1005|1006|1008|1012|1019|1032|2002|4003|4006)" if echo "${staticcheckResult}" | grep -vE "$STATIC_CHECK_MASK"; then echo -e "staticcheck checking failed:\\n${staticcheckResult}" exit 255 diff --git a/tests/Dockerfile b/tests/Dockerfile index 3012dd6be7d..d21c50204f0 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -49,8 +49,6 @@ RUN go get -v -u -tags spell github.com/chzchzchz/goword \ && go get -v -u github.com/mgechev/revive \ && go get -v -u github.com/mdempsky/unconvert \ && go get -v -u mvdan.cc/unparam \ - && go get -v -u honnef.co/go/tools/cmd/gosimple \ - && go get -v -u honnef.co/go/tools/cmd/unused \ && go get -v -u honnef.co/go/tools/cmd/staticcheck \ && go get -v -u github.com/gyuho/gocovmerge \ && go get -v -u github.com/gordonklaus/ineffassign \ diff --git a/tests/e2e/ctl_v3_auth_test.go b/tests/e2e/ctl_v3_auth_test.go index 808165c1ce8..2142394cb84 100644 --- a/tests/e2e/ctl_v3_auth_test.go +++ b/tests/e2e/ctl_v3_auth_test.go @@ -859,7 +859,7 @@ func authTestWatch(cx ctlCtx) { defer close(donec) for j := range puts { if err := ctlV3Put(cx, puts[j].key, puts[j].val, ""); err != nil { - cx.t.Fatalf("watchTest #%d-%d: ctlV3Put error (%v)", i, j, err) + cx.t.Errorf("watchTest #%d-%d: ctlV3Put error (%v)", i, j, err) } } }(i, tt.puts) diff --git a/tests/e2e/ctl_v3_watch_no_cov_test.go b/tests/e2e/ctl_v3_watch_no_cov_test.go index 6dffeee3f14..1778ecd37eb 100644 --- a/tests/e2e/ctl_v3_watch_no_cov_test.go +++ b/tests/e2e/ctl_v3_watch_no_cov_test.go @@ -133,7 +133,7 @@ func watchTest(cx ctlCtx) { go func(i int, puts []kv) { for j := range puts { if err := ctlV3Put(cx, puts[j].key, puts[j].val, ""); err != nil { - cx.t.Fatalf("watchTest #%d-%d: ctlV3Put error (%v)", i, j, err) + cx.t.Errorf("watchTest #%d-%d: ctlV3Put error (%v)", i, j, err) } } close(donec) diff --git a/tests/e2e/etcd_release_upgrade_test.go b/tests/e2e/etcd_release_upgrade_test.go index 6a8e5b13ac6..0ebdbf1e174 100644 --- a/tests/e2e/etcd_release_upgrade_test.go +++ b/tests/e2e/etcd_release_upgrade_test.go @@ -168,7 +168,7 @@ func TestReleaseUpgradeWithRestart(t *testing.T) { epc.procs[i].Config().execPath = binDir + "/etcd" epc.procs[i].Config().keepDataDir = true if err := epc.procs[i].Restart(); err != nil { - t.Fatalf("error restarting etcd process (%v)", err) + t.Errorf("error restarting etcd process (%v)", err) } wg.Done() }(i)