From 8d4bde58681158776e9e2bc9699fd6951d9a4582 Mon Sep 17 00:00:00 2001 From: Rajadeepan D Ramesh Date: Tue, 23 Jul 2019 22:59:12 +0530 Subject: [PATCH] E2E admission --- test/e2e/admission.go | 101 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/test/e2e/admission.go b/test/e2e/admission.go index 968240ac82..d7ff16871f 100644 --- a/test/e2e/admission.go +++ b/test/e2e/admission.go @@ -17,9 +17,11 @@ limitations under the License. package e2e import ( + "encoding/json" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/apis/meta/v1" + "volcano.sh/volcano/pkg/apis/batch/v1alpha1" ) var _ = Describe("Job E2E Test: Test Admission service", func() { @@ -51,4 +53,103 @@ var _ = Describe("Job E2E Test: Test Admission service", func() { "Job queue attribute would default to 'default' ") }) + It("Invalid CPU unit", func() { + + context := initTestContext() + defer cleanupTestContext(context) + namespace := "test" + + var job v1alpha1.Job + jsonData := []byte(`{ + "apiVersion": "batch.volcano.sh/v1alpha1", + "kind": "Job", + "metadata": { + "name": "test-job" + }, + "spec": { + "minAvailable": 3, + "schedulerName": "volcano", + "queue": "default", + "tasks": [ + { + "replicas": 3, + "name": "default-nginx", + "template": { + "spec": { + "containers": [ + { + "image": "nginx", + "imagePullPolicy": "IfNotPresent", + "name": "nginx", + "resources": { + "requests": { + "cpu": "-1" + } + } + } + ], + "restartPolicy": "Never" + } + } + } + ] + } +}`) + err := json.Unmarshal(jsonData, &job) + Expect(err).NotTo(HaveOccurred()) + _, err = context.vkclient.BatchV1alpha1().Jobs(namespace).Create(&job) + Expect(err).To(HaveOccurred()) + + }) + + It("Invalid memory unit", func() { + + context := initTestContext() + defer cleanupTestContext(context) + namespace := "test" + + var job v1alpha1.Job + jsonData := []byte(`{ + "apiVersion": "batch.volcano.sh/v1alpha1", + "kind": "Job", + "metadata": { + "name": "test-job" + }, + "spec": { + "minAvailable": 3, + "schedulerName": "volcano", + "queue": "default", + "tasks": [ + { + "replicas": 3, + "name": "default-nginx", + "template": { + "spec": { + "containers": [ + { + "image": "nginx", + "imagePullPolicy": "IfNotPresent", + "name": "nginx", + "resources": { + "requests": { + "memory": "-1" + } + } + } + ], + "restartPolicy": "Never" + } + } + } + ] + } +}`) + + err := json.Unmarshal(jsonData, &job) + Expect(err).NotTo(HaveOccurred()) + _, err = context.vkclient.BatchV1alpha1().Jobs(namespace).Create(&job) + Expect(err).To(HaveOccurred()) + + }) + })