Skip to content

Commit

Permalink
Merge pull request #10631 from spzala/goruntimeupdate112
Browse files Browse the repository at this point in the history
*: test update for Go 1.12.5 and related changes
  • Loading branch information
gyuho authored Jun 5, 2019
2 parents 25412f9 + 1caaa9e commit aa016ee
Show file tree
Hide file tree
Showing 53 changed files with 126 additions and 195 deletions.
4 changes: 2 additions & 2 deletions auth/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion client/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

Expand Down
1 change: 0 additions & 1 deletion clientv3/balancer/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion clientv3/balancer/grpc1.7-health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion clientv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ type Client struct {

cfg Config
creds *credentials.TransportCredentials
balancer balancer.Balancer
resolverGroup *endpoint.ResolverGroup
mu *sync.RWMutex

Expand Down
2 changes: 1 addition & 1 deletion clientv3/concurrency/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions clientv3/integration/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()

Expand All @@ -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)
}()
Expand Down Expand Up @@ -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{
{
Expand All @@ -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{}{}
}()
Expand Down Expand Up @@ -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{}{}
}()
Expand Down
8 changes: 4 additions & 4 deletions clientv3/integration/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
}()

Expand Down Expand Up @@ -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)
}()
Expand Down Expand Up @@ -767,7 +767,7 @@ func TestV3LeaseFailureOverlap(t *testing.T) {
if err == nil || err == rpctypes.ErrTimeoutDueToConnectionLost {
return
}
t.Fatal(err)
t.Error(err)
}()
}
}
Expand Down
22 changes: 11 additions & 11 deletions clientv3/integration/leasing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
}()
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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{}{}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions clientv3/integration/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()

Expand Down
2 changes: 1 addition & 1 deletion clientv3/integration/mirror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}()
Expand Down
10 changes: 5 additions & 5 deletions clientv3/integration/server_shutdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}()

Expand Down Expand Up @@ -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)
}
}()

Expand Down
10 changes: 5 additions & 5 deletions clientv3/integration/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}()
Expand All @@ -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)
}
}()

Expand Down Expand Up @@ -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{}{}
}()
Expand Down
Loading

0 comments on commit aa016ee

Please sign in to comment.