Add --restart support to kubectl run

This commit is contained in:
Brendan Burns
2015-08-04 12:54:17 -07:00
parent fbb5ce6636
commit e42d6aa255
15 changed files with 461 additions and 42 deletions

View File

@@ -485,7 +485,7 @@ var _ = Describe("Kubectl client", func() {
})
})
Describe("Kubectl run", func() {
Describe("Kubectl run rc", func() {
var nsFlag string
var rcName string
@@ -528,6 +528,59 @@ var _ = Describe("Kubectl client", func() {
})
Describe("Kubectl run pod", func() {
var nsFlag string
var podName string
BeforeEach(func() {
nsFlag = fmt.Sprintf("--namespace=%v", ns)
podName = "e2e-test-nginx-pod"
})
AfterEach(func() {
runKubectl("stop", "pods", podName, nsFlag)
})
It("should create a pod from an image when restart is OnFailure", func() {
image := "nginx"
By("running the image " + image)
runKubectl("run", podName, "--restart=OnFailure", "--image="+image, nsFlag)
By("verifying the pod " + podName + " was created")
pod, err := c.Pods(ns).Get(podName)
if err != nil {
Failf("Failed getting pod %s: %v", podName, err)
}
containers := pod.Spec.Containers
if containers == nil || len(containers) != 1 || containers[0].Image != image {
Failf("Failed creating pod %s for 1 pod with expected image %s", podName, image)
}
if pod.Spec.RestartPolicy != api.RestartPolicyOnFailure {
Failf("Failed creating a pod with correct restart policy for --restart=OnFailure")
}
})
It("should create a pod from an image when restart is Never", func() {
image := "nginx"
By("running the image " + image)
runKubectl("run", podName, "--restart=Never", "--image="+image, nsFlag)
By("verifying the pod " + podName + " was created")
pod, err := c.Pods(ns).Get(podName)
if err != nil {
Failf("Failed getting pod %s: %v", podName, err)
}
containers := pod.Spec.Containers
if containers == nil || len(containers) != 1 || containers[0].Image != image {
Failf("Failed creating pod %s for 1 pod with expected image %s", podName, image)
}
if pod.Spec.RestartPolicy != api.RestartPolicyNever {
Failf("Failed creating a pod with correct restart policy for --restart=OnFailure")
}
})
})
Describe("Proxy server", func() {
// TODO: test proxy options (static, prefix, etc)
It("should support proxy with --port 0", func() {