Skip to content

Commit

Permalink
Merge d975a1e into 981061a
Browse files Browse the repository at this point in the history
  • Loading branch information
clement2026 authored Sep 13, 2024
2 parents 981061a + d975a1e commit c381070
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion tests/framework/integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,8 @@ func (p SortableProtoMemberSliceByPeerURLs) Less(i, j int) bool {
func (p SortableProtoMemberSliceByPeerURLs) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

// MustNewMember creates a new member instance based on the response of V3 Member Add API.
func (c *Cluster) MustNewMember(t testutil.TB, resp *clientv3.MemberAddResponse) *Member {
// Pass nil for tlsinfo if the member's PeerURLs don't use HTTPS.
func (c *Cluster) MustNewMember(t testutil.TB, resp *clientv3.MemberAddResponse, tlsinfo *transport.TLSInfo) *Member {
m := c.mustNewMember(t)
m.IsLearner = resp.Member.IsLearner
m.NewCluster = false
Expand All @@ -1693,5 +1694,20 @@ func (c *Cluster) MustNewMember(t testutil.TB, resp *clientv3.MemberAddResponse)
}
m.InitialPeerURLsMap[m.Name] = types.MustNewURLs(resp.Member.PeerURLs)
c.Members = append(c.Members, m)

// c.mustNewMember(t) creates a new member without using resp.Member.PeerURLs.
// We should override PeerURLs and PeerListeners set by mustNewMember.
urls := types.MustNewURLs(resp.Member.PeerURLs)
m.PeerURLs = urls
var listeners []net.Listener
for _, url := range urls {
l, err := transport.NewListener(url.Host, url.Scheme, tlsinfo)
if err != nil {
t.Fatal("failed to listen on %v: %v", url, err)
}
listeners = append(listeners, l)
}
m.PeerListeners = listeners

return m
}
2 changes: 1 addition & 1 deletion tests/integration/clientv3/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func TestMemberPromote(t *testing.T) {

// create and launch learner member based on the response of V3 Member Add API.
// (the response has information on peer urls of the existing members in cluster)
learnerMember := clus.MustNewMember(t, memberAddResp)
learnerMember := clus.MustNewMember(t, memberAddResp, nil)

if err = learnerMember.Launch(); err != nil {
t.Fatal(err)
Expand Down

0 comments on commit c381070

Please sign in to comment.