Skip to content

Commit 24e7ec7

Browse files
committed
fix jsonpatch test
1 parent 374faa8 commit 24e7ec7

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

test/integration/model_jsonpatch_test.go

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import (
1313
"sigs.k8s.io/controller-runtime/pkg/client"
1414
)
1515

16-
// TestModelProfiles tests that profiles are applied as expected.
16+
// Test that patch can apply the priorityClassName to the model pod.
1717
func TestJSONPatch(t *testing.T) {
18+
const expectedPriorityClassName = "test-patch-priority-class"
1819
sysCfg := baseSysCfg(t)
1920
initTest(t, sysCfg)
2021
priorityClass := &schedulingv1.PriorityClass{
2122
ObjectMeta: metav1.ObjectMeta{
22-
Name: "test-priority-class",
23+
Name: expectedPriorityClassName,
2324
},
2425
}
2526
require.NoError(t, testK8sClient.Create(testCtx, priorityClass))
@@ -28,7 +29,6 @@ func TestJSONPatch(t *testing.T) {
2829
m := modelForTest(t)
2930
// Make sure there is a Pod created to run assertions against.
3031
m.Spec.MinReplicas = 1
31-
const expectedPriorityClassName = "test-priority-class"
3232
m.Spec.JSONPatches = []v1.JSONPatch{
3333
{
3434
Op: "add",
@@ -53,30 +53,5 @@ func TestJSONPatch(t *testing.T) {
5353
// Verify the priorityClassName is set on the pod
5454
assert.Equal(t, expectedPriorityClassName, pod.Spec.PriorityClassName)
5555

56-
}, 5*time.Second, time.Second/10, "Resource profile and ModelServerPods settings should be applied to the model Pod object")
57-
58-
const userImage = "my-repo.com/my-repo/my-image:latest"
59-
require.EventuallyWithT(t, func(t *assert.CollectT) {
60-
if !assert.NoError(t, testK8sClient.Get(testCtx, client.ObjectKeyFromObject(m), m)) {
61-
return
62-
}
63-
m.Spec.Image = userImage
64-
require.NoError(t, testK8sClient.Update(testCtx, m))
65-
}, 2*time.Second, time.Second/10, "Update model with user specified image")
66-
67-
require.NoError(t, testK8sClient.Delete(testCtx, pod))
68-
require.EventuallyWithT(t, func(t *assert.CollectT) {
69-
podList := &corev1.PodList{}
70-
if !assert.NoError(t, testK8sClient.List(testCtx, podList, client.InNamespace(testNS), client.MatchingLabels{"model": m.Name})) {
71-
return
72-
}
73-
if !assert.Len(t, podList.Items, 1) {
74-
return
75-
}
76-
pod = &podList.Items[0]
77-
78-
// The Pod should have a single container named "server".
79-
container := mustFindPodContainerByName(t, pod, "server")
80-
assert.Equal(t, userImage, container.Image)
81-
}, 15*time.Second, time.Second/10, "User specified image should be respected")
56+
}, 5*time.Second, time.Second/10, "Pod should have the correct priorityClassName")
8257
}

0 commit comments

Comments
 (0)