Browse Source

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.
Gyu-Ho Lee 9 years ago
parent
commit
311c19e494
2 changed files with 19 additions and 6 deletions
  1. 1 0
      e2e/etcd_release_upgrade_test.go
  2. 18 6
      e2e/etcd_test.go

+ 1 - 0
e2e/etcd_release_upgrade_test.go

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

+ 18 - 6
e2e/etcd_test.go

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