Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix MustNewMember #18584

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

// 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 {
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)
}
clement2026 marked this conversation as resolved.
Show resolved Hide resolved
m.PeerListeners = listeners

return m
}
Loading