|
1 | | -// Copyright 2026 The Kubernetes Authors. |
| 1 | +// Copyright The Kubernetes Authors. |
2 | 2 | // |
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | // you may not use this file except in compliance with the License. |
@@ -61,18 +61,24 @@ func TestPVCPersistenceAcrossReplicas(t *testing.T) { |
61 | 61 | nameHash := NameHash(pvcSandboxName) |
62 | 62 |
|
63 | 63 | // Namespace |
64 | | - ns := &corev1.Namespace{} |
65 | | - ns.Name = fmt.Sprintf("pvc-persistence-test-%d", time.Now().UnixNano()) |
| 64 | + ns := &corev1.Namespace{ |
| 65 | + ObjectMeta: metav1.ObjectMeta{ |
| 66 | + Name: fmt.Sprintf("pvc-persistence-test-%d", time.Now().UnixNano()), |
| 67 | + }, |
| 68 | + } |
66 | 69 | require.NoError(t, tc.CreateWithCleanup(ctx, ns)) |
67 | 70 |
|
68 | 71 | // Sandbox with PVC |
69 | 72 | sandboxObj := pvcSandbox(ns.Name) |
70 | 73 | require.NoError(t, tc.CreateWithCleanup(ctx, sandboxObj)) |
71 | 74 |
|
72 | 75 | pvcName := fmt.Sprintf("%s-%s", workspacesPVCTemplateName, pvcSandboxName) |
73 | | - pvc := &corev1.PersistentVolumeClaim{} |
74 | | - pvc.Name = pvcName |
75 | | - pvc.Namespace = ns.Name |
| 76 | + pvc := &corev1.PersistentVolumeClaim{ |
| 77 | + ObjectMeta: metav1.ObjectMeta{ |
| 78 | + Name: pvcName, |
| 79 | + Namespace: ns.Name, |
| 80 | + }, |
| 81 | + } |
76 | 82 |
|
77 | 83 | // Wait for sandbox to be ready with 1 replica |
78 | 84 | t.Logf("Waiting for sandbox to become ready (replicas=1)") |
@@ -135,9 +141,12 @@ func TestPVCPersistenceAcrossReplicas(t *testing.T) { |
135 | 141 | t.Logf("Sandbox status shows replicas=0") |
136 | 142 |
|
137 | 143 | // Pod must be gone |
138 | | - pod := &corev1.Pod{} |
139 | | - pod.Name = pvcSandboxName |
140 | | - pod.Namespace = ns.Name |
| 144 | + pod := &corev1.Pod{ |
| 145 | + ObjectMeta: metav1.ObjectMeta{ |
| 146 | + Name: pvcSandboxName, |
| 147 | + Namespace: ns.Name, |
| 148 | + }, |
| 149 | + } |
141 | 150 | require.NoError(t, tc.WaitForObjectNotFound(ctx, pod)) |
142 | 151 | t.Logf("Pod deleted") |
143 | 152 |
|
|
0 commit comments