Skip to content

Commit

Permalink
Merge pull request #382 from Rajadeepan/e2eadmission
Browse files Browse the repository at this point in the history
E2E admission
  • Loading branch information
volcano-sh-bot authored Jul 24, 2019
2 parents df01768 + 8d4bde5 commit 24527ea
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions test/e2e/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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())

})

})

0 comments on commit 24527ea

Please sign in to comment.