Skip to content

Commit 8ab2795

Browse files
committed
add podset integration test cases of PodGroup functions
Signed-off-by: freedown19 <[email protected]> add podset integration test cases of PodGroup functions Signed-off-by: freedown19 <[email protected]> add podgroup yamls in config dependency dir Signed-off-by: freedown19 <[email protected]> add podgroup yamls in config dependency dir Signed-off-by: freedown19 <[email protected]> add podgroup yamls in config dependency dir Signed-off-by: freedown19 <[email protected]> integration cases of roleset on podgroup Signed-off-by: freedown19 <[email protected]> integration cases of roleset on podgroup Signed-off-by: freedown19 <[email protected]> cleancode fix Signed-off-by: freedown19 <[email protected]> cleancode fix Signed-off-by: freedown19 <[email protected]> cleancode fix Signed-off-by: freedown19 <[email protected]>
1 parent 42e843f commit 8ab2795

File tree

10 files changed

+907
-18
lines changed

10 files changed

+907
-18
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## PodGroup CRD
2+
3+
- godel podgroup
4+
- volcano podgroup
5+
- x podgroup

config/dependency/podgroup/crds/scheduling.godel.kubewharf.io_podgroups.yaml

Lines changed: 340 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.6.0
8+
creationTimestamp: null
9+
name: podgroups.scheduling.volcano.sh
10+
spec:
11+
group: scheduling.volcano.sh
12+
names:
13+
kind: PodGroup
14+
listKind: PodGroupList
15+
plural: podgroups
16+
shortNames:
17+
- pg
18+
- podgroup-v1beta1
19+
singular: podgroup
20+
scope: Namespaced
21+
versions:
22+
- additionalPrinterColumns:
23+
- jsonPath: .status.phase
24+
name: STATUS
25+
type: string
26+
- jsonPath: .spec.minMember
27+
name: minMember
28+
type: integer
29+
- jsonPath: .status.running
30+
name: RUNNINGS
31+
type: integer
32+
- jsonPath: .metadata.creationTimestamp
33+
name: AGE
34+
type: date
35+
- jsonPath: .spec.queue
36+
name: QUEUE
37+
priority: 1
38+
type: string
39+
name: v1beta1
40+
schema:
41+
openAPIV3Schema:
42+
description: PodGroup is a collection of Pod; used for batch workload.
43+
properties:
44+
apiVersion:
45+
description: 'APIVersion defines the versioned schema of this representation
46+
of an object. Servers should convert recognized schemas to the latest
47+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
48+
type: string
49+
kind:
50+
description: 'Kind is a string value representing the REST resource this
51+
object represents. Servers may infer this from the endpoint the client
52+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
53+
type: string
54+
metadata:
55+
type: object
56+
spec:
57+
description: 'Specification of the desired behavior of the pod group.
58+
More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status'
59+
properties:
60+
minMember:
61+
description: MinMember defines the minimal number of members/tasks
62+
to run the pod group; if there's not enough resources to start all
63+
tasks, the scheduler will not start anyone.
64+
format: int32
65+
type: integer
66+
minResources:
67+
additionalProperties:
68+
anyOf:
69+
- type: integer
70+
- type: string
71+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
72+
x-kubernetes-int-or-string: true
73+
description: MinResources defines the minimal resource of members/tasks
74+
to run the pod group; if there's not enough resources to start all
75+
tasks, the scheduler will not start anyone.
76+
type: object
77+
minTaskMember:
78+
additionalProperties:
79+
format: int32
80+
type: integer
81+
description: MinTaskMember defines the minimal number of pods to run
82+
each task in the pod group; if there's not enough resources to start
83+
each task, the scheduler will not start anyone.
84+
type: object
85+
priorityClassName:
86+
description: If specified, indicates the PodGroup's priority. "system-node-critical"
87+
and "system-cluster-critical" are two special keywords which indicate
88+
the highest priorities with the former being the highest priority.
89+
Any other name must be defined by creating a PriorityClass object
90+
with that name. If not specified, the PodGroup priority will be
91+
default or zero if there is no default.
92+
type: string
93+
queue:
94+
description: Queue defines the queue to allocate resource for PodGroup;
95+
if queue does not exist, the PodGroup will not be scheduled. Defaults
96+
to `default` Queue with the lowest weight.
97+
type: string
98+
type: object
99+
status:
100+
description: Status represents the current information about a pod group.
101+
This data may not be up to date.
102+
properties:
103+
conditions:
104+
description: The conditions of PodGroup.
105+
items:
106+
description: PodGroupCondition contains details for the current
107+
state of this pod group.
108+
properties:
109+
lastTransitionTime:
110+
description: Last time the phase transitioned from another to
111+
current phase.
112+
format: date-time
113+
type: string
114+
message:
115+
description: Human-readable message indicating details about
116+
last transition.
117+
type: string
118+
reason:
119+
description: Unique, one-word, CamelCase reason for the phase's
120+
last transition.
121+
type: string
122+
status:
123+
description: Status is the status of the condition.
124+
type: string
125+
transitionID:
126+
description: The ID of condition transition.
127+
type: string
128+
type:
129+
description: Type is the type of the condition
130+
type: string
131+
type: object
132+
type: array
133+
failed:
134+
description: The number of pods which reached phase Failed.
135+
format: int32
136+
type: integer
137+
phase:
138+
description: Current phase of PodGroup.
139+
type: string
140+
running:
141+
description: The number of actively running pods.
142+
format: int32
143+
type: integer
144+
succeeded:
145+
description: The number of pods which reached phase Succeeded.
146+
format: int32
147+
type: integer
148+
type: object
149+
type: object
150+
served: true
151+
storage: true
152+
subresources: {}
153+
status:
154+
acceptedNames:
155+
kind: ""
156+
plural: ""
157+
conditions: []
158+
storedVersions: []
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/scheduler-plugins/pull/50
7+
controller-gen.kubebuilder.io/version: v0.16.5
8+
name: podgroups.scheduling.x-k8s.io
9+
spec:
10+
group: scheduling.x-k8s.io
11+
names:
12+
kind: PodGroup
13+
listKind: PodGroupList
14+
plural: podgroups
15+
shortNames:
16+
- pg
17+
- pgs
18+
singular: podgroup
19+
scope: Namespaced
20+
versions:
21+
- additionalPrinterColumns:
22+
- description: Current phase of PodGroup.
23+
jsonPath: .status.phase
24+
name: Phase
25+
type: string
26+
- description: MinMember defines the minimal number of members/tasks to run the
27+
pod group.
28+
jsonPath: .spec.minMember
29+
name: MinMember
30+
type: integer
31+
- description: The number of actively running pods.
32+
jsonPath: .status.running
33+
name: Running
34+
type: integer
35+
- description: The number of pods which reached phase Succeeded.
36+
jsonPath: .status.succeeded
37+
name: Succeeded
38+
type: integer
39+
- description: The number of pods which reached phase Failed.
40+
jsonPath: .status.failed
41+
name: Failed
42+
type: integer
43+
- description: Age is the time PodGroup was created.
44+
jsonPath: .metadata.creationTimestamp
45+
name: Age
46+
type: date
47+
name: v1alpha1
48+
schema:
49+
openAPIV3Schema:
50+
description: PodGroup is a collection of Pod; used for batch workload.
51+
properties:
52+
apiVersion:
53+
description: |-
54+
APIVersion defines the versioned schema of this representation of an object.
55+
Servers should convert recognized schemas to the latest internal value, and
56+
may reject unrecognized values.
57+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
58+
type: string
59+
kind:
60+
description: |-
61+
Kind is a string value representing the REST resource this object represents.
62+
Servers may infer this from the endpoint the client submits requests to.
63+
Cannot be updated.
64+
In CamelCase.
65+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
66+
type: string
67+
metadata:
68+
type: object
69+
spec:
70+
description: Specification of the desired behavior of the pod group.
71+
properties:
72+
minMember:
73+
description: |-
74+
MinMember defines the minimal number of members/tasks to run the pod group;
75+
if there's not enough resources to start all tasks, the scheduler
76+
will not start any.
77+
The minimum is 1
78+
format: int32
79+
minimum: 1
80+
type: integer
81+
minResources:
82+
additionalProperties:
83+
anyOf:
84+
- type: integer
85+
- type: string
86+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
87+
x-kubernetes-int-or-string: true
88+
description: |-
89+
MinResources defines the minimal resource of members/tasks to run the pod group;
90+
if there's not enough resources to start all tasks, the scheduler
91+
will not start any.
92+
type: object
93+
scheduleTimeoutSeconds:
94+
description: ScheduleTimeoutSeconds defines the maximal time of members/tasks
95+
to wait before run the pod group;
96+
format: int32
97+
type: integer
98+
type: object
99+
status:
100+
description: |-
101+
Status represents the current information about a pod group.
102+
This data may not be up to date.
103+
properties:
104+
failed:
105+
description: The number of pods which reached phase Failed.
106+
format: int32
107+
type: integer
108+
occupiedBy:
109+
description: |-
110+
OccupiedBy marks the workload (e.g., deployment, statefulset) UID that occupy the podgroup.
111+
It is empty if not initialized.
112+
type: string
113+
phase:
114+
description: Current phase of PodGroup.
115+
type: string
116+
running:
117+
description: The number of actively running pods.
118+
format: int32
119+
type: integer
120+
scheduleStartTime:
121+
description: ScheduleStartTime of the group
122+
format: date-time
123+
type: string
124+
succeeded:
125+
description: The number of pods which reached phase Succeeded.
126+
format: int32
127+
type: integer
128+
type: object
129+
type: object
130+
served: true
131+
storage: true
132+
subresources:
133+
status: {}

