Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit 5ecd2ed

Browse files
fix CONFLICT job.go
2 parents 5892ec8 + edaeff0 commit 5ecd2ed

File tree

5 files changed

+142
-93
lines changed

5 files changed

+142
-93
lines changed

test/e2e/e2e_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package test
17+
package e2e
1818

1919
import (
2020
"testing"

test/e2e/e2e.go renamed to test/e2e/job.go

+2-91
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,14 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package test
17+
package e2e
1818

1919
import (
20-
"fmt"
21-
2220
. "github.com/onsi/ginkgo"
2321
. "github.com/onsi/gomega"
24-
25-
"k8s.io/api/core/v1"
26-
"k8s.io/kubernetes/pkg/scheduler/algorithm"
2722
)
2823

29-
var _ = Describe("E2E Test", func() {
24+
var _ = Describe("Job E2E Test", func() {
3025
It("Schedule Job", func() {
3126
context := initTestContext()
3227
defer cleanupTestContext(context)
@@ -138,90 +133,6 @@ var _ = Describe("E2E Test", func() {
138133
err = waitTasksReady(context, job3.Name, int(rep)/3)
139134
Expect(err).NotTo(HaveOccurred())
140135
})
141-
142-
It("NodeAffinity", func() {
143-
context := initTestContext()
144-
defer cleanupTestContext(context)
145-
146-
slot := oneCPU
147-
nodeName, rep := computeNode(context, oneCPU)
148-
Expect(rep).NotTo(Equal(0))
149-
150-
affinity := &v1.Affinity{
151-
NodeAffinity: &v1.NodeAffinity{
152-
RequiredDuringSchedulingIgnoredDuringExecution: &v1.NodeSelector{
153-
NodeSelectorTerms: []v1.NodeSelectorTerm{
154-
{
155-
MatchFields: []v1.NodeSelectorRequirement{
156-
{
157-
Key: algorithm.NodeFieldSelectorKeyNodeName,
158-
Operator: v1.NodeSelectorOpIn,
159-
Values: []string{nodeName},
160-
},
161-
},
162-
},
163-
},
164-
},
165-
},
166-
}
167-
168-
job := createJob(context, "na-job", 1, 1, "nginx", slot, affinity)
169-
err := waitJobReady(context, job.Name)
170-
Expect(err).NotTo(HaveOccurred())
171-
172-
pods := getPodOfJob(context, "na-job")
173-
for _, pod := range pods {
174-
Expect(pod.Spec.NodeName).To(Equal(nodeName))
175-
}
176-
})
177-
178-
It("Reclaim", func() {
179-
context := initTestContext()
180-
defer cleanupTestContext(context)
181-
182-
jobName1 := "n1/qj-1"
183-
jobName2 := "n2/qj-2"
184-
185-
slot := oneCPU
186-
rep := clusterSize(context, slot)
187-
188-
createJob(context, jobName1, 1, rep, "nginx", slot, nil)
189-
err := waitJobReady(context, jobName1)
190-
Expect(err).NotTo(HaveOccurred())
191-
192-
expected := int(rep) / 2
193-
// Reduce one pod to tolerate decimal fraction.
194-
if expected > 1 {
195-
expected--
196-
} else {
197-
err := fmt.Errorf("expected replica <%d> is too small", expected)
198-
Expect(err).NotTo(HaveOccurred())
199-
}
200-
201-
createJob(context, jobName2, 1, rep, "nginx", slot, nil)
202-
err = waitTasksReady(context, jobName2, expected)
203-
Expect(err).NotTo(HaveOccurred())
204-
205-
err = waitTasksReady(context, jobName1, expected)
206-
Expect(err).NotTo(HaveOccurred())
207-
})
208-
209-
It("Hostport", func() {
210-
context := initTestContext()
211-
defer cleanupTestContext(context)
212-
213-
nn := clusterNodeNumber(context)
214-
215-
containers := createContainers("nginx", oneCPU, 28080)
216-
job := createJobWithOptions(context, "kube-batch", "qj-1", int32(nn), int32(nn*2), nil, containers)
217-
218-
err := waitTasksReady(context, job.Name, nn)
219-
Expect(err).NotTo(HaveOccurred())
220-
221-
err = waitTasksNotReady(context, job.Name, nn)
222-
Expect(err).NotTo(HaveOccurred())
223-
})
224-
225136
It("Schedule BestEffort Job", func() {
226137
context := initTestContext()
227138
defer cleanupTestContext(context)

test/e2e/predicates.go

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
. "github.com/onsi/ginkgo"
21+
. "github.com/onsi/gomega"
22+
23+
"k8s.io/api/core/v1"
24+
"k8s.io/kubernetes/pkg/scheduler/algorithm"
25+
)
26+
27+
var _ = Describe("Predicates E2E Test", func() {
28+
It("NodeAffinity", func() {
29+
context := initTestContext()
30+
defer cleanupTestContext(context)
31+
32+
slot := oneCPU
33+
nodeName, rep := computeNode(context, oneCPU)
34+
Expect(rep).NotTo(Equal(0))
35+
36+
affinity := &v1.Affinity{
37+
NodeAffinity: &v1.NodeAffinity{
38+
RequiredDuringSchedulingIgnoredDuringExecution: &v1.NodeSelector{
39+
NodeSelectorTerms: []v1.NodeSelectorTerm{
40+
{
41+
MatchFields: []v1.NodeSelectorRequirement{
42+
{
43+
Key: algorithm.NodeFieldSelectorKeyNodeName,
44+
Operator: v1.NodeSelectorOpIn,
45+
Values: []string{nodeName},
46+
},
47+
},
48+
},
49+
},
50+
},
51+
},
52+
}
53+
54+
job := createJob(context, "na-job", 1, 1, "nginx", slot, affinity)
55+
err := waitJobReady(context, job.Name)
56+
Expect(err).NotTo(HaveOccurred())
57+
58+
pods := getPodOfJob(context, "na-job")
59+
for _, pod := range pods {
60+
Expect(pod.Spec.NodeName).To(Equal(nodeName))
61+
}
62+
})
63+
64+
It("Hostport", func() {
65+
context := initTestContext()
66+
defer cleanupTestContext(context)
67+
68+
nn := clusterNodeNumber(context)
69+
70+
containers := createContainers("nginx", oneCPU, 28080)
71+
job := createJobWithOptions(context, "kube-batch", "qj-1", int32(nn), int32(nn*2), nil, containers)
72+
73+
err := waitTasksReady(context, job.Name, nn)
74+
Expect(err).NotTo(HaveOccurred())
75+
76+
err = waitTasksNotReady(context, job.Name, nn)
77+
Expect(err).NotTo(HaveOccurred())
78+
})
79+
})

test/e2e/queue.go

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
"fmt"
21+
22+
. "github.com/onsi/ginkgo"
23+
. "github.com/onsi/gomega"
24+
)
25+
26+
var _ = Describe("Predicates E2E Test", func() {
27+
28+
It("Reclaim", func() {
29+
context := initTestContext()
30+
defer cleanupTestContext(context)
31+
32+
jobName1 := "n1/qj-1"
33+
jobName2 := "n2/qj-2"
34+
35+
slot := oneCPU
36+
rep := clusterSize(context, slot)
37+
38+
createJob(context, jobName1, 1, rep, "nginx", slot, nil)
39+
err := waitJobReady(context, jobName1)
40+
Expect(err).NotTo(HaveOccurred())
41+
42+
expected := int(rep) / 2
43+
// Reduce one pod to tolerate decimal fraction.
44+
if expected > 1 {
45+
expected--
46+
} else {
47+
err := fmt.Errorf("expected replica <%d> is too small", expected)
48+
Expect(err).NotTo(HaveOccurred())
49+
}
50+
51+
createJob(context, jobName2, 1, rep, "nginx", slot, nil)
52+
err = waitTasksReady(context, jobName2, expected)
53+
Expect(err).NotTo(HaveOccurred())
54+
55+
err = waitTasksReady(context, jobName1, expected)
56+
Expect(err).NotTo(HaveOccurred())
57+
})
58+
59+
})

test/e2e/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package test
17+
package e2e
1818

1919
import (
2020
"os"

0 commit comments

Comments
 (0)