From 896cba5cb9788dfaff0357992b3e60b62bc4e021 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 18 Mar 2016 18:44:40 -0700 Subject: [PATCH 1/6] README: go1.5 for Go development --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4b5911bd..3c01677ca 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Or feel free to just use `curl`, as in the examples below. The easiest way to get etcd is to use one of the pre-built release binaries which are available for OSX, Linux, Windows, AppC (ACI), and Docker. Instructions for using these binaries are on the [GitHub releases page][github-release]. For those wanting to try the very latest version, you can build the latest version of etcd from the `master` branch. -You will first need [*Go*](https://golang.org/) installed on your machine (version 1.4+ is required). +You will first need [*Go*](https://golang.org/) installed on your machine (version 1.5+ is required). All development occurs on `master`, including new features and bug fixes. Bug fixes are first targeted at `master` and subsequently ported to release branches, as described in the [branch management][branch-management] guide. From 25e47db4163505461ee51242d31342dcfe063405 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 18 Mar 2016 18:44:56 -0700 Subject: [PATCH 2/6] client: drop go1.4 tests --- client/cancelreq.go | 2 -- client/cancelreq_go14.go | 17 ------------- client/fake_transport_go14_test.go | 41 ------------------------------ client/fake_transport_test.go | 2 -- 4 files changed, 62 deletions(-) delete mode 100644 client/cancelreq_go14.go delete mode 100644 client/fake_transport_go14_test.go diff --git a/client/cancelreq.go b/client/cancelreq.go index fefdb40e4..76d1f0401 100644 --- a/client/cancelreq.go +++ b/client/cancelreq.go @@ -4,8 +4,6 @@ // borrowed from golang/net/context/ctxhttp/cancelreq.go -// +build go1.5 - package client import "net/http" diff --git a/client/cancelreq_go14.go b/client/cancelreq_go14.go deleted file mode 100644 index 2bed38a41..000000000 --- a/client/cancelreq_go14.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// borrowed from golang/net/context/ctxhttp/cancelreq_go14.go - -// +build !go1.5 - -package client - -import "net/http" - -func requestCanceler(tr CancelableTransport, req *http.Request) func() { - return func() { - tr.CancelRequest(req) - } -} diff --git a/client/fake_transport_go14_test.go b/client/fake_transport_go14_test.go deleted file mode 100644 index 4a99a7d37..000000000 --- a/client/fake_transport_go14_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// 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. - -// +build !go1.5 - -package client - -import ( - "errors" - "net/http" -) - -func (t *fakeTransport) RoundTrip(req *http.Request) (*http.Response, error) { - select { - case resp := <-t.respchan: - return resp, nil - case err := <-t.errchan: - return nil, err - case <-t.startCancel: - select { - // this simulates that the request is finished before cancel effects - case resp := <-t.respchan: - return resp, nil - // wait on finishCancel to simulate taking some amount of - // time while calling CancelRequest - case <-t.finishCancel: - return nil, errors.New("cancelled") - } - } -} diff --git a/client/fake_transport_test.go b/client/fake_transport_test.go index 06761e266..7013a119f 100644 --- a/client/fake_transport_test.go +++ b/client/fake_transport_test.go @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build go1.5 - package client import ( From 33e22fa8d7f47d486fb5ca68bb78c5aa16f7e459 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 18 Mar 2016 18:45:12 -0700 Subject: [PATCH 3/6] pkg/httputil: drop go1.4 tests --- pkg/httputil/cancelreq.go | 2 -- pkg/httputil/cancelreq_go14.go | 25 ------------------------- 2 files changed, 27 deletions(-) delete mode 100644 pkg/httputil/cancelreq_go14.go diff --git a/pkg/httputil/cancelreq.go b/pkg/httputil/cancelreq.go index e3a7a7422..ab9fce1ab 100644 --- a/pkg/httputil/cancelreq.go +++ b/pkg/httputil/cancelreq.go @@ -4,8 +4,6 @@ // borrowed from golang/net/context/ctxhttp/cancelreq.go -// +build go1.5 - // Package httputil provides HTTP utility functions. package httputil diff --git a/pkg/httputil/cancelreq_go14.go b/pkg/httputil/cancelreq_go14.go deleted file mode 100644 index b270f9212..000000000 --- a/pkg/httputil/cancelreq_go14.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// borrowed from golang/net/context/ctxhttp/cancelreq_go14.go - -// +build !go1.5 - -package httputil - -import "net/http" - -type requestCanceler interface { - CancelRequest(req *http.Request) -} - -func RequestCanceler(rt http.RoundTripper, req *http.Request) func() { - c, ok := rt.(requestCanceler) - if !ok { - return func() {} - } - return func() { - c.CancelRequest(req) - } -} From 0a82c06a2c5c20566dee9441880ac04f5d3e9019 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 18 Mar 2016 18:45:29 -0700 Subject: [PATCH 4/6] pkg/types: drop go1.4 tests --- pkg/types/urlsmap_go15_test.go | 40 ---------------------------------- pkg/types/urlsmap_test.go | 16 ++++++++++++++ 2 files changed, 16 insertions(+), 40 deletions(-) delete mode 100644 pkg/types/urlsmap_go15_test.go diff --git a/pkg/types/urlsmap_go15_test.go b/pkg/types/urlsmap_go15_test.go deleted file mode 100644 index 1955bb9cb..000000000 --- a/pkg/types/urlsmap_go15_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// 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. - -// +build go1.5 - -package types - -import ( - "reflect" - "testing" - - "github.com/coreos/etcd/pkg/testutil" -) - -// This is only tested in Go1.5+ because Go1.4 doesn't support literal IPv6 address with zone in -// URI (https://github.com/golang/go/issues/6530). -func TestNewURLsMapIPV6(t *testing.T) { - c, err := NewURLsMap("mem1=http://[2001:db8::1]:2380,mem1=http://[fe80::6e40:8ff:feb1:58e4%25en0]:2380,mem2=http://[fe80::92e2:baff:fe7c:3224%25ext0]:2380") - if err != nil { - t.Fatalf("unexpected parse error: %v", err) - } - wc := URLsMap(map[string]URLs{ - "mem1": testutil.MustNewURLs(t, []string{"http://[2001:db8::1]:2380", "http://[fe80::6e40:8ff:feb1:58e4%25en0]:2380"}), - "mem2": testutil.MustNewURLs(t, []string{"http://[fe80::92e2:baff:fe7c:3224%25ext0]:2380"}), - }) - if !reflect.DeepEqual(c, wc) { - t.Errorf("cluster = %#v, want %#v", c, wc) - } -} diff --git a/pkg/types/urlsmap_test.go b/pkg/types/urlsmap_test.go index a01b5efa9..e2ba6a5cd 100644 --- a/pkg/types/urlsmap_test.go +++ b/pkg/types/urlsmap_test.go @@ -97,3 +97,19 @@ func TestParse(t *testing.T) { } } } + +// This is only tested in Go1.5+ because Go1.4 doesn't support literal IPv6 address with zone in +// URI (https://github.com/golang/go/issues/6530). +func TestNewURLsMapIPV6(t *testing.T) { + c, err := NewURLsMap("mem1=http://[2001:db8::1]:2380,mem1=http://[fe80::6e40:8ff:feb1:58e4%25en0]:2380,mem2=http://[fe80::92e2:baff:fe7c:3224%25ext0]:2380") + if err != nil { + t.Fatalf("unexpected parse error: %v", err) + } + wc := URLsMap(map[string]URLs{ + "mem1": testutil.MustNewURLs(t, []string{"http://[2001:db8::1]:2380", "http://[fe80::6e40:8ff:feb1:58e4%25en0]:2380"}), + "mem2": testutil.MustNewURLs(t, []string{"http://[fe80::92e2:baff:fe7c:3224%25ext0]:2380"}), + }) + if !reflect.DeepEqual(c, wc) { + t.Errorf("cluster = %#v, want %#v", c, wc) + } +} From 5bba7731997ae22b27a559187f52d9cca9d10e8e Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 18 Mar 2016 18:45:47 -0700 Subject: [PATCH 5/6] pkg/testutil: drop go1.4 goroutine leak exception --- pkg/testutil/leak.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/pkg/testutil/leak.go b/pkg/testutil/leak.go index 38ef4dc9d..79b8b2db4 100644 --- a/pkg/testutil/leak.go +++ b/pkg/testutil/leak.go @@ -74,12 +74,7 @@ func AfterTest(t *testing.T) { "timeoutHandler": "a TimeoutHandler", "net.(*netFD).connect(": "a timing out dial", ").noteClientGone(": "a closenotifier sender", - } - - // readLoop was buggy before go1.5: - // https://github.com/golang/go/issues/10457 - if getAtLeastGo15() { - badSubstring[").readLoop("] = "a Transport" + ").readLoop(": "a Transport", } var stacks string @@ -126,11 +121,3 @@ func interestingGoroutines() (gs []string) { sort.Strings(gs) return } - -// getAtLeastGo15 returns true if the runtime has go1.5+. -func getAtLeastGo15() bool { - var major, minor int - var discard string - i, err := fmt.Sscanf(runtime.Version(), "go%d.%d%s", &major, &minor, &discard) - return (err == nil && i == 3 && (major > 1 || major == 1 && minor >= 5)) -} From 21b33de81070e4d819bbbbd9a6093dc89d80e75a Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 18 Mar 2016 18:46:11 -0700 Subject: [PATCH 6/6] rafthttp: drop go1.4 tests --- rafthttp/fake_roundtripper_go14_test.go | 35 ------------------------- rafthttp/fake_roundtripper_test.go | 2 -- 2 files changed, 37 deletions(-) delete mode 100644 rafthttp/fake_roundtripper_go14_test.go diff --git a/rafthttp/fake_roundtripper_go14_test.go b/rafthttp/fake_roundtripper_go14_test.go deleted file mode 100644 index ed005a4ca..000000000 --- a/rafthttp/fake_roundtripper_go14_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// 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. - -// +build !go1.5 - -package rafthttp - -import ( - "errors" - "net/http" -) - -func (t *roundTripperBlocker) RoundTrip(req *http.Request) (*http.Response, error) { - c := make(chan struct{}, 1) - t.mu.Lock() - t.cancel[req] = c - t.mu.Unlock() - select { - case <-t.unblockc: - return &http.Response{StatusCode: http.StatusNoContent, Body: &nopReadCloser{}}, nil - case <-c: - return nil, errors.New("request canceled") - } -} diff --git a/rafthttp/fake_roundtripper_test.go b/rafthttp/fake_roundtripper_test.go index 749dca278..99675c435 100644 --- a/rafthttp/fake_roundtripper_test.go +++ b/rafthttp/fake_roundtripper_test.go @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build go1.5 - package rafthttp import (