Skip to content

Commit

Permalink
Merge pull request kubernetes-retired#438 from k82cn/kb_425_5
Browse files Browse the repository at this point in the history
Using jobSpec for queue e2e.
  • Loading branch information
k8s-ci-robot authored Oct 16, 2018
2 parents 8a812dd + b6ee7b2 commit a7319f8
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 261 deletions.
3 changes: 2 additions & 1 deletion pkg/scheduler/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ func (sc *SchedulerCache) Snapshot() *arbapi.ClusterInfo {
}

if _, found := queues[value.Queue]; !found {
glog.V(3).Infof("The Queue of Job <%v> does not exist, ignore it.", value.UID)
glog.V(3).Infof("The Queue <%v> of Job <%v> does not exist, ignore it.",
value.Queue, value.UID)
continue
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/scheduler/cache/event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ func (sc *SchedulerCache) AddPodGroup(obj interface{}) {
sc.Mutex.Lock()
defer sc.Mutex.Unlock()

// If namespace as queue, the `.spec.Queue` of PodGroup is ignored.
if sc.namespaceAsQueue {
ss.Spec.Queue = ""
}

glog.V(4).Infof("Add PodGroup(%s) into cache, spec(%#v)", ss.Name, ss.Spec)
err := sc.setPodGroup(ss)
if err != nil {
Expand Down
9 changes: 2 additions & 7 deletions test/e2e/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ var _ = Describe("Job E2E Test", func() {
rep := clusterSize(context, oneCPU)

_, pg := createJobEx(context, &jobSpec{
name: "qj-1",
namespace: "test",
name: "qj-1",
tasks: []taskSpec{
{
img: "busybox",
Expand All @@ -51,7 +50,6 @@ var _ = Describe("Job E2E Test", func() {
rep := clusterSize(context, oneCPU)

job := &jobSpec{
namespace: "test",
tasks: []taskSpec{
{
img: "busybox",
Expand Down Expand Up @@ -151,7 +149,6 @@ var _ = Describe("Job E2E Test", func() {
rep := clusterSize(context, slot)

job := &jobSpec{
namespace: "test",
tasks: []taskSpec{
{
img: "nginx",
Expand Down Expand Up @@ -184,7 +181,6 @@ var _ = Describe("Job E2E Test", func() {
rep := clusterSize(context, slot)

job := &jobSpec{
namespace: "test",
tasks: []taskSpec{
{
img: "nginx",
Expand Down Expand Up @@ -226,8 +222,7 @@ var _ = Describe("Job E2E Test", func() {
rep := clusterSize(context, slot)

job := &jobSpec{
name: "test",
namespace: "test",
name: "test",
tasks: []taskSpec{
{
img: "nginx",
Expand Down
9 changes: 3 additions & 6 deletions test/e2e/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ var _ = Describe("Predicates E2E Test", func() {
}

job := &jobSpec{
name: "na-job",
namespace: "test",
name: "na-job",
tasks: []taskSpec{
{
img: "nginx",
Expand Down Expand Up @@ -83,8 +82,7 @@ var _ = Describe("Predicates E2E Test", func() {
nn := clusterNodeNumber(context)

job := &jobSpec{
name: "hp-job",
namespace: "test",
name: "hp-job",
tasks: []taskSpec{
{
img: "nginx",
Expand Down Expand Up @@ -129,8 +127,7 @@ var _ = Describe("Predicates E2E Test", func() {
}

job := &jobSpec{
name: "pa-job",
namespace: "test",
name: "pa-job",
tasks: []taskSpec{
{
img: "nginx",
Expand Down
29 changes: 20 additions & 9 deletions test/e2e/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,28 @@ import (
)

var _ = Describe("Predicates E2E Test", func() {

It("Reclaim", func() {
context := initTestContext()
defer cleanupTestContext(context)

jobName1 := "n1/qj-1"
jobName2 := "n2/qj-2"

slot := oneCPU
rep := clusterSize(context, slot)

createJob(context, jobName1, 1, rep, "nginx", slot, nil, nil)
err := waitJobReady(context, jobName1)
job := &jobSpec{
tasks: []taskSpec{
{
img: "nginx",
req: slot,
min: 1,
rep: rep,
},
},
}

job.name = "q1-qj-1"
job.queue = "q1"
_, pg1 := createJobEx(context, job)
err := waitPodGroupReady(context, pg1)
Expect(err).NotTo(HaveOccurred())

expected := int(rep) / 2
Expand All @@ -48,11 +57,13 @@ var _ = Describe("Predicates E2E Test", func() {
Expect(err).NotTo(HaveOccurred())
}

createJob(context, jobName2, 1, rep, "nginx", slot, nil, nil)
err = waitTasksReady(context, jobName2, expected)
job.name = "q2-qj-2"
job.queue = "q2"
_, pg2 := createJobEx(context, job)
err = waitTasksReadyEx(context, pg2, expected)
Expect(err).NotTo(HaveOccurred())

err = waitTasksReady(context, jobName1, expected)
err = waitTasksReadyEx(context, pg1, expected)
Expect(err).NotTo(HaveOccurred())
})

Expand Down
Loading

0 comments on commit a7319f8

Please sign in to comment.