Skip to content

Commit

Permalink
fix: TestMemberPromote
Browse files Browse the repository at this point in the history
Signed-off-by: Clement <[email protected]>
  • Loading branch information
clement2026 committed Sep 13, 2024
1 parent 981061a commit 9627f5c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/framework/integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1693,5 +1693,30 @@ 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)

// Override PeerURLs and PeerListeners set by mustNewMember
urls := types.MustNewURLs(resp.Member.PeerURLs)
m.PeerURLs = urls

var listeners []net.Listener
for _, url := range urls {
var l net.Listener
var err error
switch url.Scheme {
case "http", "https":
l, err = net.Listen("tcp", url.Host)
case "unix", "unixs":
l, err = net.Listen("unix", url.Host)
default:
err = fmt.Errorf("unsupported scheme: %s", url.Scheme)
}

if err != nil {
t.Fatal("failed to listen on %v: %v", url, err)
}
listeners = append(listeners, l)
}
m.PeerListeners = listeners

return m
}

0 comments on commit 9627f5c

Please sign in to comment.