@@ -2283,6 +2283,85 @@ func TestWorkloadReconciler(t *testing.T) {
22832283 },
22842284 wantResult : reconcile.Result {RequeueAfter : initializationRetryAfter },
22852285 },
2286+ "should adopt existing long-named slice when ShorterSliceNameLength feature gate enabled" : {
2287+ enableShorterSliceNameLength : true ,
2288+ request : types.NamespacedName {Name : "very-long-workload-name-exceeding-limit-for-testing" , Namespace : corev1 .NamespaceDefault },
2289+ objs : []client.Object {
2290+ worker1Node .DeepCopy (),
2291+ worker2Node .DeepCopy (),
2292+ baseAdmissionCheckWrapper .DeepCopy (),
2293+ utiltesting .MakeWorkload ("very-long-workload-name-exceeding-limit-for-testing" , corev1 .NamespaceDefault ).
2294+ UID ("very-long-workload-name-exceeding-limit-for-testing" ).
2295+ PodSets (basePodSets ... ).
2296+ ReserveQuota (baseAdmission , now ).
2297+ ControllerReference (jobSetGVK , baseJobSetName , baseJobSetName ).
2298+ Finalizers (SliceControllerName ).
2299+ AdmissionCheck (buildAdmissionCheckState (kueue .CheckStatePending , "" )).
2300+ Obj (),
2301+ baseJobSetWrapper .Clone ().Obj (),
2302+ // Existing Slices with LONG names
2303+ utiltesting .MakeSliceWrapper (core .SliceNameWithMaxLen ("default" , "very-long-workload-name-exceeding-limit-for-testing" , "ps1" , 0 , 54 )).
2304+ Type (slice .TypeTpu7x ).
2305+ Topology ("4x4x4" ).
2306+ OwnerWorkloadAnnotations ("default" , "very-long-workload-name-exceeding-limit-for-testing" ).
2307+ PartitionIDs ("subblock1" ).
2308+ Active ().
2309+ Obj (),
2310+ utiltesting .MakeSliceWrapper (core .SliceNameWithMaxLen ("default" , "very-long-workload-name-exceeding-limit-for-testing" , "ps2" , 0 , 54 )).
2311+ Type (slice .TypeTpu7x ).
2312+ Topology ("4x4x4" ).
2313+ OwnerWorkloadAnnotations ("default" , "very-long-workload-name-exceeding-limit-for-testing" ).
2314+ PartitionIDs ("subblock2" ).
2315+ Active ().
2316+ Obj (),
2317+ },
2318+ wantWorkloads : []kueue.Workload {
2319+ * utiltesting .MakeWorkload ("very-long-workload-name-exceeding-limit-for-testing" , corev1 .NamespaceDefault ).
2320+ UID ("very-long-workload-name-exceeding-limit-for-testing" ).
2321+ PodSets (basePodSets ... ).
2322+ ReserveQuota (baseAdmission , now ).
2323+ ControllerReference (jobSetGVK , baseJobSetName , baseJobSetName ).
2324+ Finalizers (SliceControllerName ).
2325+ AdmissionCheck (buildAdmissionCheckStateWithPodSetUpdates (kueue .CheckStateReady ,
2326+ `Slices are in states: 2 ACTIVE` ,
2327+ []kueue.PodSetUpdate {
2328+ {
2329+ Name : "ps1" ,
2330+ NodeSelector : map [string ]string {"cloud.google.com/gke-tpu-topology" : "4x4x4" },
2331+ },
2332+ {
2333+ Name : "ps2" ,
2334+ NodeSelector : map [string ]string {"cloud.google.com/gke-tpu-topology" : "4x4x4" },
2335+ },
2336+ })).
2337+ Obj (),
2338+ },
2339+ wantSlices : []slice.Slice {
2340+ * utiltesting .MakeSliceWrapper (core .SliceNameWithMaxLen ("default" , "very-long-workload-name-exceeding-limit-for-testing" , "ps2" , 0 , 54 )).
2341+ Type (slice .TypeTpu7x ).
2342+ Topology ("4x4x4" ).
2343+ OwnerWorkloadAnnotations ("default" , "very-long-workload-name-exceeding-limit-for-testing" ).
2344+ PartitionIDs ("subblock2" ).
2345+ Active ().
2346+ Obj (),
2347+ * utiltesting .MakeSliceWrapper (core .SliceNameWithMaxLen ("default" , "very-long-workload-name-exceeding-limit-for-testing" , "ps1" , 0 , 54 )).
2348+ Type (slice .TypeTpu7x ).
2349+ Topology ("4x4x4" ).
2350+ OwnerWorkloadAnnotations ("default" , "very-long-workload-name-exceeding-limit-for-testing" ).
2351+ PartitionIDs ("subblock1" ).
2352+ Active ().
2353+ Obj (),
2354+ },
2355+ wantJobSets : []jobset.JobSet {* baseJobSetWrapper .Clone ().Obj ()},
2356+ wantEvents : []utiltesting.EventRecord {
2357+ {
2358+ Key : client.ObjectKey {Namespace : corev1 .NamespaceDefault , Name : "very-long-workload-name-exceeding-limit-for-testing" },
2359+ EventType : corev1 .EventTypeNormal ,
2360+ Reason : AdmissionCheckUpdatedEventType ,
2361+ Message : fmt .Sprintf (`Admission check %q updated state from "Pending" to "Ready"` , baseACName ),
2362+ },
2363+ },
2364+ },
22862365 }
22872366 for name , tc := range testCases {
22882367 t .Run (name , func (t * testing.T ) {
0 commit comments