Skip to content

Commit

Permalink
Merge pull request #588 from hzxuzhonghu/e2e-framework
Browse files Browse the repository at this point in the history
Cleanup e2e framework to speed up e2e
  • Loading branch information
volcano-sh-bot authored Dec 9, 2019
2 parents 75ccb50 + e0718d6 commit cbe3c00
Show file tree
Hide file tree
Showing 17 changed files with 138 additions and 148 deletions.
2 changes: 1 addition & 1 deletion docs/development/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ make e2e-test-kind
If you want to run e2e test in a existing cluster with volcano deployed, run the following:

```bash
export VK_BIN= need to set vcctl binary path (eg:.../src/volcano.sh/volcano/_output/bin/)
export VC_BIN= need to set vcctl binary path (eg:.../src/volcano.sh/volcano/_output/bin/)
KUBECONFIG=${KUBECONFIG} go test ./test/e2e
```

Expand Down
2 changes: 1 addition & 1 deletion hack/run-e2e-kind.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

export VK_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/..
export VK_BIN=${VK_ROOT}/${BIN_DIR}/${BIN_OSARCH}
export VC_BIN=${VK_ROOT}/${BIN_DIR}/${BIN_OSARCH}
export LOG_LEVEL=3
export SHOW_VOLCANO_LOGS=${SHOW_VOLCANO_LOGS:-1}
export CLEANUP_CLUSTER=${CLEANUP_CLUSTER:-1}
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var _ = Describe("Job E2E Test: Test Admission service", func() {
It("Default queue would be added", func() {
jobName := "job-default-queue"
namespace := "test"
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

_, err := createJobInner(context, &jobSpec{
Expand All @@ -60,7 +60,7 @@ var _ = Describe("Job E2E Test: Test Admission service", func() {

It("Invalid CPU unit", func() {

context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)
namespace := "test"

Expand Down Expand Up @@ -109,7 +109,7 @@ var _ = Describe("Job E2E Test: Test Admission service", func() {

It("Invalid memory unit", func() {

context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)
namespace := "test"

Expand Down Expand Up @@ -160,7 +160,7 @@ var _ = Describe("Job E2E Test: Test Admission service", func() {
It("Create default-scheduler pod", func() {
podName := "pod-default-scheduler"
namespace := "test"
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

pod := &corev1.Pod{
Expand Down Expand Up @@ -188,7 +188,7 @@ var _ = Describe("Job E2E Test: Test Admission service", func() {
podName := "pod-volcano"
pgName := "pending-pg"
namespace := "test"
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

pg := &schedulingv1alpha2.PodGroup{
Expand Down
11 changes: 8 additions & 3 deletions test/e2e/cli_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ func RunCliCommand(command []string) string {
command = append(command, "--master", masterURL())
}
command = append(command, "--kubeconfig", kubeconfigPath(homeDir()))
output, err := exec.Command(VolcanoCliBinary(), command...).Output()
vcctl := VolcanoCliBinary()
Expect(fileExist(vcctl)).To(BeTrue(), fmt.Sprintf(
"vcctl binary: %s is required for E2E tests, please update VC_BIN environment", vcctl))
output, err := exec.Command(vcctl, command...).Output()
Expect(err).NotTo(HaveOccurred(),
fmt.Sprintf("Command %s failed to execute: %s", strings.Join(command, ""), err))
return string(output)
Expand All @@ -83,8 +86,10 @@ func RunCliCommandWithoutKubeConfig(command []string) string {
if masterURL() != "" {
command = append(command, "--master", masterURL())
}

output, err := exec.Command(VolcanoCliBinary(), command...).Output()
vcctl := VolcanoCliBinary()
Expect(fileExist(vcctl)).To(BeTrue(), fmt.Sprintf(
"vcctl binary: %s is required for E2E tests, please update VC_BIN environment", vcctl))
output, err := exec.Command(vcctl, command...).Output()
Expect(err).NotTo(HaveOccurred(),
fmt.Sprintf("Command %s failed to execute: %s", strings.Join(command, ""), err))
return string(output)
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var _ = Describe("Job E2E Test: Test Job Command", func() {
var outBuffer bytes.Buffer
jobName := "test-job"
namespace := "test"
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)
rep := clusterSize(context, oneCPU)

Expand Down Expand Up @@ -70,7 +70,7 @@ var _ = Describe("Job E2E Test: Test Job Command", func() {
jobName := "test-suspend-running-job"
taskName := "long-live-task"
namespace := "test"
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

job := createJob(context, &jobSpec{
Expand Down Expand Up @@ -113,7 +113,7 @@ var _ = Describe("Job E2E Test: Test Job Command", func() {
})

It("Suspend pending job", func() {
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)
rep := clusterSize(context, oneCPU)

Expand Down Expand Up @@ -157,7 +157,7 @@ var _ = Describe("Job E2E Test: Test Job Command", func() {

jobName := "test-del-job"
namespace := "test"
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)
rep := clusterSize(context, oneCPU)

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/job_controlled_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var _ = Describe("Job E2E Test: Test Job PVCs", func() {
taskName := "pvctask"
pvName := "job-pv-name"
pvcName := "job-pvc-name-exist"
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

var tt v12.HostPathType
Expand Down Expand Up @@ -136,7 +136,7 @@ var _ = Describe("Job E2E Test: Test Job PVCs", func() {
It("Generate PodGroup and valid minResource when creating job", func() {
jobName := "job-name-podgroup"
namespace := "test"
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

resource := v12.ResourceList{
Expand Down
41 changes: 22 additions & 19 deletions test/e2e/job_error_handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ limitations under the License.
package e2e

import (
"strconv"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"strconv"

"k8s.io/api/core/v1"

Expand All @@ -31,7 +32,7 @@ import (
var _ = Describe("Job Error Handling", func() {
It("job level LifecyclePolicy, Event: PodFailed; Action: RestartJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -68,7 +69,7 @@ var _ = Describe("Job Error Handling", func() {

It("job level LifecyclePolicy, Event: PodFailed; Action: TerminateJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -105,7 +106,7 @@ var _ = Describe("Job Error Handling", func() {

It("job level LifecyclePolicy, Event: PodFailed; Action: AbortJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -142,7 +143,7 @@ var _ = Describe("Job Error Handling", func() {

It("job level LifecyclePolicy, Event: PodEvicted; Action: RestartJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -186,7 +187,7 @@ var _ = Describe("Job Error Handling", func() {

It("job level LifecyclePolicy, Event: PodEvicted; Action: TerminateJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -230,7 +231,7 @@ var _ = Describe("Job Error Handling", func() {

It("job level LifecyclePolicy, Event: PodEvicted; Action: AbortJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -274,7 +275,7 @@ var _ = Describe("Job Error Handling", func() {

It("job level LifecyclePolicy, Event: Any; Action: RestartJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -318,7 +319,7 @@ var _ = Describe("Job Error Handling", func() {

It("Job error handling: Restart job when job is unschedulable", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)
rep := clusterSize(context, oneCPU)

Expand Down Expand Up @@ -377,7 +378,7 @@ var _ = Describe("Job Error Handling", func() {

It("Job error handling: Abort job when job is unschedulable", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)
rep := clusterSize(context, oneCPU)

Expand Down Expand Up @@ -432,7 +433,7 @@ var _ = Describe("Job Error Handling", func() {

It("job level LifecyclePolicy, Event: TaskCompleted; Action: CompletedJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -472,7 +473,7 @@ var _ = Describe("Job Error Handling", func() {

It("job level LifecyclePolicy, error code: 3; Action: RestartJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -510,7 +511,7 @@ var _ = Describe("Job Error Handling", func() {

It("job level LifecyclePolicy, Event[]: PodEvicted, PodFailed; Action: TerminateJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -556,7 +557,7 @@ var _ = Describe("Job Error Handling", func() {
})
It("Task level LifecyclePolicy, Event: PodFailed; Action: RestartJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -592,7 +593,7 @@ var _ = Describe("Job Error Handling", func() {
})
It("Task level LifecyclePolicy, Event: PodEvicted; Action: RestartJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -636,7 +637,7 @@ var _ = Describe("Job Error Handling", func() {
})
It("Task level LifecyclePolicy, Event: PodEvicted; Action: TerminateJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -679,7 +680,7 @@ var _ = Describe("Job Error Handling", func() {
})
It("Task level LifecyclePolicy, Event: TaskCompleted; Action: CompletedJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -719,7 +720,7 @@ var _ = Describe("Job Error Handling", func() {

It("job level LifecyclePolicy, Event: PodFailed; Action: AbortJob and Task level lifecyclePolicy, Event : PodFailed; Action: RestartJob", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -762,7 +763,9 @@ var _ = Describe("Job Error Handling", func() {

It("Task Priority", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{
priorityClasses: []string{masterPriority, workerPriority},
})
defer cleanupTestContext(context)

rep := clusterSize(context, oneCPU)
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/job_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
var _ = Describe("Job Life Cycle", func() {
It("Delete job that is pending state", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -62,7 +62,7 @@ var _ = Describe("Job Life Cycle", func() {

It("Delete job that is Running state", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -93,7 +93,7 @@ var _ = Describe("Job Life Cycle", func() {

It("Delete job that is Completed state", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -126,7 +126,7 @@ var _ = Describe("Job Life Cycle", func() {

It("Delete job that is Failed job", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -165,7 +165,7 @@ var _ = Describe("Job Life Cycle", func() {

It("Delete job that is terminated job", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -204,7 +204,7 @@ var _ = Describe("Job Life Cycle", func() {

It("Create and Delete job with CPU requirement", func() {
By("init test context")
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

By("create job")
Expand Down Expand Up @@ -243,7 +243,7 @@ var _ = Describe("Job Life Cycle", func() {
})

It("Checking Event Generation for job", func() {
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

job := createJob(context, &jobSpec{
Expand Down Expand Up @@ -271,7 +271,7 @@ var _ = Describe("Job Life Cycle", func() {
})

It("Checking Unschedulable Event Generation for job", func() {
context := initTestContext()
context := initTestContext(options{})
defer cleanupTestContext(context)

nodeName, rep := computeNode(context, oneCPU)
Expand Down
Loading

0 comments on commit cbe3c00

Please sign in to comment.