Skip to content

Commit 061bf04

Browse files
committed
Test cases for CustomPodResources.
Signed-off-by: dmatch01 <darroyo@us.ibm.com>
1 parent 2982c0d commit 061bf04

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed

test/e2e/queue.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,79 @@ var _ = Describe("AppWrapper E2E Test", func() {
284284

285285
})
286286

287+
It("MCAD Custom Pod Resources Test", func() {
288+
fmt.Fprintf(os.Stdout, "[e2e] MCAD Custom Pod Resources Test - Started.\n")
289+
context := initTestContext()
290+
var appwrappers []*arbv1.AppWrapper
291+
appwrappersPtr := &appwrappers
292+
defer cleanupTestObjectsPtr(context, appwrappersPtr)
293+
294+
// This should fit on cluster with customPodResources matching deployment resource demands so AW pods are created
295+
aw := createGenericDeploymentCustomPodResourcesWithCPUAW(
296+
context, "aw-deployment-2-550-vs-550-cpu", "550m", "550m", 2)
297+
298+
appwrappers = append(appwrappers, aw)
299+
300+
err := waitAWAnyPodsExists(context, aw)
301+
Expect(err).To(HaveOccurred())
302+
303+
err = waitAWPodsReady(context, aw)
304+
Expect(err).NotTo(HaveOccurred())
305+
})
306+
307+
308+
It("MCAD Bad Custom Pod Resources vs. Deployment Pod Resource Not Queuing Test", func() {
309+
fmt.Fprintf(os.Stdout, "[e2e] MCAD Bad Custom Pod Resources vs. Deployment Pod Resource Not Queuing Test - Started.\n")
310+
context := initTestContext()
311+
var appwrappers []*arbv1.AppWrapper
312+
appwrappersPtr := &appwrappers
313+
defer cleanupTestObjectsPtr(context, appwrappersPtr)
314+
315+
// This should fill up the worker node and most of the master node
316+
aw := createDeploymentAWwith550CPU(context, "aw-deployment-2-550cpu")
317+
appwrappers = append(appwrappers, aw)
318+
319+
err := waitAWPodsReady(context, aw)
320+
Expect(err).NotTo(HaveOccurred())
321+
322+
// This should not fit on cluster but customPodResources is incorrect so AW pods are created
323+
aw2 := createGenericDeploymentCustomPodResourcesWithCPUAW(
324+
context, "aw-deployment-2-425-vs-426-cpu", "425m", "426m", 2)
325+
326+
appwrappers = append(appwrappers, aw2)
327+
328+
err = waitAWAnyPodsExists(context, aw2)
329+
Expect(err).To(HaveOccurred())
330+
331+
err = waitAWPodsReady(context, aw2)
332+
Expect(err).NotTo(HaveOccurred())
333+
})
334+
335+
It("MCAD Bad Custom Pod Resources vs. Deployment Pod Resource Queuing Test 2", func() {
336+
fmt.Fprintf(os.Stdout, "[e2e] MCAD Bad Custom Pod Resources vs. Deployment Pod Resource Queuing Test 2 - Started.\n")
337+
context := initTestContext()
338+
var appwrappers []*arbv1.AppWrapper
339+
appwrappersPtr := &appwrappers
340+
defer cleanupTestObjectsPtr(context, appwrappersPtr)
341+
342+
// This should fill up the worker node and most of the master node
343+
aw := createDeploymentAWwith550CPU(context, "aw-deployment-2-550cpu")
344+
appwrappers = append(appwrappers, aw)
345+
346+
err := waitAWPodsReady(context, aw)
347+
Expect(err).NotTo(HaveOccurred())
348+
349+
// This should fit on cluster but customPodResources is incorrect so AW pods are not created
350+
aw2 := createGenericDeploymentCustomPodResourcesWithCPUAW(
351+
context, "aw-deployment-2-426-vs-425-cpu", "426m", "425m", 2)
352+
353+
appwrappers = append(appwrappers, aw2)
354+
355+
err = waitAWAnyPodsExists(context, aw2)
356+
Expect(err).NotTo(HaveOccurred())
357+
358+
})
359+
287360
It("MCAD CPU Accounting Queuing Test", func() {
288361
fmt.Fprintf(os.Stdout, "[e2e] MCAD CPU Accounting Queuing Test - Started.\n")
289362
context := initTestContext()

test/e2e/util.go

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,94 @@ func createGenericDeploymentWithCPUAW(context *context, name string, cpuDemand s
15921592
return appwrapper
15931593
}
15941594

1595+
func createGenericDeploymentCustomPodResourcesWithCPUAW(context *context, name string, customPodCpuDemand string, cpuDemand string, replicas int) *arbv1.AppWrapper {
1596+
rb := []byte(fmt.Sprintf(`{
1597+
"apiVersion": "apps/v1",
1598+
"kind": "Deployment",
1599+
"metadata": {
1600+
"name": "%s",
1601+
"namespace": "test",
1602+
"labels": {
1603+
"app": "%s"
1604+
}
1605+
},
1606+
"spec": {
1607+
"replicas": %d,
1608+
"selector": {
1609+
"matchLabels": {
1610+
"app": "%s"
1611+
}
1612+
},
1613+
"template": {
1614+
"metadata": {
1615+
"labels": {
1616+
"app": "%s"
1617+
},
1618+
"annotations": {
1619+
"appwrapper.mcad.ibm.com/appwrapper-name": "%s"
1620+
}
1621+
},
1622+
"spec": {
1623+
"containers": [
1624+
{
1625+
"name": "%s",
1626+
"image": "k8s.gcr.io/echoserver:1.4",
1627+
"resources": {
1628+
"requests": {
1629+
"cpu": "%s"
1630+
}
1631+
},
1632+
"ports": [
1633+
{
1634+
"containerPort": 80
1635+
}
1636+
]
1637+
}
1638+
]
1639+
}
1640+
}
1641+
}} `, name, name, replicas, name, name, name, name, cpuDemand))
1642+
1643+
var schedSpecMin int = replicas
1644+
var customCpuResource = v1.ResourceList{"cpu": resource.MustParse(customPodCpuDemand)}
1645+
1646+
aw := &arbv1.AppWrapper{
1647+
ObjectMeta: metav1.ObjectMeta{
1648+
Name: name,
1649+
Namespace: context.namespace,
1650+
},
1651+
Spec: arbv1.AppWrapperSpec{
1652+
SchedSpec: arbv1.SchedulingSpecTemplate{
1653+
MinAvailable: schedSpecMin,
1654+
},
1655+
AggrResources: arbv1.AppWrapperResourceList{
1656+
GenericItems: []arbv1.AppWrapperGenericResource{
1657+
{
1658+
ObjectMeta: metav1.ObjectMeta{
1659+
Name: fmt.Sprintf("%s-%s", name, "item1"),
1660+
Namespace: context.namespace,
1661+
},
1662+
CustomPodResources: []arbv1.CustomPodResourceTemplate{
1663+
{
1664+
Replicas: replicas,
1665+
Requests: customCpuResource,
1666+
},
1667+
},
1668+
GenericTemplate: runtime.RawExtension{
1669+
Raw: rb,
1670+
},
1671+
},
1672+
},
1673+
},
1674+
},
1675+
}
1676+
1677+
appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw)
1678+
Expect(err).NotTo(HaveOccurred())
1679+
1680+
return appwrapper
1681+
}
1682+
15951683
func createNamespaceAW(context *context, name string) *arbv1.AppWrapper {
15961684
rb := []byte(`{"apiVersion": "v1",
15971685
"kind": "Namespace",

0 commit comments

Comments
 (0)