Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add E2E for check functionality of all Plugins #395

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions test/e2e/job_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/scheduler/api"
"volcano.sh/volcano/pkg/controllers/job/helpers"
"volcano.sh/volcano/pkg/controllers/job/plugins/env"
)

var _ = Describe("Job E2E Test: Test Job Plugins", func() {
Expand Down Expand Up @@ -170,4 +171,70 @@ var _ = Describe("Job E2E Test: Test Job Plugins", func() {
Expect(pod.Spec.NodeName).To(Equal(nodeName))
}
})

It("Check Functionality of all plugins", func() {
jobName := "job-with-all-plugin"
namespace := "test"
taskName := "task"
foundVolume := false
foundEnv := false
context := initTestContext()
defer cleanupTestContext(context)

_, rep := computeNode(context, oneCPU)
Expect(rep).NotTo(Equal(0))

job := createJob(context, &jobSpec{
namespace: namespace,
name: jobName,
plugins: map[string][]string{
"ssh": {"--no-root"},
"env": {},
"svc": {},
},
tasks: []taskSpec{
{
img: defaultNginxImage,
req: oneCPU,
min: 1,
rep: rep,
name: taskName,
},
},
})

err := waitJobReady(context, job)
Expect(err).NotTo(HaveOccurred())

pluginName := fmt.Sprintf("%s-ssh", jobName)
_, err = context.kubeclient.CoreV1().ConfigMaps(namespace).Get(
pluginName, v1.GetOptions{})
Expect(err).NotTo(HaveOccurred())

pod, err := context.kubeclient.CoreV1().Pods(namespace).Get(
fmt.Sprintf(helpers.PodNameFmt, jobName, taskName, 0), v1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
for _, volume := range pod.Spec.Volumes {
if volume.Name == pluginName {
foundVolume = true
break
}
}
Expect(foundVolume).To(BeTrue())

// Check whether env exists in the pod
for _, container := range pod.Spec.Containers {
for _, envi := range container.Env {
if envi.Name == env.TaskVkIndex {
foundEnv = true
break
}
}
}
Expect(foundEnv).To(BeTrue())

// Check whether service is created with job name
_, err = context.kubeclient.CoreV1().Services(job.Namespace).Get(job.Name, v1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
})
})