Skip to content

Commit

Permalink
Merge branch 'master' into vkctlqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
k82cn authored May 7, 2019
2 parents 5114f9e + d1c3741 commit 9c43d2f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 55 deletions.
4 changes: 2 additions & 2 deletions test/e2e/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var _ = Describe("Queue E2E Test", func() {
}

spec.name = "q1-qj-1"
spec.queue = "q1"
spec.queue = defaultQueue1
job1 := createJob(context, spec)
err := waitJobReady(context, job1)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -58,7 +58,7 @@ var _ = Describe("Queue E2E Test", func() {
}

spec.name = "q2-qj-2"
spec.queue = "q2"
spec.queue = defaultQueue2
job2 := createJob(context, spec)
err = waitTasksReady(context, job2, expected)
Expect(err).NotTo(HaveOccurred())
Expand Down
78 changes: 25 additions & 53 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,22 @@ import (
"volcano.sh/volcano/pkg/controllers/job/state"
)

var oneMinute = 1 * time.Minute

var twoMinute = 2 * time.Minute

var oneCPU = v1.ResourceList{"cpu": resource.MustParse("1000m")}
var (
oneMinute = 1 * time.Minute
twoMinute = 2 * time.Minute
oneCPU = v1.ResourceList{"cpu": resource.MustParse("1000m")}
)

const (
workerPriority = "worker-pri"
masterPriority = "master-pri"
defaultNginxImage = "nginx:1.14"
defaultBusyBoxImage = "busybox:1.24"
defaultMPIImage = "volcanosh/example-mpi:0.0.1"

defaultNamespace = "test"
defaultQueue1 = "q1"
defaultQueue2 = "q2"
)

func cpuResource(request string) v1.ResourceList {
Expand Down Expand Up @@ -99,15 +103,14 @@ type context struct {
kbclient *kbver.Clientset
vkclient *vkver.Clientset

namespace string
queues []string
enableNamespaceAsQueue bool
namespace string
queues []string
}

func initTestContext() *context {
cxt := &context{
namespace: "test",
queues: []string{"q1", "q2"},
namespace: defaultNamespace,
queues: []string{defaultQueue1, defaultQueue2},
}

home := homeDir()
Expand All @@ -129,10 +132,6 @@ func initTestContext() *context {
Expect(err).NotTo(HaveOccurred(),
"k8s cluster is required to have one ready worker node at least.")

//NOTE(tommylikehu):NamespaceAsQueue feature was removed from kube-batch,
//we will eventually remove this logic in test as well.
cxt.enableNamespaceAsQueue = false

_, err = cxt.kubeclient.CoreV1().Namespaces().Create(&v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: cxt.namespace,
Expand Down Expand Up @@ -177,12 +176,7 @@ func queueNotExist(ctx *context) wait.ConditionFunc {
return func() (bool, error) {
for _, q := range ctx.queues {
var err error
if ctx.enableNamespaceAsQueue {
_, err = ctx.kubeclient.CoreV1().Namespaces().Get(q, metav1.GetOptions{})
} else {
_, err = ctx.kbclient.SchedulingV1alpha1().Queues().Get(q, metav1.GetOptions{})
}

_, err = ctx.kbclient.SchedulingV1alpha1().Queues().Get(q, metav1.GetOptions{})
if !(err != nil && errors.IsNotFound(err)) {
return false, err
}
Expand Down Expand Up @@ -234,22 +228,14 @@ func createQueues(cxt *context) {
var err error

for _, q := range cxt.queues {
if cxt.enableNamespaceAsQueue {
_, err = cxt.kubeclient.CoreV1().Namespaces().Create(&v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: q,
},
})
} else {
_, err = cxt.kbclient.SchedulingV1alpha1().Queues().Create(&kbv1.Queue{
ObjectMeta: metav1.ObjectMeta{
Name: q,
},
Spec: kbv1.QueueSpec{
Weight: 1,
},
})
}
_, err = cxt.kbclient.SchedulingV1alpha1().Queues().Create(&kbv1.Queue{
ObjectMeta: metav1.ObjectMeta{
Name: q,
},
Spec: kbv1.QueueSpec{
Weight: 1,
},
})

Expect(err).NotTo(HaveOccurred())
}
Expand All @@ -259,17 +245,9 @@ func deleteQueues(cxt *context) {
foreground := metav1.DeletePropagationForeground

for _, q := range cxt.queues {
var err error

if cxt.enableNamespaceAsQueue {
err = cxt.kubeclient.CoreV1().Namespaces().Delete(q, &metav1.DeleteOptions{
PropagationPolicy: &foreground,
})
} else {
err = cxt.kbclient.SchedulingV1alpha1().Queues().Delete(q, &metav1.DeleteOptions{
PropagationPolicy: &foreground,
})
}
err := cxt.kbclient.SchedulingV1alpha1().Queues().Delete(q, &metav1.DeleteOptions{
PropagationPolicy: &foreground,
})

Expect(err).NotTo(HaveOccurred())
}
Expand Down Expand Up @@ -305,12 +283,6 @@ func getNS(context *context, job *jobSpec) string {
return job.namespace
}

if context.enableNamespaceAsQueue {
if len(job.queue) != 0 {
return job.queue
}
}

return context.namespace
}

Expand Down

0 comments on commit 9c43d2f

Please sign in to comment.