e2e: use unix port for release tests

Fix https://github.com/coreos/etcd/issues/5947.

When we restart, the previous port could have been still bind
by the OS. Use Unix port to avoid such rebind cases.
This commit is contained in:
Gyu-Ho Lee 2016-08-08 13:45:55 -07:00
parent bb28c9ab00
commit 311c19e494
2 changed files with 19 additions and 6 deletions

View File

@ -37,6 +37,7 @@ func TestReleaseUpgrade(t *testing.T) {
copiedCfg := configNoTLS
copiedCfg.execPath = lastReleaseBinary
copiedCfg.snapCount = 3
copiedCfg.baseScheme = "unix" // to avoid port conflict
epc, err := newEtcdProcessCluster(&copiedCfg)
if err != nil {

View File

@ -131,6 +131,8 @@ type etcdProcessConfig struct {
dataDirPath string
keepDataDir bool
purl url.URL
acurl string
// additional url for tls connection when the etcd process
// serves both http and https
@ -146,8 +148,11 @@ type etcdProcessClusterConfig struct {
keepDataDir bool
clusterSize int
basePort int
proxySize int
baseScheme string
basePort int
proxySize int
snapCount int // default is 10000
@ -217,9 +222,12 @@ func (cfg *etcdProcessClusterConfig) etcdProcessConfigs() []*etcdProcessConfig {
if cfg.clientTLS == clientTLS {
clientScheme = "https"
}
peerScheme := "http"
peerScheme := cfg.baseScheme
if peerScheme == "" {
peerScheme = "http"
}
if cfg.isPeerTLS {
peerScheme = "https"
peerScheme += "s"
}
etcdCfgs := make([]*etcdProcessConfig, cfg.clusterSize+cfg.proxySize)
@ -277,6 +285,7 @@ func (cfg *etcdProcessClusterConfig) etcdProcessConfigs() []*etcdProcessConfig {
args: args,
dataDirPath: dataDirPath,
keepDataDir: cfg.keepDataDir,
purl: purl,
acurl: curl,
acurltls: curltls,
acurlHost: curlHost,
@ -381,14 +390,13 @@ func (epc *etcdProcessCluster) StopAll() (err error) {
if p == nil {
continue
}
if curErr := p.proc.Stop(); curErr != nil {
if curErr := p.Stop(); curErr != nil {
if err != nil {
err = fmt.Errorf("%v; %v", err, curErr)
} else {
err = curErr
}
}
<-p.donec
}
return err
}
@ -423,6 +431,10 @@ func (ep *etcdProcess) Stop() error {
return err
}
<-ep.donec
if ep.cfg.purl.Scheme == "unix" || ep.cfg.purl.Scheme == "unixs" {
os.RemoveAll(ep.cfg.purl.Host)
}
return nil
}