Add e2e test for kubectl run should generate deployment

pull/6/head
Janet Kuo 2016-02-02 14:51:15 -08:00
parent 311385e76c
commit 4e8b4871c4
2 changed files with 45 additions and 1 deletions

View File

@ -160,6 +160,7 @@ func TestRunArgsFollowDashRules(t *testing.T) {
tf.ClientConfig = &client.Config{} tf.ClientConfig = &client.Config{}
cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr) cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr)
cmd.Flags().Set("image", "nginx") 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) err := Run(f, os.Stdin, os.Stdout, os.Stderr, cmd, test.args, test.argsLenAtDash)
if test.expectError && err == nil { if test.expectError && err == nil {
t.Errorf("unexpected non-error (%s)", test.name) t.Errorf("unexpected non-error (%s)", test.name)

View File

@ -870,7 +870,7 @@ var _ = Describe("Kubectl client", func() {
image := "nginx" image := "nginx"
By("running the image " + image) 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") By("verifying the rc " + rcName + " was created")
rc, err := c.ReplicationControllers(ns).Get(rcName) rc, err := c.ReplicationControllers(ns).Get(rcName)
if err != nil { 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() { Describe("Kubectl run job", func() {
var nsFlag string var nsFlag string
var jobName string var jobName string