func BuildJob()

in internal/testhelpers/resources.go [283:306]


func BuildJob(name types.NamespacedName, appLabel string) *batchv1.Job {
	job := &batchv1.Job{
		TypeMeta: metav1.TypeMeta{Kind: "Job", APIVersion: "batch/v1"},
		ObjectMeta: metav1.ObjectMeta{
			Name:      name.Name,
			Namespace: name.Namespace,
			Labels:    map[string]string{"app": appLabel},
		},
		Spec: batchv1.JobSpec{
			Template:    buildPodTemplateSpec(30, appLabel),
			Parallelism: ptr(int32(1)), // run the pod 20 times, 1 at a time
			Completions: ptr(int32(20)),
		},
	}
	job.Spec.Template.Spec.RestartPolicy = corev1.RestartPolicyNever
	podCmd := fmt.Sprintf("echo Container 1 is Running \n"+
		"sleep %d \n"+
		"for url in $CSQL_PROXY_QUIT_URLS ; do \n"+
		"   wget --post-data '' $url \n"+
		"done", 30)
	job.Spec.Template.Spec.Containers[0].Command = []string{"sh", "-c", podCmd}

	return job
}