diff --git a/pkg/kubectl/cmd/run_test.go b/pkg/kubectl/cmd/run_test.go index 8f7ebedbf04..a728a810e6e 100644 --- a/pkg/kubectl/cmd/run_test.go +++ b/pkg/kubectl/cmd/run_test.go @@ -160,6 +160,7 @@ func TestRunArgsFollowDashRules(t *testing.T) { tf.ClientConfig = &client.Config{} cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr) cmd.Flags().Set("image", "nginx") + cmd.Flags().Set("generator", "run/v1") err := Run(f, os.Stdin, os.Stdout, os.Stderr, cmd, test.args, test.argsLenAtDash) if test.expectError && err == nil { t.Errorf("unexpected non-error (%s)", test.name) diff --git a/test/e2e/kubectl.go b/test/e2e/kubectl.go index 94ec99dc0b0..150106c6e51 100644 --- a/test/e2e/kubectl.go +++ b/test/e2e/kubectl.go @@ -870,7 +870,7 @@ var _ = Describe("Kubectl client", func() { image := "nginx" By("running the image " + image) - runKubectlOrDie("run", rcName, "--image="+image, nsFlag) + runKubectlOrDie("run", rcName, "--image="+image, "--generator=run/v1", nsFlag) By("verifying the rc " + rcName + " was created") rc, err := c.ReplicationControllers(ns).Get(rcName) if err != nil { @@ -896,6 +896,49 @@ var _ = Describe("Kubectl client", func() { }) + Describe("Kubectl run deployment", func() { + var nsFlag string + var dName string + + BeforeEach(func() { + nsFlag = fmt.Sprintf("--namespace=%v", ns) + dName = "e2e-test-nginx-deployment" + }) + + AfterEach(func() { + runKubectlOrDie("delete", "deployment", dName, nsFlag) + }) + + It("should create a deployment from an image [Conformance]", func() { + image := "nginx" + + By("running the image " + image) + runKubectlOrDie("run", dName, "--image="+image, nsFlag) + By("verifying the deployment " + dName + " was created") + d, err := c.Extensions().Deployments(ns).Get(dName) + if err != nil { + Failf("Failed getting deployment %s: %v", dName, err) + } + containers := d.Spec.Template.Spec.Containers + if containers == nil || len(containers) != 1 || containers[0].Image != image { + Failf("Failed creating deployment %s for 1 pod with expected image %s", dName, image) + } + + By("verifying the pod controlled by deployment " + dName + " was created") + label := labels.SelectorFromSet(labels.Set(map[string]string{"run": dName})) + podlist, err := waitForPodsWithLabel(c, ns, label) + if err != nil { + Failf("Failed getting pod controlled by deployment %s: %v", dName, err) + } + pods := podlist.Items + if pods == nil || len(pods) != 1 || len(pods[0].Spec.Containers) != 1 || pods[0].Spec.Containers[0].Image != image { + runKubectlOrDie("get", "pods", "-L", "run", nsFlag) + Failf("Failed creating 1 pod with expected image %s. Number of pods = %v", image, len(pods)) + } + }) + + }) + Describe("Kubectl run job", func() { var nsFlag string var jobName string