@@ -124,13 +124,13 @@ func TestUserWatermarkReclaimManager_Reconcile_CreateReclaimers(t *testing.T) {
124124 conf .UserWatermarkConfiguration .ServiceLabel = "svc-label"
125125
126126 // add a cgroup level configuration
127- cgPath := "/sys/fs/cgroup/memory/custom"
127+ cgPath := "/sys/fs/cgroup/memory/custom-test-create "
128128 conf .UserWatermarkConfiguration .CgroupConfig [cgPath ] = userwmconfig .NewReclaimConfigDetail (conf .UserWatermarkConfiguration .DefaultConfig )
129129
130130 podObj := & v1.Pod {
131131 ObjectMeta : metav1.ObjectMeta {
132- UID : "pod-uid-1" ,
133- Name : "test-pod" ,
132+ UID : "pod-uid-1-test-create " ,
133+ Name : "test-pod-create " ,
134134 Namespace : "default" ,
135135 Annotations : map [string ]string {
136136 katalystapiconsts .PodAnnotationQoSLevelKey : katalystapiconsts .PodAnnotationQoSLevelSharedCores ,
@@ -144,7 +144,7 @@ func TestUserWatermarkReclaimManager_Reconcile_CreateReclaimers(t *testing.T) {
144144 ContainerStatuses : []v1.ContainerStatus {
145145 {
146146 Name : "c1" ,
147- ContainerID : "containerd://cid-1" ,
147+ ContainerID : "containerd://cid-1-test-create " ,
148148 Ready : true ,
149149 },
150150 },
@@ -156,7 +156,7 @@ func TestUserWatermarkReclaimManager_Reconcile_CreateReclaimers(t *testing.T) {
156156 // patch container cgroup path helper to avoid touching real cgroups
157157 mockey .Mock (common .GetContainerAbsCgroupPath ).
158158 To (func (_ string , podUID , containerID string ) (string , error ) {
159- return "/sys/fs/cgroup/memory/test-cgroup" , nil
159+ return "/sys/fs/cgroup/memory/test-cgroup-create " , nil
160160 }).Build ()
161161
162162 m := NewUserWatermarkReclaimManager (qosConfig , dynamicConf , metrics.DummyMetrics {}, ms )
@@ -240,33 +240,34 @@ func TestUserWatermarkReclaimManager_Reconcile_CleanupStaleReclaimers(t *testing
240240
241241 m := NewUserWatermarkReclaimManager (qosConfig , dynamicConf , metrics.DummyMetrics {}, ms )
242242
243- podContainerKey := katalystcoreconsts .PodContainerName ("pod-1,container-1" )
244- cgPath := "/sys/fs/cgroup/memory/old"
243+ // Generate unique keys to avoid potential conflicts with other parallel tests
244+ podContainerKey := katalystcoreconsts .PodContainerName ("pod-1,container-1-test-cleanup" )
245+ cgPath := "/sys/fs/cgroup/memory/old-test-cleanup"
245246
246247 frContainer := & fakeReclaimer {}
247248 frCgroup := & fakeReclaimer {}
248249
250+ // Directly set the state since we're testing the reconcile logic
249251 m .containerReclaimer [podContainerKey ] = frContainer
250252 m .cgroupPathReclaimer [cgPath ] = frCgroup
251-
252253 m .started [string (podContainerKey )] = true
253254 m .started [cgPath ] = true
254255
255256 // no CgroupConfig for cgPath, and no pods => both reclaimers should be cleaned
256257 m .reconcile ()
257258
258259 _ , exist := m .containerReclaimer [podContainerKey ]
259- assert .False (t , exist )
260+ assert .False (t , exist , "container reclaimer should be cleaned up" )
260261
261262 _ , exist = m .cgroupPathReclaimer [cgPath ]
262- assert .False (t , exist )
263+ assert .False (t , exist , "cgroup path reclaimer should be cleaned up" )
263264
264265 _ , exist = m .started [string (podContainerKey )]
265- assert .False (t , exist )
266+ assert .False (t , exist , "container started flag should be removed" )
266267
267268 _ , exist = m .started [cgPath ]
268- assert .False (t , exist )
269+ assert .False (t , exist , "cgroup path started flag should be removed" )
269270
270- assert .True (t , frContainer .stopped )
271- assert .True (t , frCgroup .stopped )
271+ assert .True (t , frContainer .stopped , "container reclaimer should be stopped" )
272+ assert .True (t , frCgroup .stopped , "cgroup path reclaimer should be stopped" )
272273}
0 commit comments