From c43e4cffafc1d6669665e80e73eccd67f6535c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Sat, 29 Apr 2017 03:04:42 +0200 Subject: [PATCH] Collect "processes" to kill in openshiftCluster instead of named members MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t really need to differentiate between the master/registry, we just want to terminate them, maybe in the right order. So, collect them in an array instead of using separate members. This will make it easier to have more registry instances in the near future. Signed-off-by: Miloslav Trmač --- integration/openshift.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/integration/openshift.go b/integration/openshift.go index 0f89f061..48da88f3 100644 --- a/integration/openshift.go +++ b/integration/openshift.go @@ -22,8 +22,7 @@ var adminKUBECONFIG = map[string]string{ // running on localhost. type openshiftCluster struct { workingDir string - master *exec.Cmd - registry *exec.Cmd + processes []*exec.Cmd // Processes to terminate on teardown; append to the end, terminate from end to the start. } // startOpenshiftCluster creates a new openshiftCluster. @@ -59,13 +58,14 @@ func (cluster *openshiftCluster) clusterCmd(env map[string]string, name string, // startMaster starts the OpenShift master (etcd+API server) and waits for it to be ready, or terminates on failure. func (cluster *openshiftCluster) startMaster(c *check.C) { - cluster.master = cluster.clusterCmd(nil, "openshift", "start", "master") - stdout, err := cluster.master.StdoutPipe() + cmd := cluster.clusterCmd(nil, "openshift", "start", "master") + cluster.processes = append(cluster.processes, cmd) + stdout, err := cmd.StdoutPipe() // Send both to the same pipe. This might cause the two streams to be mixed up, // but logging actually goes only to stderr - this primarily ensure we log any // unexpected output to stdout. - cluster.master.Stderr = cluster.master.Stdout - err = cluster.master.Start() + cmd.Stderr = cmd.Stdout + err = cmd.Start() c.Assert(err, check.IsNil) portOpen, terminatePortCheck := newPortChecker(c, 8443) @@ -172,7 +172,7 @@ func (cluster *openshiftCluster) startRegistryProcess(c *check.C, port int, conf // startRegistry starts the OpenShift registry and waits for it to be ready, or terminates on failure. func (cluster *openshiftCluster) startRegistry(c *check.C) { - cluster.registry = cluster.startRegistryProcess(c, 5000, "/atomic-registry-config.yml") + cluster.processes = append(cluster.processes, cluster.startRegistryProcess(c, 5000, "/atomic-registry-config.yml")) } // ocLogin runs (oc login) and (oc new-project) on the cluster, or terminates on failure. @@ -221,11 +221,8 @@ func (cluster *openshiftCluster) relaxImageSignerPermissions(c *check.C) { // tearDown stops the cluster services and deletes (only some!) of the state. func (cluster *openshiftCluster) tearDown(c *check.C) { - if cluster.registry != nil && cluster.registry.Process != nil { - cluster.registry.Process.Kill() - } - if cluster.master != nil && cluster.master.Process != nil { - cluster.master.Process.Kill() + for i := len(cluster.processes) - 1; i >= 0; i-- { + cluster.processes[i].Process.Kill() } if cluster.workingDir != "" { os.RemoveAll(cluster.workingDir)