integration: decrease timeout for isMemberBootstrapped

Spending seconds(!) when it would fail anyway.

integration/TestV3 (before): 100.670
integration/TestV3 (after): 29.571
release-2.3
Anthony Romano 2016-02-02 14:31:50 -08:00
parent 20673e384a
commit 9ae8d85049
4 changed files with 14 additions and 5 deletions

View File

@ -29,8 +29,8 @@ import (
// isMemberBootstrapped tries to check if the given member has been bootstrapped
// in the given cluster.
func isMemberBootstrapped(cl *cluster, member string, rt http.RoundTripper) bool {
rcl, err := getClusterFromRemotePeers(getRemotePeerURLs(cl, member), time.Second, false, rt)
func isMemberBootstrapped(cl *cluster, member string, rt http.RoundTripper, timeout time.Duration) bool {
rcl, err := getClusterFromRemotePeers(getRemotePeerURLs(cl, member), timeout, false, rt)
if err != nil {
return false
}

View File

@ -46,8 +46,9 @@ type ServerConfig struct {
ForceNewCluster bool
PeerTLSInfo transport.TLSInfo
TickMs uint
ElectionTicks int
TickMs uint
ElectionTicks int
BootstrapTimeout time.Duration
V3demo bool
@ -181,3 +182,10 @@ func checkDuplicateURL(urlsmap types.URLsMap) bool {
}
return false
}
func (c *ServerConfig) bootstrapTimeout() time.Duration {
if c.BootstrapTimeout != 0 {
return c.BootstrapTimeout
}
return time.Second
}

View File

@ -269,7 +269,7 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
return nil, err
}
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)
}
if cfg.ShouldDiscover() {

View File

@ -422,6 +422,7 @@ func mustNewMember(t *testing.T, name string, peerTLS *transport.TLSInfo, client
}
m.InitialClusterToken = clusterName
m.NewCluster = true
m.BootstrapTimeout = 10 * time.Millisecond
if m.PeerTLSInfo != nil {
m.ServerConfig.PeerTLSInfo = *m.PeerTLSInfo
}