@@ -594,3 +594,32 @@ func TestUserWatermarkReclaimer_ReclaimGetStatsFailed(t *testing.T) {
594594 assert .Contains (t , result .Reason , "Get memory reclaimStats failed" )
595595 assert .Equal (t , uint64 (0 ), result .ReclaimedSize )
596596}
597+
598+ func TestUserWatermarkReclaimer_UpdateInstanceInfo (t * testing.T ) {
599+ t .Parallel ()
600+
601+ // Create test dependencies
602+ dynamicConf := dynamicconfig .NewDynamicAgentConfiguration ()
603+ instance := ReclaimInstance {CgroupPath : "/sys/fs/cgroup/memory/test" }
604+ r := NewUserWatermarkReclaimer (instance , (* metaserver .MetaServer )(nil ), metrics.DummyMetrics {}, dynamicConf )
605+
606+ // Update with new container info
607+ newContainerInfo := & types.ContainerInfo {
608+ PodUID : "new-pod-uid" ,
609+ PodNamespace : "new-namespace" ,
610+ PodName : "new-pod-name" ,
611+ ContainerName : "new-container-name" ,
612+ QoSLevel : "new-qos-level" ,
613+ Labels : map [string ]string {"key" : "value" },
614+ }
615+
616+ r .UpdateInstanceInfo (ReclaimInstance {
617+ ContainerInfo : newContainerInfo ,
618+ CgroupPath : "/sys/fs/cgroup/memory/new-path" , // This shouldn't change the cgroupPath
619+ })
620+
621+ // Verify container info was updated
622+ assert .Equal (t , newContainerInfo , r .containerInfo )
623+ // Verify cgroupPath wasn't changed (UpdateInstanceInfo shouldn't modify it)
624+ assert .Equal (t , "/sys/fs/cgroup/memory/test" , r .cgroupPath )
625+ }
0 commit comments