From d9ad6aa2a9f93a6fd6cbd7c86c5a61e49a6f7f80 Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Mon, 6 Apr 2015 08:38:13 -0700 Subject: [PATCH] *: update to use IANA-assigned ports --- README.md | 8 +-- client/client.go | 4 +- client/client_test.go | 8 +-- client/doc.go | 2 +- client/members_test.go | 16 ++--- discovery/srv_test.go | 8 +-- etcdctl/README.md | 2 +- etcdctl/main.go | 2 +- etcdmain/config_test.go | 12 ++-- etcdmain/etcd_test.go | 4 +- etcdserver/cluster_test.go | 4 +- etcdserver/config_test.go | 8 +-- etcdserver/etcdhttp/httptypes/member_test.go | 16 ++--- etcdserver/server_test.go | 4 +- pkg/flags/flag_test.go | 16 ++--- pkg/flags/ipaddressport_test.go | 6 +- pkg/flags/urls.go | 2 +- pkg/flags/urls_test.go | 2 +- pkg/netutil/netutil_test.go | 56 ++++++++-------- pkg/types/urls_test.go | 70 ++++++++++---------- proxy/reverse_test.go | 2 +- rafthttp/http_test.go | 4 +- rafthttp/pipeline_test.go | 22 +++--- rafthttp/stream_test.go | 6 +- rafthttp/transport_test.go | 12 ++-- 25 files changed, 148 insertions(+), 148 deletions(-) diff --git a/README.md b/README.md index 6afdffc1a..2f83c9878 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ First start a single-member cluster of etcd: ./bin/etcd ``` -This will bring up etcd listening on port 4001 for client communication and on port 7001 for server-to-server communication. +This will bring up etcd listening on port 2379 for client communication and on port 2380 for server-to-server communication. Next, let's set a single key, and then retrieve it: ``` -curl -L http://127.0.0.1:4001/v2/keys/mykey -XPUT -d value="this is awesome" -curl -L http://127.0.0.1:4001/v2/keys/mykey +curl -L http://127.0.0.1:2379/v2/keys/mykey -XPUT -d value="this is awesome" +curl -L http://127.0.0.1:2379/v2/keys/mykey ``` You have successfully started an etcd and written a key to the store. @@ -112,7 +112,7 @@ New minor versions may add additional features to the API. You can get the version of etcd by issuing a request to /version: ```sh -curl -L http://127.0.0.1:4001/version +curl -L http://127.0.0.1:2379/version ``` #### API Versioning diff --git a/client/client.go b/client/client.go index 79f35ae11..128e25069 100644 --- a/client/client.go +++ b/client/client.go @@ -50,9 +50,9 @@ type Config struct { // example, a three-node cluster could be provided like so: // // Endpoints: []string{ - // "http://node1.example.com:4001", + // "http://node1.example.com:2379", // "http://node2.example.com:2379", - // "http://node3.example.com:4001", + // "http://node3.example.com:2379", // } // // If multiple endpoints are provided, the Client will attempt to diff --git a/client/client_test.go b/client/client_test.go index 13245baf4..bf2e9b1bb 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -626,12 +626,12 @@ func TestHTTPClusterClientSync(t *testing.T) { }) hc := &httpClusterClient{clientFactory: cf} - err := hc.reset([]string{"http://127.0.0.1:4001"}) + err := hc.reset([]string{"http://127.0.0.1:2379"}) if err != nil { t.Fatalf("unexpected error during setup: %#v", err) } - want := []string{"http://127.0.0.1:4001"} + want := []string{"http://127.0.0.1:2379"} got := hc.Endpoints() if !reflect.DeepEqual(want, got) { t.Fatalf("incorrect endpoints: want=%#v got=%#v", want, got) @@ -666,12 +666,12 @@ func TestHTTPClusterClientSyncFail(t *testing.T) { }) hc := &httpClusterClient{clientFactory: cf} - err := hc.reset([]string{"http://127.0.0.1:4001"}) + err := hc.reset([]string{"http://127.0.0.1:2379"}) if err != nil { t.Fatalf("unexpected error during setup: %#v", err) } - want := []string{"http://127.0.0.1:4001"} + want := []string{"http://127.0.0.1:2379"} got := hc.Endpoints() if !reflect.DeepEqual(want, got) { t.Fatalf("incorrect endpoints: want=%#v got=%#v", want, got) diff --git a/client/doc.go b/client/doc.go index cf3030038..70111cace 100644 --- a/client/doc.go +++ b/client/doc.go @@ -25,7 +25,7 @@ Create a Config and exchange it for a Client: ) cfg := client.Config{ - Endpoints: []string{"http://127.0.0.1:4001"}, + Endpoints: []string{"http://127.0.0.1:2379"}, Transport: DefaultTransport, } diff --git a/client/members_test.go b/client/members_test.go index 6e4ee0167..240b81ead 100644 --- a/client/members_test.go +++ b/client/members_test.go @@ -128,23 +128,23 @@ func TestMemberUnmarshal(t *testing.T) { // both client and peer URLs { - body: []byte(`{"peerURLs": ["http://127.0.0.1:4001"], "clientURLs": ["http://127.0.0.1:4001"]}`), + body: []byte(`{"peerURLs": ["http://127.0.0.1:2379"], "clientURLs": ["http://127.0.0.1:2379"]}`), wantMember: Member{ PeerURLs: []string{ - "http://127.0.0.1:4001", + "http://127.0.0.1:2379", }, ClientURLs: []string{ - "http://127.0.0.1:4001", + "http://127.0.0.1:2379", }, }, }, // multiple peer URLs { - body: []byte(`{"peerURLs": ["http://127.0.0.1:4001", "https://example.com"]}`), + body: []byte(`{"peerURLs": ["http://127.0.0.1:2379", "https://example.com"]}`), wantMember: Member{ PeerURLs: []string{ - "http://127.0.0.1:4001", + "http://127.0.0.1:2379", "https://example.com", }, ClientURLs: nil, @@ -153,11 +153,11 @@ func TestMemberUnmarshal(t *testing.T) { // multiple client URLs { - body: []byte(`{"clientURLs": ["http://127.0.0.1:4001", "https://example.com"]}`), + body: []byte(`{"clientURLs": ["http://127.0.0.1:2379", "https://example.com"]}`), wantMember: Member{ PeerURLs: nil, ClientURLs: []string{ - "http://127.0.0.1:4001", + "http://127.0.0.1:2379", "https://example.com", }, }, @@ -311,7 +311,7 @@ func TestHTTPMembersAPIAddSuccess(t *testing.T) { } func TestHTTPMembersAPIAddError(t *testing.T) { - okPeer := "http://example.com:4001" + okPeer := "http://example.com:2379" tests := []struct { peerURL string client httpClient diff --git a/discovery/srv_test.go b/discovery/srv_test.go index 9699484ef..f523adb7b 100644 --- a/discovery/srv_test.go +++ b/discovery/srv_test.go @@ -55,10 +55,10 @@ func TestSRVGetCluster(t *testing.T) { &net.SRV{Target: "10.0.0.3", Port: 2480}, }, []*net.SRV{ - &net.SRV{Target: "10.0.0.1", Port: 7001}, + &net.SRV{Target: "10.0.0.1", Port: 2380}, }, nil, - "0=https://10.0.0.1:2480,1=https://10.0.0.2:2480,2=https://10.0.0.3:2480,3=http://10.0.0.1:7001", + "0=https://10.0.0.1:2480,1=https://10.0.0.2:2480,2=https://10.0.0.3:2480,3=http://10.0.0.1:2380", }, { []*net.SRV{ @@ -67,10 +67,10 @@ func TestSRVGetCluster(t *testing.T) { &net.SRV{Target: "10.0.0.3", Port: 2480}, }, []*net.SRV{ - &net.SRV{Target: "10.0.0.1", Port: 7001}, + &net.SRV{Target: "10.0.0.1", Port: 2380}, }, []string{"https://10.0.0.1:2480"}, - "dnsClusterTest=https://10.0.0.1:2480,0=https://10.0.0.2:2480,1=https://10.0.0.3:2480,2=http://10.0.0.1:7001", + "dnsClusterTest=https://10.0.0.1:2480,0=https://10.0.0.2:2480,1=https://10.0.0.3:2480,2=http://10.0.0.1:2380", }, } diff --git a/etcdctl/README.md b/etcdctl/README.md index b46178dc9..602906217 100644 --- a/etcdctl/README.md +++ b/etcdctl/README.md @@ -233,7 +233,7 @@ The following exit codes can be returned from etcdctl: ## Peers -If your etcd cluster isn't available on `http://127.0.0.1:4001` you can specify +If your etcd cluster isn't available on `http://127.0.0.1:2379` you can specify a `--peers` flag or `ETCDCTL_PEERS` environment variable. You can list one peer, or a comma-separated list of peers. diff --git a/etcdctl/main.go b/etcdctl/main.go index e5cc08207..04456f293 100644 --- a/etcdctl/main.go +++ b/etcdctl/main.go @@ -31,7 +31,7 @@ func main() { cli.BoolFlag{Name: "debug", Usage: "output cURL commands which can be used to reproduce the request"}, cli.BoolFlag{Name: "no-sync", Usage: "don't synchronize cluster information before sending request"}, cli.StringFlag{Name: "output, o", Value: "simple", Usage: "output response in the given format (`simple` or `json`)"}, - cli.StringFlag{Name: "peers, C", Value: "", Usage: "a comma-delimited list of machine addresses in the cluster (default: \"127.0.0.1:4001\")"}, + cli.StringFlag{Name: "peers, C", Value: "", Usage: "a comma-delimited list of machine addresses in the cluster (default: \"127.0.0.1:4001,127.0.0.1:2379\")"}, cli.StringFlag{Name: "cert-file", Value: "", Usage: "identify HTTPS client using this SSL certificate file"}, cli.StringFlag{Name: "key-file", Value: "", Usage: "identify HTTPS client using this SSL key file"}, cli.StringFlag{Name: "ca-file", Value: "", Usage: "verify certificates of HTTPS-enabled servers using this CA bundle"}, diff --git a/etcdmain/config_test.go b/etcdmain/config_test.go index 38c3ebb5f..b729b2de0 100644 --- a/etcdmain/config_test.go +++ b/etcdmain/config_test.go @@ -153,14 +153,14 @@ func TestConfigParsingOtherFlags(t *testing.T) { func TestConfigParsingV1Flags(t *testing.T) { args := []string{ - "-peer-addr=127.0.0.1:7001", - "-addr=127.0.0.1:4001", + "-peer-addr=127.0.0.1:2380", + "-addr=127.0.0.1:2379", } wcfg := NewConfig() - wcfg.lpurls = []url.URL{{Scheme: "http", Host: "[::]:7001"}} - wcfg.apurls = []url.URL{{Scheme: "http", Host: "127.0.0.1:7001"}} - wcfg.lcurls = []url.URL{{Scheme: "http", Host: "[::]:4001"}} - wcfg.acurls = []url.URL{{Scheme: "http", Host: "127.0.0.1:4001"}} + wcfg.lpurls = []url.URL{{Scheme: "http", Host: "[::]:2380"}} + wcfg.apurls = []url.URL{{Scheme: "http", Host: "127.0.0.1:2380"}} + wcfg.lcurls = []url.URL{{Scheme: "http", Host: "[::]:2379"}} + wcfg.acurls = []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}} cfg := NewConfig() if err := cfg.Parse(args); err != nil { diff --git a/etcdmain/etcd_test.go b/etcdmain/etcd_test.go index f48a16079..700b61544 100644 --- a/etcdmain/etcd_test.go +++ b/etcdmain/etcd_test.go @@ -27,8 +27,8 @@ func TestGenClusterString(t *testing.T) { wstr string }{ { - "default", []string{"http://127.0.0.1:4001"}, - "default=http://127.0.0.1:4001", + "default", []string{"http://127.0.0.1:2379"}, + "default=http://127.0.0.1:2379", }, { "node1", []string{"http://0.0.0.0:2379", "http://1.1.1.1:2379"}, diff --git a/etcdserver/cluster_test.go b/etcdserver/cluster_test.go index 9af9ce175..b223f6bd1 100644 --- a/etcdserver/cluster_test.go +++ b/etcdserver/cluster_test.go @@ -594,7 +594,7 @@ func TestClusterString(t *testing.T) { ), 3: newTestMember( 3, - []string{"http://3.3.3.3:1234", "http://127.0.0.1:7001"}, + []string{"http://3.3.3.3:1234", "http://127.0.0.1:2380"}, "ghi", nil, ), @@ -613,7 +613,7 @@ func TestClusterString(t *testing.T) { ), }, } - w := "abc=http://0.0.0.0:0000,abc=http://1.1.1.1:1111,def=http://2.2.2.2:2222,ghi=http://127.0.0.1:7001,ghi=http://3.3.3.3:1234" + w := "abc=http://0.0.0.0:0000,abc=http://1.1.1.1:1111,def=http://2.2.2.2:2222,ghi=http://127.0.0.1:2380,ghi=http://3.3.3.3:1234" if g := cls.String(); g != w { t.Fatalf("Cluster.String():\ngot %#v\nwant %#v", g, w) } diff --git a/etcdserver/config_test.go b/etcdserver/config_test.go index eb301515b..d6bf2f279 100644 --- a/etcdserver/config_test.go +++ b/etcdserver/config_test.go @@ -54,7 +54,7 @@ func TestConfigVerifyExistingWithDiscoveryURLFail(t *testing.T) { } c := &ServerConfig{ Name: "node1", - DiscoveryURL: "http://127.0.0.1:4001/abcdefg", + DiscoveryURL: "http://127.0.0.1:2379/abcdefg", PeerURLs: mustNewURLs(t, []string{"http://127.0.0.1:2380"}), Cluster: cluster, NewCluster: false, @@ -105,7 +105,7 @@ func TestConfigVerifyLocalMember(t *testing.T) { }, { // Advertised peer URLs must match those in cluster-state - "node1=http://localhost:7001,node1=http://localhost:12345", + "node1=http://localhost:2380,node1=http://localhost:12345", []string{"http://localhost:12345"}, true, @@ -113,7 +113,7 @@ func TestConfigVerifyLocalMember(t *testing.T) { }, { // Advertised peer URLs must match those in cluster-state - "node1=http://localhost:7001", + "node1=http://localhost:2380", []string{}, true, @@ -121,7 +121,7 @@ func TestConfigVerifyLocalMember(t *testing.T) { }, { // do not care about the urls if strict is not set - "node1=http://localhost:7001", + "node1=http://localhost:2380", []string{}, false, diff --git a/etcdserver/etcdhttp/httptypes/member_test.go b/etcdserver/etcdhttp/httptypes/member_test.go index e0b29d883..cfff78381 100644 --- a/etcdserver/etcdhttp/httptypes/member_test.go +++ b/etcdserver/etcdhttp/httptypes/member_test.go @@ -37,23 +37,23 @@ func TestMemberUnmarshal(t *testing.T) { // both client and peer URLs { - body: []byte(`{"peerURLs": ["http://127.0.0.1:4001"], "clientURLs": ["http://127.0.0.1:4001"]}`), + body: []byte(`{"peerURLs": ["http://127.0.0.1:2379"], "clientURLs": ["http://127.0.0.1:2379"]}`), wantMember: Member{ PeerURLs: []string{ - "http://127.0.0.1:4001", + "http://127.0.0.1:2379", }, ClientURLs: []string{ - "http://127.0.0.1:4001", + "http://127.0.0.1:2379", }, }, }, // multiple peer URLs { - body: []byte(`{"peerURLs": ["http://127.0.0.1:4001", "https://example.com"]}`), + body: []byte(`{"peerURLs": ["http://127.0.0.1:2379", "https://example.com"]}`), wantMember: Member{ PeerURLs: []string{ - "http://127.0.0.1:4001", + "http://127.0.0.1:2379", "https://example.com", }, ClientURLs: nil, @@ -62,11 +62,11 @@ func TestMemberUnmarshal(t *testing.T) { // multiple client URLs { - body: []byte(`{"clientURLs": ["http://127.0.0.1:4001", "https://example.com"]}`), + body: []byte(`{"clientURLs": ["http://127.0.0.1:2379", "https://example.com"]}`), wantMember: Member{ PeerURLs: nil, ClientURLs: []string{ - "http://127.0.0.1:4001", + "http://127.0.0.1:2379", "https://example.com", }, }, @@ -122,7 +122,7 @@ func TestMemberCreateRequestUnmarshalFail(t *testing.T) { []byte(`{"peerURLs": "foo"}`), []byte(`{"peerURLs": ["."]}`), []byte(`{"peerURLs": []}`), - []byte(`{"peerURLs": ["http://127.0.0.1:4001/foo"]}`), + []byte(`{"peerURLs": ["http://127.0.0.1:2379/foo"]}`), []byte(`{"peerURLs": ["http://127.0.0.1"]}`), } diff --git a/etcdserver/server_test.go b/etcdserver/server_test.go index 130f8ffd0..2059590ef 100644 --- a/etcdserver/server_test.go +++ b/etcdserver/server_test.go @@ -401,10 +401,10 @@ func TestApplyRequestOnAdminMemberAttributes(t *testing.T) { Method: "PUT", ID: 1, Path: path.Join(storeMembersPrefix, strconv.FormatUint(1, 16), attributesSuffix), - Val: `{"Name":"abc","ClientURLs":["http://127.0.0.1:4001"]}`, + Val: `{"Name":"abc","ClientURLs":["http://127.0.0.1:2379"]}`, } srv.applyRequest(req) - w := Attributes{Name: "abc", ClientURLs: []string{"http://127.0.0.1:4001"}} + w := Attributes{Name: "abc", ClientURLs: []string{"http://127.0.0.1:2379"}} if g := cl.Member(1).Attributes; !reflect.DeepEqual(g, w) { t.Errorf("attributes = %v, want %v", g, w) } diff --git a/pkg/flags/flag_test.go b/pkg/flags/flag_test.go index fcc2809f1..3e3ca09c4 100644 --- a/pkg/flags/flag_test.go +++ b/pkg/flags/flag_test.go @@ -93,23 +93,23 @@ func TestSetBindAddrFromAddr(t *testing.T) { }, // addr flag set { - args: []string{"-addr=192.0.3.17:4001"}, - waddr: &IPAddressPort{IP: "::", Port: 4001}, + args: []string{"-addr=192.0.3.17:2379"}, + waddr: &IPAddressPort{IP: "::", Port: 2379}, }, // bindAddr flag set { - args: []string{"-bind-addr=127.0.0.1:4001"}, - waddr: &IPAddressPort{IP: "127.0.0.1", Port: 4001}, + args: []string{"-bind-addr=127.0.0.1:2379"}, + waddr: &IPAddressPort{IP: "127.0.0.1", Port: 2379}, }, // both addr flags set { - args: []string{"-bind-addr=127.0.0.1:4001", "-addr=192.0.3.17:4001"}, - waddr: &IPAddressPort{IP: "127.0.0.1", Port: 4001}, + args: []string{"-bind-addr=127.0.0.1:2379", "-addr=192.0.3.17:2379"}, + waddr: &IPAddressPort{IP: "127.0.0.1", Port: 2379}, }, // both addr flags set, IPv6 { - args: []string{"-bind-addr=[2001:db8::4:9]:4001", "-addr=[2001:db8::4:f0]:4001"}, - waddr: &IPAddressPort{IP: "2001:db8::4:9", Port: 4001}, + args: []string{"-bind-addr=[2001:db8::4:9]:2379", "-addr=[2001:db8::4:f0]:2379"}, + waddr: &IPAddressPort{IP: "2001:db8::4:9", Port: 2379}, }, } for i, tt := range tests { diff --git a/pkg/flags/ipaddressport_test.go b/pkg/flags/ipaddressport_test.go index 139d3759e..68b08e1ed 100644 --- a/pkg/flags/ipaddressport_test.go +++ b/pkg/flags/ipaddressport_test.go @@ -27,7 +27,7 @@ func TestIPAddressPortSet(t *testing.T) { fail := []string{ // bad IP specification - ":4001", + ":2379", "127.0:8080", "123:456", // bad port specification @@ -62,8 +62,8 @@ func TestIPAddressPortSet(t *testing.T) { func TestIPAddressPortString(t *testing.T) { addresses := []string{ - "[2001:db8::1:1234]:4001", - "127.0.0.1:4001", + "[2001:db8::1:1234]:2379", + "127.0.0.1:2379", } for i, tt := range addresses { f := &IPAddressPort{} diff --git a/pkg/flags/urls.go b/pkg/flags/urls.go index 51e2969d4..cf8214553 100644 --- a/pkg/flags/urls.go +++ b/pkg/flags/urls.go @@ -24,7 +24,7 @@ import ( type URLsValue types.URLs // Set parses a command line set of URLs formatted like: -// http://127.0.0.1:7001,http://10.1.1.2:80 +// http://127.0.0.1:2380,http://10.1.1.2:80 func (us *URLsValue) Set(s string) error { strs := strings.Split(s, ",") nus, err := types.NewURLs(strs) diff --git a/pkg/flags/urls_test.go b/pkg/flags/urls_test.go index 677b6b169..8591773e5 100644 --- a/pkg/flags/urls_test.go +++ b/pkg/flags/urls_test.go @@ -21,7 +21,7 @@ import ( func TestValidateURLsValueBad(t *testing.T) { tests := []string{ // bad IP specification - ":4001", + ":2379", "127.0:8080", "123:456", // bad port specification diff --git a/pkg/netutil/netutil_test.go b/pkg/netutil/netutil_test.go index f0a661d49..bfb91aedc 100644 --- a/pkg/netutil/netutil_test.go +++ b/pkg/netutil/netutil_test.go @@ -157,73 +157,73 @@ func TestURLsEqual(t *testing.T) { expect bool }{ { - a: []url.URL{{Scheme: "http", Host: "127.0.0.1:4001"}}, - b: []url.URL{{Scheme: "http", Host: "127.0.0.1:4001"}}, + a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}}, + b: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}}, expect: true, }, { - a: []url.URL{{Scheme: "http", Host: "example.com:4001"}}, - b: []url.URL{{Scheme: "http", Host: "10.0.10.1:4001"}}, + a: []url.URL{{Scheme: "http", Host: "example.com:2379"}}, + b: []url.URL{{Scheme: "http", Host: "10.0.10.1:2379"}}, expect: true, }, { - a: []url.URL{{Scheme: "http", Host: "127.0.0.1:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, - b: []url.URL{{Scheme: "http", Host: "127.0.0.1:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, + a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, + b: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, expect: true, }, { - a: []url.URL{{Scheme: "http", Host: "example.com:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, - b: []url.URL{{Scheme: "http", Host: "example.com:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, + a: []url.URL{{Scheme: "http", Host: "example.com:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, + b: []url.URL{{Scheme: "http", Host: "example.com:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, expect: true, }, { - a: []url.URL{{Scheme: "http", Host: "10.0.10.1:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, - b: []url.URL{{Scheme: "http", Host: "example.com:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, + a: []url.URL{{Scheme: "http", Host: "10.0.10.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, + b: []url.URL{{Scheme: "http", Host: "example.com:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, expect: true, }, { - a: []url.URL{{Scheme: "http", Host: "127.0.0.1:4001"}}, - b: []url.URL{{Scheme: "http", Host: "127.0.0.1:7001"}}, + a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}}, + b: []url.URL{{Scheme: "http", Host: "127.0.0.1:2380"}}, expect: false, }, { - a: []url.URL{{Scheme: "http", Host: "example.com:7001"}}, - b: []url.URL{{Scheme: "http", Host: "10.0.10.1:4001"}}, + a: []url.URL{{Scheme: "http", Host: "example.com:2380"}}, + b: []url.URL{{Scheme: "http", Host: "10.0.10.1:2379"}}, expect: false, }, { - a: []url.URL{{Scheme: "http", Host: "127.0.0.1:4001"}}, - b: []url.URL{{Scheme: "http", Host: "10.0.0.1:4001"}}, + a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}}, + b: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}}, expect: false, }, { - a: []url.URL{{Scheme: "http", Host: "example.com:4001"}}, - b: []url.URL{{Scheme: "http", Host: "10.0.0.1:4001"}}, + a: []url.URL{{Scheme: "http", Host: "example.com:2379"}}, + b: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}}, expect: false, }, { - a: []url.URL{{Scheme: "http", Host: "127.0.0.1:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, - b: []url.URL{{Scheme: "http", Host: "127.0.0.1:7001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, + a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, + b: []url.URL{{Scheme: "http", Host: "127.0.0.1:2380"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, expect: false, }, { - a: []url.URL{{Scheme: "http", Host: "example.com:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, - b: []url.URL{{Scheme: "http", Host: "127.0.0.1:7001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, + a: []url.URL{{Scheme: "http", Host: "example.com:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, + b: []url.URL{{Scheme: "http", Host: "127.0.0.1:2380"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, expect: false, }, { - a: []url.URL{{Scheme: "http", Host: "127.0.0.1:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, - b: []url.URL{{Scheme: "http", Host: "10.0.0.1:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, + a: []url.URL{{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, + b: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, expect: false, }, { - a: []url.URL{{Scheme: "http", Host: "example.com:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, - b: []url.URL{{Scheme: "http", Host: "10.0.0.1:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, + a: []url.URL{{Scheme: "http", Host: "example.com:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, + b: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, expect: false, }, { - a: []url.URL{{Scheme: "http", Host: "10.0.0.1:4001"}}, - b: []url.URL{{Scheme: "http", Host: "10.0.0.1:4001"}, {Scheme: "http", Host: "127.0.0.1:7001"}}, + a: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}}, + b: []url.URL{{Scheme: "http", Host: "10.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2380"}}, expect: false, }, } diff --git a/pkg/types/urls_test.go b/pkg/types/urls_test.go index 41caa5d68..ffa2cf007 100644 --- a/pkg/types/urls_test.go +++ b/pkg/types/urls_test.go @@ -27,23 +27,23 @@ func TestNewURLs(t *testing.T) { wurls URLs }{ { - []string{"http://127.0.0.1:4001"}, - testutil.MustNewURLs(t, []string{"http://127.0.0.1:4001"}), + []string{"http://127.0.0.1:2379"}, + testutil.MustNewURLs(t, []string{"http://127.0.0.1:2379"}), }, // it can trim space { - []string{" http://127.0.0.1:4001 "}, - testutil.MustNewURLs(t, []string{"http://127.0.0.1:4001"}), + []string{" http://127.0.0.1:2379 "}, + testutil.MustNewURLs(t, []string{"http://127.0.0.1:2379"}), }, // it does sort { []string{ - "http://127.0.0.2:4001", - "http://127.0.0.1:4001", + "http://127.0.0.2:2379", + "http://127.0.0.1:2379", }, testutil.MustNewURLs(t, []string{ - "http://127.0.0.1:4001", - "http://127.0.0.2:4001", + "http://127.0.0.1:2379", + "http://127.0.0.2:2379", }), }, } @@ -65,22 +65,22 @@ func TestURLsString(t *testing.T) { "", }, { - testutil.MustNewURLs(t, []string{"http://127.0.0.1:4001"}), - "http://127.0.0.1:4001", + testutil.MustNewURLs(t, []string{"http://127.0.0.1:2379"}), + "http://127.0.0.1:2379", }, { testutil.MustNewURLs(t, []string{ - "http://127.0.0.1:4001", - "http://127.0.0.2:4001", + "http://127.0.0.1:2379", + "http://127.0.0.2:2379", }), - "http://127.0.0.1:4001,http://127.0.0.2:4001", + "http://127.0.0.1:2379,http://127.0.0.2:2379", }, { testutil.MustNewURLs(t, []string{ - "http://127.0.0.2:4001", - "http://127.0.0.1:4001", + "http://127.0.0.2:2379", + "http://127.0.0.1:2379", }), - "http://127.0.0.2:4001,http://127.0.0.1:4001", + "http://127.0.0.2:2379,http://127.0.0.1:2379", }, } for i, tt := range tests { @@ -93,16 +93,16 @@ func TestURLsString(t *testing.T) { func TestURLsSort(t *testing.T) { g := testutil.MustNewURLs(t, []string{ - "http://127.0.0.4:4001", - "http://127.0.0.2:4001", - "http://127.0.0.1:4001", - "http://127.0.0.3:4001", + "http://127.0.0.4:2379", + "http://127.0.0.2:2379", + "http://127.0.0.1:2379", + "http://127.0.0.3:2379", }) w := testutil.MustNewURLs(t, []string{ - "http://127.0.0.1:4001", - "http://127.0.0.2:4001", - "http://127.0.0.3:4001", - "http://127.0.0.4:4001", + "http://127.0.0.1:2379", + "http://127.0.0.2:2379", + "http://127.0.0.3:2379", + "http://127.0.0.4:2379", }) gurls := URLs(g) gurls.Sort() @@ -121,22 +121,22 @@ func TestURLsStringSlice(t *testing.T) { []string{}, }, { - testutil.MustNewURLs(t, []string{"http://127.0.0.1:4001"}), - []string{"http://127.0.0.1:4001"}, + testutil.MustNewURLs(t, []string{"http://127.0.0.1:2379"}), + []string{"http://127.0.0.1:2379"}, }, { testutil.MustNewURLs(t, []string{ - "http://127.0.0.1:4001", - "http://127.0.0.2:4001", + "http://127.0.0.1:2379", + "http://127.0.0.2:2379", }), - []string{"http://127.0.0.1:4001", "http://127.0.0.2:4001"}, + []string{"http://127.0.0.1:2379", "http://127.0.0.2:2379"}, }, { testutil.MustNewURLs(t, []string{ - "http://127.0.0.2:4001", - "http://127.0.0.1:4001", + "http://127.0.0.2:2379", + "http://127.0.0.1:2379", }), - []string{"http://127.0.0.2:4001", "http://127.0.0.1:4001"}, + []string{"http://127.0.0.2:2379", "http://127.0.0.1:2379"}, }, } for i, tt := range tests { @@ -152,13 +152,13 @@ func TestNewURLsFail(t *testing.T) { // no urls given {}, // missing protocol scheme - {"://127.0.0.1:4001"}, + {"://127.0.0.1:2379"}, // unsupported scheme - {"mailto://127.0.0.1:4001"}, + {"mailto://127.0.0.1:2379"}, // not conform to host:port {"http://127.0.0.1"}, // contain a path - {"http://127.0.0.1:4001/path"}, + {"http://127.0.0.1:2379/path"}, } for i, tt := range tests { _, err := NewURLs(tt) diff --git a/proxy/reverse_test.go b/proxy/reverse_test.go index 2ed1843f8..90824a575 100644 --- a/proxy/reverse_test.go +++ b/proxy/reverse_test.go @@ -81,7 +81,7 @@ func TestReverseProxyServe(t *testing.T) { transport: tt.rt, } - req, _ := http.NewRequest("GET", "http://192.0.2.2:4001", nil) + req, _ := http.NewRequest("GET", "http://192.0.2.2:2379", nil) rr := httptest.NewRecorder() rp.ServeHTTP(rr, req) diff --git a/rafthttp/http_test.go b/rafthttp/http_test.go index 95f0a78b4..c5506f072 100644 --- a/rafthttp/http_test.go +++ b/rafthttp/http_test.go @@ -174,7 +174,7 @@ func TestServeRaftStreamPrefix(t *testing.T) { }, } for i, tt := range tests { - req, err := http.NewRequest("GET", "http://localhost:7001"+tt.path, nil) + req, err := http.NewRequest("GET", "http://localhost:2380"+tt.path, nil) if err != nil { t.Fatalf("#%d: could not create request: %#v", i, err) } @@ -281,7 +281,7 @@ func TestServeRaftStreamPrefixBad(t *testing.T) { }, } for i, tt := range tests { - req, err := http.NewRequest(tt.method, "http://localhost:7001"+tt.path, nil) + req, err := http.NewRequest(tt.method, "http://localhost:2380"+tt.path, nil) if err != nil { t.Fatalf("#%d: could not create request: %#v", i, err) } diff --git a/rafthttp/pipeline_test.go b/rafthttp/pipeline_test.go index 5e87f2e0d..8ada077d0 100644 --- a/rafthttp/pipeline_test.go +++ b/rafthttp/pipeline_test.go @@ -31,7 +31,7 @@ import ( // and increase success count in stats. func TestPipelineSend(t *testing.T) { tr := &roundTripperRecorder{} - picker := mustNewURLPicker(t, []string{"http://localhost:7001"}) + picker := mustNewURLPicker(t, []string{"http://localhost:2380"}) fs := &stats.FollowerStats{} p := newPipeline(tr, picker, types.ID(1), types.ID(1), fs, &fakeRaft{}, nil) @@ -50,7 +50,7 @@ func TestPipelineSend(t *testing.T) { func TestPipelineExceedMaximalServing(t *testing.T) { tr := newRoundTripperBlocker() - picker := mustNewURLPicker(t, []string{"http://localhost:7001"}) + picker := mustNewURLPicker(t, []string{"http://localhost:2380"}) fs := &stats.FollowerStats{} p := newPipeline(tr, picker, types.ID(1), types.ID(1), fs, &fakeRaft{}, nil) @@ -90,7 +90,7 @@ func TestPipelineExceedMaximalServing(t *testing.T) { // TestPipelineSendFailed tests that when send func meets the post error, // it increases fail count in stats. func TestPipelineSendFailed(t *testing.T) { - picker := mustNewURLPicker(t, []string{"http://localhost:7001"}) + picker := mustNewURLPicker(t, []string{"http://localhost:2380"}) fs := &stats.FollowerStats{} p := newPipeline(newRespRoundTripper(0, errors.New("blah")), picker, types.ID(1), types.ID(1), fs, &fakeRaft{}, nil) @@ -106,7 +106,7 @@ func TestPipelineSendFailed(t *testing.T) { func TestPipelinePost(t *testing.T) { tr := &roundTripperRecorder{} - picker := mustNewURLPicker(t, []string{"http://localhost:7001"}) + picker := mustNewURLPicker(t, []string{"http://localhost:2380"}) p := newPipeline(tr, picker, types.ID(1), types.ID(1), nil, &fakeRaft{}, nil) if err := p.post([]byte("some data")); err != nil { t.Fatalf("unexpect post error: %v", err) @@ -116,8 +116,8 @@ func TestPipelinePost(t *testing.T) { if g := tr.Request().Method; g != "POST" { t.Errorf("method = %s, want %s", g, "POST") } - if g := tr.Request().URL.String(); g != "http://localhost:7001/raft" { - t.Errorf("url = %s, want %s", g, "http://localhost:7001/raft") + if g := tr.Request().URL.String(); g != "http://localhost:2380/raft" { + t.Errorf("url = %s, want %s", g, "http://localhost:2380/raft") } if g := tr.Request().Header.Get("Content-Type"); g != "application/protobuf" { t.Errorf("content type = %s, want %s", g, "application/protobuf") @@ -141,10 +141,10 @@ func TestPipelinePostBad(t *testing.T) { err error }{ // RoundTrip returns error - {"http://localhost:7001", 0, errors.New("blah")}, + {"http://localhost:2380", 0, errors.New("blah")}, // unexpected response status code - {"http://localhost:7001", http.StatusOK, nil}, - {"http://localhost:7001", http.StatusCreated, nil}, + {"http://localhost:2380", http.StatusOK, nil}, + {"http://localhost:2380", http.StatusCreated, nil}, } for i, tt := range tests { picker := mustNewURLPicker(t, []string{tt.u}) @@ -164,8 +164,8 @@ func TestPipelinePostErrorc(t *testing.T) { code int err error }{ - {"http://localhost:7001", http.StatusForbidden, nil}, - {"http://localhost:7001", http.StatusPreconditionFailed, nil}, + {"http://localhost:2380", http.StatusForbidden, nil}, + {"http://localhost:2380", http.StatusPreconditionFailed, nil}, } for i, tt := range tests { picker := mustNewURLPicker(t, []string{tt.u}) diff --git a/rafthttp/stream_test.go b/rafthttp/stream_test.go index 66fe6fef3..d5d6dd925 100644 --- a/rafthttp/stream_test.go +++ b/rafthttp/stream_test.go @@ -86,7 +86,7 @@ func TestStreamReaderDialRequest(t *testing.T) { tr := &roundTripperRecorder{} sr := &streamReader{ tr: tr, - picker: mustNewURLPicker(t, []string{"http://localhost:7001"}), + picker: mustNewURLPicker(t, []string{"http://localhost:2380"}), t: tt, from: types.ID(1), to: types.ID(2), @@ -96,7 +96,7 @@ func TestStreamReaderDialRequest(t *testing.T) { sr.dial() req := tr.Request() - wurl := fmt.Sprintf("http://localhost:7001" + tt.endpoint() + "/1") + wurl := fmt.Sprintf("http://localhost:2380" + tt.endpoint() + "/1") if req.URL.String() != wurl { t.Errorf("#%d: url = %s, want %s", i, req.URL.String(), wurl) } @@ -133,7 +133,7 @@ func TestStreamReaderDialResult(t *testing.T) { tr := newRespRoundTripper(tt.code, tt.err) sr := &streamReader{ tr: tr, - picker: mustNewURLPicker(t, []string{"http://localhost:7001"}), + picker: mustNewURLPicker(t, []string{"http://localhost:2380"}), t: streamTypeMessage, from: types.ID(1), to: types.ID(2), diff --git a/rafthttp/transport_test.go b/rafthttp/transport_test.go index 34f896357..c56c48b81 100644 --- a/rafthttp/transport_test.go +++ b/rafthttp/transport_test.go @@ -72,7 +72,7 @@ func TestTransportAdd(t *testing.T) { leaderStats: ls, peers: make(map[types.ID]Peer), } - tr.AddPeer(1, []string{"http://localhost:7001"}) + tr.AddPeer(1, []string{"http://localhost:2380"}) defer tr.Stop() if _, ok := ls.Followers["1"]; !ok { @@ -84,7 +84,7 @@ func TestTransportAdd(t *testing.T) { } // duplicate AddPeer is ignored - tr.AddPeer(1, []string{"http://localhost:7001"}) + tr.AddPeer(1, []string{"http://localhost:2380"}) ns := tr.peers[types.ID(1)] if s != ns { t.Errorf("sender = %v, want %v", ns, s) @@ -97,7 +97,7 @@ func TestTransportRemove(t *testing.T) { leaderStats: stats.NewLeaderStats(""), peers: make(map[types.ID]Peer), } - tr.AddPeer(1, []string{"http://localhost:7001"}) + tr.AddPeer(1, []string{"http://localhost:2380"}) tr.RemovePeer(types.ID(1)) defer tr.Stop() @@ -111,9 +111,9 @@ func TestTransportUpdate(t *testing.T) { tr := &transport{ peers: map[types.ID]Peer{types.ID(1): peer}, } - u := "http://localhost:7001" + u := "http://localhost:2380" tr.UpdatePeer(types.ID(1), []string{u}) - wurls := types.URLs(testutil.MustNewURLs(t, []string{"http://localhost:7001"})) + wurls := types.URLs(testutil.MustNewURLs(t, []string{"http://localhost:2380"})) if !reflect.DeepEqual(peer.urls, wurls) { t.Errorf("urls = %+v, want %+v", peer.urls, wurls) } @@ -127,7 +127,7 @@ func TestTransportErrorc(t *testing.T) { peers: make(map[types.ID]Peer), errorc: errorc, } - tr.AddPeer(1, []string{"http://localhost:7001"}) + tr.AddPeer(1, []string{"http://localhost:2380"}) defer tr.Stop() select {