add e2e test for same-image rolling-update
This commit is contained in:
parent
1baa473ef2
commit
9b91750284
@ -1416,7 +1416,7 @@ func ValidateController(c *client.Client, containerImage string, replicas int, c
|
|||||||
By(fmt.Sprintf("waiting for all containers in %s pods to come up.", testname)) //testname should be selector
|
By(fmt.Sprintf("waiting for all containers in %s pods to come up.", testname)) //testname should be selector
|
||||||
waitLoop:
|
waitLoop:
|
||||||
for start := time.Now(); time.Since(start) < PodStartTimeout; time.Sleep(5 * time.Second) {
|
for start := time.Now(); time.Since(start) < PodStartTimeout; time.Sleep(5 * time.Second) {
|
||||||
getPodsOutput := RunKubectlOrDie("get", "pods", "-o", "template", getPodsTemplate, "--api-version=v1", "-l", testname, fmt.Sprintf("--namespace=%v", ns))
|
getPodsOutput := RunKubectlOrDie("get", "pods", "-o", "template", getPodsTemplate, "-l", testname, fmt.Sprintf("--namespace=%v", ns))
|
||||||
pods := strings.Fields(getPodsOutput)
|
pods := strings.Fields(getPodsOutput)
|
||||||
if numPods := len(pods); numPods != replicas {
|
if numPods := len(pods); numPods != replicas {
|
||||||
By(fmt.Sprintf("Replicas for %s: expected=%d actual=%d", testname, replicas, numPods))
|
By(fmt.Sprintf("Replicas for %s: expected=%d actual=%d", testname, replicas, numPods))
|
||||||
@ -1424,13 +1424,13 @@ waitLoop:
|
|||||||
}
|
}
|
||||||
var runningPods []string
|
var runningPods []string
|
||||||
for _, podID := range pods {
|
for _, podID := range pods {
|
||||||
running := RunKubectlOrDie("get", "pods", podID, "-o", "template", getContainerStateTemplate, "--api-version=v1", fmt.Sprintf("--namespace=%v", ns))
|
running := RunKubectlOrDie("get", "pods", podID, "-o", "template", getContainerStateTemplate, fmt.Sprintf("--namespace=%v", ns))
|
||||||
if running != "true" {
|
if running != "true" {
|
||||||
Logf("%s is created but not running", podID)
|
Logf("%s is created but not running", podID)
|
||||||
continue waitLoop
|
continue waitLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
currentImage := RunKubectlOrDie("get", "pods", podID, "-o", "template", getImageTemplate, "--api-version=v1", fmt.Sprintf("--namespace=%v", ns))
|
currentImage := RunKubectlOrDie("get", "pods", podID, "-o", "template", getImageTemplate, fmt.Sprintf("--namespace=%v", ns))
|
||||||
if currentImage != containerImage {
|
if currentImage != containerImage {
|
||||||
Logf("%s is created but running wrong image; expected: %s, actual: %s", podID, containerImage, currentImage)
|
Logf("%s is created but running wrong image; expected: %s, actual: %s", podID, containerImage, currentImage)
|
||||||
continue waitLoop
|
continue waitLoop
|
||||||
|
@ -1020,6 +1020,40 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
framework.KubeDescribe("Kubectl rolling-update", func() {
|
||||||
|
var nsFlag string
|
||||||
|
var rcName string
|
||||||
|
var c *client.Client
|
||||||
|
|
||||||
|
BeforeEach(func() {
|
||||||
|
c = f.Client
|
||||||
|
nsFlag = fmt.Sprintf("--namespace=%v", ns)
|
||||||
|
rcName = "e2e-test-nginx-rc"
|
||||||
|
})
|
||||||
|
|
||||||
|
AfterEach(func() {
|
||||||
|
framework.RunKubectlOrDie("delete", "rc", rcName, nsFlag)
|
||||||
|
})
|
||||||
|
|
||||||
|
It("should support rolling-update to same image [Conformance]", func() {
|
||||||
|
By("running the image " + nginxImage)
|
||||||
|
framework.RunKubectlOrDie("run", rcName, "--image="+nginxImage, "--generator=run/v1", nsFlag)
|
||||||
|
By("verifying the rc " + rcName + " was created")
|
||||||
|
rc, err := c.ReplicationControllers(ns).Get(rcName)
|
||||||
|
if err != nil {
|
||||||
|
framework.Failf("Failed getting rc %s: %v", rcName, err)
|
||||||
|
}
|
||||||
|
containers := rc.Spec.Template.Spec.Containers
|
||||||
|
if containers == nil || len(containers) != 1 || containers[0].Image != nginxImage {
|
||||||
|
framework.Failf("Failed creating rc %s for 1 pod with expected image %s", rcName, nginxImage)
|
||||||
|
}
|
||||||
|
|
||||||
|
By("rolling-update to same image controller")
|
||||||
|
framework.RunKubectlOrDie("rolling-update", rcName, "--update-period=1s", "--image="+nginxImage, "--image-pull-policy="+string(api.PullIfNotPresent), nsFlag)
|
||||||
|
framework.ValidateController(c, nginxImage, 1, rcName, "run="+rcName, noOpValidatorFn, ns)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
framework.KubeDescribe("Kubectl run deployment", func() {
|
framework.KubeDescribe("Kubectl run deployment", func() {
|
||||||
var nsFlag string
|
var nsFlag string
|
||||||
var dName string
|
var dName string
|
||||||
@ -1444,6 +1478,8 @@ func getUDData(jpgExpected string, ns string) func(*client.Client, string) error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func noOpValidatorFn(c *client.Client, podID string) error { return nil }
|
||||||
|
|
||||||
// newBlockingReader returns a reader that allows reading the given string,
|
// newBlockingReader returns a reader that allows reading the given string,
|
||||||
// then blocks until Close() is called on the returned closer.
|
// then blocks until Close() is called on the returned closer.
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user