diff --git a/test/e2e/framework/rc_util.go b/test/e2e/framework/rc_util.go index a64a9e943fa..249ae86f742 100644 --- a/test/e2e/framework/rc_util.go +++ b/test/e2e/framework/rc_util.go @@ -21,7 +21,7 @@ import ( "strings" "time" - . "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -124,6 +124,10 @@ func ScaleRCByLabels(clientset clientset.Interface, scalesGetter scaleclient.Sca type updateRcFunc func(d *v1.ReplicationController) +// UpdateReplicationControllerWithRetries retries updating the given rc on conflict with the following steps: +// 1. Get latest resource +// 2. applyUpdate +// 3. Update the resource func UpdateReplicationControllerWithRetries(c clientset.Interface, namespace, name string, applyUpdate updateRcFunc) (*v1.ReplicationController, error) { var rc *v1.ReplicationController var updateErr error @@ -152,12 +156,15 @@ func DeleteRCAndWaitForGC(c clientset.Interface, ns, name string) error { return DeleteResourceAndWaitForGC(c, api.Kind("ReplicationController"), ns, name) } +// ScaleRC scales Replication Controller to be desired size. func ScaleRC(clientset clientset.Interface, scalesGetter scaleclient.ScalesGetter, ns, name string, size uint, wait bool) error { return ScaleResource(clientset, scalesGetter, ns, name, size, wait, api.Kind("ReplicationController"), api.Resource("replicationcontrollers")) } +// RunRC Launches (and verifies correctness) of a Replication Controller +// and will wait for all pods it spawns to become "Running". func RunRC(config testutils.RCConfig) error { - By(fmt.Sprintf("creating replication controller %s in namespace %s", config.Name, config.Namespace)) + ginkgo.By(fmt.Sprintf("creating replication controller %s in namespace %s", config.Name, config.Namespace)) config.NodeDumpFunc = DumpNodeDebugInfo config.ContainerDumpFunc = LogFailedContainers return testutils.RunRC(config) @@ -180,10 +187,9 @@ func WaitForReplicationController(c clientset.Interface, namespace, name string, if err != nil { Logf("Get ReplicationController %s in namespace %s failed (%v).", name, namespace, err) return !exist, nil - } else { - Logf("ReplicationController %s in namespace %s found.", name, namespace) - return exist, nil } + Logf("ReplicationController %s in namespace %s found.", name, namespace) + return exist, nil }) if err != nil { stateMsg := map[bool]string{true: "to appear", false: "to disappear"} @@ -249,13 +255,13 @@ func ValidateController(c clientset.Interface, containerImage string, replicas i getImageTemplate := fmt.Sprintf(`--template={{if (exists . "spec" "containers")}}{{range .spec.containers}}{{if eq .name "%s"}}{{.image}}{{end}}{{end}}{{end}}`, containername) - By(fmt.Sprintf("waiting for all containers in %s pods to come up.", testname)) //testname should be selector + ginkgo.By(fmt.Sprintf("waiting for all containers in %s pods to come up.", testname)) //testname should be selector waitLoop: for start := time.Now(); time.Since(start) < PodStartTimeout; time.Sleep(5 * time.Second) { getPodsOutput := RunKubectlOrDie("get", "pods", "-o", "template", getPodsTemplate, "-l", testname, fmt.Sprintf("--namespace=%v", ns)) pods := strings.Fields(getPodsOutput) if numPods := len(pods); numPods != replicas { - By(fmt.Sprintf("Replicas for %s: expected=%d actual=%d", testname, replicas, numPods)) + ginkgo.By(fmt.Sprintf("Replicas for %s: expected=%d actual=%d", testname, replicas, numPods)) continue } var runningPods []string