Add kubectl run ScheduledJob e2e test
This commit is contained in:
		| @@ -120,6 +120,12 @@ func NewDefaultFederatedFramework(baseName string) *Framework { | |||||||
| 	return f | 	return f | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func NewDefaultGroupVersionFramework(baseName string, groupVersion unversioned.GroupVersion) *Framework { | ||||||
|  | 	f := NewDefaultFramework(baseName) | ||||||
|  | 	f.options.GroupVersion = &groupVersion | ||||||
|  | 	return f | ||||||
|  | } | ||||||
|  |  | ||||||
| func NewFramework(baseName string, options FrameworkOptions, client *client.Client) *Framework { | func NewFramework(baseName string, options FrameworkOptions, client *client.Client) *Framework { | ||||||
| 	f := &Framework{ | 	f := &Framework{ | ||||||
| 		BaseName:                 baseName, | 		BaseName:                 baseName, | ||||||
|   | |||||||
| @@ -171,7 +171,7 @@ func runKubectlRetryOrDie(args ...string) string { | |||||||
|  |  | ||||||
| var _ = framework.KubeDescribe("Kubectl client", func() { | var _ = framework.KubeDescribe("Kubectl client", func() { | ||||||
| 	defer GinkgoRecover() | 	defer GinkgoRecover() | ||||||
| 	f := framework.NewDefaultFramework("kubectl") | 	f := framework.NewDefaultGroupVersionFramework("kubectl", BatchV2Alpha1GroupVersion) | ||||||
|  |  | ||||||
| 	// Reustable cluster state function.  This won't be adversly affected by lazy initialization of framework. | 	// Reustable cluster state function.  This won't be adversly affected by lazy initialization of framework. | ||||||
| 	clusterState := func() *framework.ClusterVerification { | 	clusterState := func() *framework.ClusterVerification { | ||||||
| @@ -1073,7 +1073,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { | |||||||
| 			} | 			} | ||||||
| 			containers := job.Spec.Template.Spec.Containers | 			containers := job.Spec.Template.Spec.Containers | ||||||
| 			if containers == nil || len(containers) != 1 || containers[0].Image != nginxImage { | 			if containers == nil || len(containers) != 1 || containers[0].Image != nginxImage { | ||||||
| 				framework.Failf("Failed creating job %s for 1 pod with expected image %s", jobName, nginxImage) | 				framework.Failf("Failed creating job %s for 1 pod with expected image %s: %#v", jobName, nginxImage, containers) | ||||||
| 			} | 			} | ||||||
| 			if job.Spec.Template.Spec.RestartPolicy != api.RestartPolicyOnFailure { | 			if job.Spec.Template.Spec.RestartPolicy != api.RestartPolicyOnFailure { | ||||||
| 				framework.Failf("Failed creating a job with correct restart policy for --restart=OnFailure") | 				framework.Failf("Failed creating a job with correct restart policy for --restart=OnFailure") | ||||||
| @@ -1081,6 +1081,43 @@ var _ = framework.KubeDescribe("Kubectl client", func() { | |||||||
| 		}) | 		}) | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
|  | 	framework.KubeDescribe("Kubectl run ScheduledJob", func() { | ||||||
|  | 		var nsFlag string | ||||||
|  | 		var sjName string | ||||||
|  |  | ||||||
|  | 		BeforeEach(func() { | ||||||
|  | 			nsFlag = fmt.Sprintf("--namespace=%v", ns) | ||||||
|  | 			sjName = "e2e-test-echo-scheduledjob" | ||||||
|  | 		}) | ||||||
|  |  | ||||||
|  | 		AfterEach(func() { | ||||||
|  | 			framework.RunKubectlOrDie("delete", "scheduledjobs", sjName, nsFlag) | ||||||
|  | 		}) | ||||||
|  |  | ||||||
|  | 		It("should create a ScheduledJob", func() { | ||||||
|  | 			framework.SkipIfMissingResource(f.ClientPool, ScheduledJobGroupVersionResource, f.Namespace.Name) | ||||||
|  |  | ||||||
|  | 			schedule := "*/5 * * * ?" | ||||||
|  | 			framework.RunKubectlOrDie("run", sjName, "--restart=OnFailure", "--generator=scheduledjob/v2alpha1", | ||||||
|  | 				"--schedule="+schedule, "--image="+busyboxImage, nsFlag) | ||||||
|  | 			By("verifying the ScheduledJob " + sjName + " was created") | ||||||
|  | 			sj, err := c.Batch().ScheduledJobs(ns).Get(sjName) | ||||||
|  | 			if err != nil { | ||||||
|  | 				framework.Failf("Failed getting ScheduledJob %s: %v", sjName, err) | ||||||
|  | 			} | ||||||
|  | 			if sj.Spec.Schedule != schedule { | ||||||
|  | 				framework.Failf("Failed creating a ScheduledJob with correct schedule %s", schedule) | ||||||
|  | 			} | ||||||
|  | 			containers := sj.Spec.JobTemplate.Spec.Template.Spec.Containers | ||||||
|  | 			if containers == nil || len(containers) != 1 || containers[0].Image != busyboxImage { | ||||||
|  | 				framework.Failf("Failed creating ScheduledJob %s for 1 pod with expected image %s: %#v", sjName, busyboxImage, containers) | ||||||
|  | 			} | ||||||
|  | 			if sj.Spec.JobTemplate.Spec.Template.Spec.RestartPolicy != api.RestartPolicyOnFailure { | ||||||
|  | 				framework.Failf("Failed creating a ScheduledJob with correct restart policy for --restart=OnFailure") | ||||||
|  | 			} | ||||||
|  | 		}) | ||||||
|  | 	}) | ||||||
|  |  | ||||||
| 	framework.KubeDescribe("Kubectl run pod", func() { | 	framework.KubeDescribe("Kubectl run pod", func() { | ||||||
| 		var nsFlag string | 		var nsFlag string | ||||||
| 		var podName string | 		var podName string | ||||||
|   | |||||||
| @@ -37,16 +37,16 @@ const ( | |||||||
| 	scheduledJobTimeout = 5 * time.Minute | 	scheduledJobTimeout = 5 * time.Minute | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | var ( | ||||||
|  | 	ScheduledJobGroupVersionResource = unversioned.GroupVersionResource{Group: batch.GroupName, Version: "v2alpha1", Resource: "scheduledjobs"} | ||||||
|  | 	BatchV2Alpha1GroupVersion        = unversioned.GroupVersion{Group: batch.GroupName, Version: "v2alpha1"} | ||||||
|  | ) | ||||||
|  |  | ||||||
| var _ = framework.KubeDescribe("ScheduledJob", func() { | var _ = framework.KubeDescribe("ScheduledJob", func() { | ||||||
| 	options := framework.FrameworkOptions{ | 	f := framework.NewDefaultGroupVersionFramework("scheduledjob", BatchV2Alpha1GroupVersion) | ||||||
| 		ClientQPS:    20, |  | ||||||
| 		ClientBurst:  50, |  | ||||||
| 		GroupVersion: &unversioned.GroupVersion{Group: batch.GroupName, Version: "v2alpha1"}, |  | ||||||
| 	} |  | ||||||
| 	f := framework.NewFramework("scheduledjob", options, nil) |  | ||||||
|  |  | ||||||
| 	BeforeEach(func() { | 	BeforeEach(func() { | ||||||
| 		framework.SkipIfMissingResource(f.ClientPool, unversioned.GroupVersionResource{Group: batch.GroupName, Version: "v2alpha1", Resource: "scheduledjobs"}, f.Namespace.Name) | 		framework.SkipIfMissingResource(f.ClientPool, ScheduledJobGroupVersionResource, f.Namespace.Name) | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
| 	// multiple jobs running at once | 	// multiple jobs running at once | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Maciej Szulik
					Maciej Szulik