Skip to content

Commit b73bca6

Browse files
Replace hardcoded nginx:alpine with nginxAlpineImage constant
Refactor test file to use the existing nginxAlpineImage constant instead of hardcoded strings for consistency with other parts of the codebase. Co-authored-by: Copilot <[email protected]>
1 parent 0c94d77 commit b73bca6

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

test/e2e/controller-manager/model_serving_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,9 +1383,9 @@ func TestModelServingPartitionBoundaryProtection(t *testing.T) {
13831383

13841384
// Trigger rolling update by changing image
13851385
updatedMS := initialMS.DeepCopy()
1386-
updatedMS.Spec.Template.Roles[0].EntryTemplate.Spec.Containers[0].Image = "nginx:alpine"
1386+
updatedMS.Spec.Template.Roles[0].EntryTemplate.Spec.Containers[0].Image = nginxAlpineImage
13871387

1388-
t.Log("Updating ModelServing image to nginx:alpine (partition=3 protects R-0, R-1, R-2)")
1388+
t.Logf("Updating ModelServing image to %s (partition=3 protects R-0, R-1, R-2)", nginxAlpineImage)
13891389
_, err = kthenaClient.WorkloadV1alpha1().ModelServings(testNamespace).Update(ctx, updatedMS, metav1.UpdateOptions{})
13901390
require.NoError(t, err, "Failed to update ModelServing")
13911391

@@ -1419,7 +1419,7 @@ func TestModelServingPartitionBoundaryProtection(t *testing.T) {
14191419
t.Log("Verifying per-ordinal revisions and images")
14201420
labelSelector := modelServingLabelSelector(modelServing.Name)
14211421
waitForPodsByLabel(t, ctx, kubeClient, labelSelector, 3*time.Minute, func(pods []corev1.Pod) bool {
1422-
protectedCorrect, updatedCorrect := verifyPartitionState(t, pods, int(partition), nginxImage, "nginx:alpine")
1422+
protectedCorrect, updatedCorrect := verifyPartitionState(t, pods, int(partition), nginxImage, nginxAlpineImage)
14231423
t.Logf("Protected correct: %d/3, Updated correct: %d/2", protectedCorrect, updatedCorrect)
14241424
return protectedCorrect == 3 && updatedCorrect == 2
14251425
}, "Per-ordinal revision/image verification failed")
@@ -1449,9 +1449,9 @@ func TestModelServingPartitionDeletedGroupHistoricalRevision(t *testing.T) {
14491449

14501450
// Phase 2: Trigger partitioned update (change image)
14511451
updatedMS := initialMS.DeepCopy()
1452-
updatedMS.Spec.Template.Roles[0].EntryTemplate.Spec.Containers[0].Image = "nginx:alpine"
1452+
updatedMS.Spec.Template.Roles[0].EntryTemplate.Spec.Containers[0].Image = nginxAlpineImage
14531453

1454-
t.Log("Phase 2: Updating image to nginx:alpine (partition=3 protects R-0, R-1, R-2)")
1454+
t.Logf("Phase 2: Updating image to %s (partition=3 protects R-0, R-1, R-2)", nginxAlpineImage)
14551455
_, err = kthenaClient.WorkloadV1alpha1().ModelServings(testNamespace).Update(ctx, updatedMS, metav1.UpdateOptions{})
14561456
require.NoError(t, err, "Failed to update ModelServing")
14571457

@@ -1472,7 +1472,7 @@ func TestModelServingPartitionDeletedGroupHistoricalRevision(t *testing.T) {
14721472
// Verify the partitioned state is established: R-0,R-1,R-2 have old image, R-3,R-4 have new
14731473
labelSelector := modelServingLabelSelector(modelServing.Name)
14741474
waitForPodsByLabel(t, ctx, kubeClient, labelSelector, 3*time.Minute, func(pods []corev1.Pod) bool {
1475-
protectedOld, updatedNew := verifyPartitionState(t, pods, int(partition), nginxImage, "nginx:alpine")
1475+
protectedOld, updatedNew := verifyPartitionState(t, pods, int(partition), nginxImage, nginxAlpineImage)
14761476
return protectedOld == 3 && updatedNew == 2
14771477
}, "Failed to reach partitioned state")
14781478

@@ -1562,7 +1562,7 @@ func TestModelServingPartitionDeletedGroupHistoricalRevision(t *testing.T) {
15621562
// Also verify the overall state is still correct: 3 protected + 2 updated
15631563
t.Log("Verifying overall partition state is preserved after pod recreation")
15641564
waitForPodsByLabel(t, ctx, kubeClient, labelSelector, 3*time.Minute, func(pods []corev1.Pod) bool {
1565-
protectedOld, updatedNew := verifyPartitionState(t, pods, int(partition), nginxImage, "nginx:alpine")
1565+
protectedOld, updatedNew := verifyPartitionState(t, pods, int(partition), nginxImage, nginxAlpineImage)
15661566
t.Logf("Protected with old image: %d/3, Updated with new image: %d/2", protectedOld, updatedNew)
15671567
return protectedOld == 3 && updatedNew == 2
15681568
}, "Overall partition state broken after pod recreation")
@@ -1591,9 +1591,9 @@ func TestModelServingRollingUpdate(t *testing.T) {
15911591

15921592
// Trigger rolling update by changing image
15931593
updatedMS := initialMS.DeepCopy()
1594-
updatedMS.Spec.Template.Roles[0].EntryTemplate.Spec.Containers[0].Image = "nginx:alpine"
1594+
updatedMS.Spec.Template.Roles[0].EntryTemplate.Spec.Containers[0].Image = nginxAlpineImage
15951595

1596-
t.Log("Triggering rolling update: image -> nginx:alpine (no partition, all replicas should update)")
1596+
t.Logf("Triggering rolling update: image -> %s (no partition, all replicas should update)", nginxAlpineImage)
15971597
_, err = kthenaClient.WorkloadV1alpha1().ModelServings(testNamespace).Update(ctx, updatedMS, metav1.UpdateOptions{})
15981598
require.NoError(t, err, "Failed to update ModelServing")
15991599

@@ -1622,7 +1622,7 @@ func TestModelServingRollingUpdate(t *testing.T) {
16221622
containerImage := getPodContainerImage(pod, "test-container")
16231623
podRevision := pod.Labels["modelserving.volcano.sh/revision"]
16241624

1625-
if containerImage != "nginx:alpine" {
1625+
if containerImage != nginxAlpineImage {
16261626
t.Logf("Pod %s still has old image: %s", pod.Name, containerImage)
16271627
allCorrect = false
16281628
}
@@ -1660,7 +1660,7 @@ func TestModelServingRollingUpdate(t *testing.T) {
16601660

16611661
containerImage := getPodContainerImage(pod, "test-container")
16621662
podRevision := pod.Labels["modelserving.volcano.sh/revision"]
1663-
if containerImage != "nginx:alpine" || podRevision != finalMS.Status.CurrentRevision {
1663+
if containerImage != nginxAlpineImage || podRevision != finalMS.Status.CurrentRevision {
16641664
return false
16651665
}
16661666
}

0 commit comments

Comments
 (0)