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

E2E admission #382

Merged
merged 1 commit into from
Jul 24, 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
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"
}
}
}
]
}
}`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest moving this to a file.
and if we want to fix something in the future, it would be easy.

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())

})

})