mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #1448 from bcwaldon/member-URLs
fix usage of copy in newMemberCollection
This commit is contained in:
commit
87327a245d
@ -541,8 +541,8 @@ func newMemberCollection(ms []*etcdserver.Member) httptypes.MemberCollection {
|
||||
ClientURLs: make([]string, len(m.ClientURLs)),
|
||||
}
|
||||
|
||||
copy(m.PeerURLs, tm.PeerURLs)
|
||||
copy(m.ClientURLs, tm.ClientURLs)
|
||||
copy(tm.PeerURLs, m.PeerURLs)
|
||||
copy(tm.ClientURLs, m.ClientURLs)
|
||||
|
||||
c[i] = tm
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import (
|
||||
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/jonboulle/clockwork"
|
||||
etcdErr "github.com/coreos/etcd/error"
|
||||
"github.com/coreos/etcd/etcdserver"
|
||||
"github.com/coreos/etcd/etcdserver/etcdhttp/httptypes"
|
||||
"github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/store"
|
||||
@ -561,7 +562,7 @@ func TestServeAdminMembers(t *testing.T) {
|
||||
clusterInfo: cluster,
|
||||
}
|
||||
|
||||
wmc := string(`[{"id":"c","name":"","peerURLs":[],"clientURLs":[""]},{"id":"d","name":"","peerURLs":[],"clientURLs":[""]}]`)
|
||||
wmc := string(`[{"id":"c","name":"","peerURLs":[],"clientURLs":["http://localhost:8080"]},{"id":"d","name":"","peerURLs":[],"clientURLs":["http://localhost:8081"]}]`)
|
||||
|
||||
tests := []struct {
|
||||
path string
|
||||
@ -1564,3 +1565,36 @@ func TestTrimPrefix(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewMemberCollection(t *testing.T) {
|
||||
fixture := []*etcdserver.Member{
|
||||
&etcdserver.Member{
|
||||
ID: 12,
|
||||
Attributes: etcdserver.Attributes{ClientURLs: []string{"http://localhost:8080", "http://localhost:8081"}},
|
||||
RaftAttributes: etcdserver.RaftAttributes{PeerURLs: []string{"http://localhost:8082", "http://localhost:8083"}},
|
||||
},
|
||||
&etcdserver.Member{
|
||||
ID: 13,
|
||||
Attributes: etcdserver.Attributes{ClientURLs: []string{"http://localhost:9090", "http://localhost:9091"}},
|
||||
RaftAttributes: etcdserver.RaftAttributes{PeerURLs: []string{"http://localhost:9092", "http://localhost:9093"}},
|
||||
},
|
||||
}
|
||||
got := newMemberCollection(fixture)
|
||||
|
||||
want := httptypes.MemberCollection([]httptypes.Member{
|
||||
httptypes.Member{
|
||||
ID: "c",
|
||||
ClientURLs: []string{"http://localhost:8080", "http://localhost:8081"},
|
||||
PeerURLs: []string{"http://localhost:8082", "http://localhost:8083"},
|
||||
},
|
||||
httptypes.Member{
|
||||
ID: "d",
|
||||
ClientURLs: []string{"http://localhost:9090", "http://localhost:9091"},
|
||||
PeerURLs: []string{"http://localhost:9092", "http://localhost:9093"},
|
||||
},
|
||||
})
|
||||
|
||||
if !reflect.DeepEqual(want, got) {
|
||||
t.Fatalf("newMemberCollection failure: want=%#v, got=%#v", want, got)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user