integration: decrease timeout for isMemberBootstrapped
Spending seconds(!) when it would fail anyway. integration/TestV3 (before): 100.670 integration/TestV3 (after): 29.571
This commit is contained in:
@ -29,8 +29,8 @@ import (
|
|||||||
|
|
||||||
// isMemberBootstrapped tries to check if the given member has been bootstrapped
|
// isMemberBootstrapped tries to check if the given member has been bootstrapped
|
||||||
// in the given cluster.
|
// in the given cluster.
|
||||||
func isMemberBootstrapped(cl *cluster, member string, rt http.RoundTripper) bool {
|
func isMemberBootstrapped(cl *cluster, member string, rt http.RoundTripper, timeout time.Duration) bool {
|
||||||
rcl, err := getClusterFromRemotePeers(getRemotePeerURLs(cl, member), time.Second, false, rt)
|
rcl, err := getClusterFromRemotePeers(getRemotePeerURLs(cl, member), timeout, false, rt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ type ServerConfig struct {
|
|||||||
|
|
||||||
TickMs uint
|
TickMs uint
|
||||||
ElectionTicks int
|
ElectionTicks int
|
||||||
|
BootstrapTimeout time.Duration
|
||||||
|
|
||||||
V3demo bool
|
V3demo bool
|
||||||
|
|
||||||
@ -181,3 +182,10 @@ func checkDuplicateURL(urlsmap types.URLsMap) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ServerConfig) bootstrapTimeout() time.Duration {
|
||||||
|
if c.BootstrapTimeout != 0 {
|
||||||
|
return c.BootstrapTimeout
|
||||||
|
}
|
||||||
|
return time.Second
|
||||||
|
}
|
||||||
|
@ -269,7 +269,7 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m := cl.MemberByName(cfg.Name)
|
m := cl.MemberByName(cfg.Name)
|
||||||
if isMemberBootstrapped(cl, cfg.Name, prt) {
|
if isMemberBootstrapped(cl, cfg.Name, prt, cfg.bootstrapTimeout()) {
|
||||||
return nil, fmt.Errorf("member %s has already been bootstrapped", m.ID)
|
return nil, fmt.Errorf("member %s has already been bootstrapped", m.ID)
|
||||||
}
|
}
|
||||||
if cfg.ShouldDiscover() {
|
if cfg.ShouldDiscover() {
|
||||||
|
@ -422,6 +422,7 @@ func mustNewMember(t *testing.T, name string, peerTLS *transport.TLSInfo, client
|
|||||||
}
|
}
|
||||||
m.InitialClusterToken = clusterName
|
m.InitialClusterToken = clusterName
|
||||||
m.NewCluster = true
|
m.NewCluster = true
|
||||||
|
m.BootstrapTimeout = 10 * time.Millisecond
|
||||||
if m.PeerTLSInfo != nil {
|
if m.PeerTLSInfo != nil {
|
||||||
m.ServerConfig.PeerTLSInfo = *m.PeerTLSInfo
|
m.ServerConfig.PeerTLSInfo = *m.PeerTLSInfo
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user