Split a startRegistryProcess from openshiftCluster.startRegistry

The helper will be reused in the future.  For now, this does not change
behavior.
This commit is contained in:
Miloslav Trmač
2017-04-19 22:33:05 +02:00
parent 1f1f6801bb
commit 4f199f86f7

View File

@@ -150,24 +150,30 @@ func (c *openshiftCluster) prepareRegistryConfig() {
c.c.Assert(string(out), check.Equals, "") c.c.Assert(string(out), check.Equals, "")
} }
// startRegistry starts the OpenShift registry and waits for it to be ready, or terminates on failure. // startRegistry starts the OpenShift registry with configPart on port, waits for it to be ready, and returns the process object, or terminates on failure.
func (c *openshiftCluster) startRegistry() { func (c *openshiftCluster) startRegistryProcess(port int, configPath string) *exec.Cmd {
//KUBECONFIG=openshift.local.registry/openshift-registry.kubeconfig DOCKER_REGISTRY_URL=127.0.0.1:5000 cmd := c.clusterCmd(map[string]string{
c.registry = c.clusterCmd(map[string]string{
"KUBECONFIG": "openshift.local.registry/openshift-registry.kubeconfig", "KUBECONFIG": "openshift.local.registry/openshift-registry.kubeconfig",
"DOCKER_REGISTRY_URL": "127.0.0.1:5000", "DOCKER_REGISTRY_URL": fmt.Sprintf("127.0.0.1:%d", port),
}, "dockerregistry", "/atomic-registry-config.yml") }, "dockerregistry", configPath)
consumeAndLogOutputs(c.c, "registry", c.registry) consumeAndLogOutputs(c.c, fmt.Sprintf("registry-%d", port), cmd)
err := c.registry.Start() err := cmd.Start()
c.c.Assert(err, check.IsNil) c.c.Assert(err, check.IsNil)
portOpen, terminatePortCheck := newPortChecker(c.c, 5000) portOpen, terminatePortCheck := newPortChecker(c.c, port)
defer func() { defer func() {
terminatePortCheck <- true terminatePortCheck <- true
}() }()
c.c.Logf("Waiting for registry to start") c.c.Logf("Waiting for registry to start")
<-portOpen <-portOpen
c.c.Logf("OK, Registry port open") c.c.Logf("OK, Registry port open")
return cmd
}
// startRegistry starts the OpenShift registry and waits for it to be ready, or terminates on failure.
func (c *openshiftCluster) startRegistry() {
c.registry = c.startRegistryProcess(5000, "/atomic-registry-config.yml")
} }
// ocLogin runs (oc login) and (oc new-project) on the cluster, or terminates on failure. // ocLogin runs (oc login) and (oc new-project) on the cluster, or terminates on failure.