test/integration/controller/podset_test.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
corev1 "k8s.io/api/core/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"sigs.k8s.io/controller-runtime/pkg/client"
28+
volcanoschedv1beta1 "volcano.sh/apis/pkg/apis/scheduling/v1beta1"
2829

2930
orchestrationapi "github.com/vllm-project/aibrix/api/orchestration/v1alpha1"
3031
"github.com/vllm-project/aibrix/pkg/controller/constants"
@@ -34,6 +35,7 @@ import (
3435

3536
var _ = ginkgo.Describe("PodSet controller test", func() {
3637
var ns *corev1.Namespace
38+
// using for podgroup type
3739

3840
// update represents a test step: optional mutation + validation
3941
type update struct {
@@ -147,6 +149,68 @@ var _ = ginkgo.Describe("PodSet controller test", func() {
147149
},
148150
},
149151
),
152+
ginkgo.Entry("normal PodSet create and create its volcano podgroup",
153+
&testValidatingCase{
154+
makePodSet: func() *orchestrationapi.PodSet {
155+
podTemplate := corev1.PodTemplateSpec{
156+
ObjectMeta: metav1.ObjectMeta{
157+
Labels: map[string]string{
158+
"app": "nginx",
159+
},
160+
},
161+
Spec: corev1.PodSpec{
162+
Containers: []corev1.Container{
163+
{
164+
Name: "nginx",
165+
Image: "nginx:latest",
166+
},
167+
},
168+
},
169+
}
170+
schedulingStrategy := &orchestrationapi.SchedulingStrategy{
171+
VolcanoSchedulingStrategy: &orchestrationapi.VolcanoSchedulingStrategySpec{
172+
MinMember: int32(1), Queue: "default",
173+
},
174+
}
175+
176+
return wrapper.MakePodSet("podset-normal").
177+
Namespace(ns.Name).
178+
AddPodSetSchedulingStrategy(schedulingStrategy).
179+
PodTemplate(podTemplate).
180+
Obj()
181+
},
182+
updates: []*update{
183+
{
184+
// trigger PodSet all pods to ready
185+
updateFunc: func(podset *orchestrationapi.PodSet) {
186+
// Step 0: Create the PodSet
187+
gomega.Expect(k8sClient.Create(ctx, podset)).To(gomega.Succeed())
188+
// Step 1: List all Pods
189+
validation.WaitForPodsCreated(ctx, k8sClient, ns.Name, constants.PodSetNameLabelKey,
190+
podset.Name, 2)
191+
// Step 2: Patch all Pods to Running and Ready (simulate integration test environment)
192+
validation.MarkPodsReady(ctx, k8sClient, ns.Name, constants.PodSetNameLabelKey, podset.Name)
193+
},
194+
checkFunc: func(ctx context.Context, k8sClient client.Client, podset *orchestrationapi.PodSet) {
195+
expectedLabels := map[string]string{
196+
constants.PodSetNameLabelKey: podset.Name,
197+
}
198+
podGroup := &volcanoschedv1beta1.PodGroup{}
199+
podGroup.SetGroupVersionKind(volcanoschedv1beta1.SchemeGroupVersion.WithKind("PodGroup"))
200+
minMember := podset.Spec.SchedulingStrategy.VolcanoSchedulingStrategy.MinMember
201+
// Validate pg CRD exists
202+
validation.ValidatePodGroupCRDExist(ctx, dynamicClient, podGroup)
203+
// Validate pg Spec
204+
validation.ValidatePodGroupSpec(ctx, dynamicClient, podGroup, minMember,
205+
podset.Namespace, podset.Name)
206+
// Validate pg labels which is labelled by podSet controller
207+
validation.ValidatePodGroupLabels(ctx, dynamicClient, podGroup, expectedLabels,
208+
podset.Namespace, podset.Name)
209+
},
210+
},
211+
},
212+
},
213+
),
150214
// TODO: add more test case
151215
)
152216
})

0 commit comments

Comments
 (0)