@@ -248,6 +248,54 @@ var moveTests = []struct {
248248 },
249249 wantErr : false ,
250250 },
251+ {
252+ name : "Cluster with MachineDeployment with a static bootstrap config" ,
253+ fields : moveTestsFields {
254+ objs : test .NewFakeCluster ("ns1" , "cluster1" ).
255+ WithMachineDeployments (
256+ test .NewFakeMachineDeployment ("md1" ).
257+ WithStaticBootstrapConfig ().
258+ WithMachineSets (
259+ test .NewFakeMachineSet ("ms1" ).
260+ WithStaticBootstrapConfig ().
261+ WithMachines (
262+ test .NewFakeMachine ("m1" ).
263+ WithStaticBootstrapConfig (),
264+ test .NewFakeMachine ("m2" ).
265+ WithStaticBootstrapConfig (),
266+ ),
267+ ),
268+ ).Objs (),
269+ },
270+ wantMoveGroups : [][]string {
271+ { // group 1
272+ "cluster.x-k8s.io/v1beta1, Kind=Cluster, ns1/cluster1" ,
273+ },
274+ { // group 2 (objects with ownerReferences in group 1)
275+ // owned by Clusters
276+ "/v1, Kind=Secret, ns1/cluster1-ca" ,
277+ "/v1, Kind=Secret, ns1/cluster1-kubeconfig" ,
278+ "cluster.x-k8s.io/v1beta1, Kind=MachineDeployment, ns1/md1" ,
279+ "infrastructure.cluster.x-k8s.io/v1beta1, Kind=GenericInfrastructureCluster, ns1/cluster1" ,
280+ "infrastructure.cluster.x-k8s.io/v1beta1, Kind=GenericInfrastructureMachineTemplate, ns1/md1" ,
281+ },
282+ { // group 3 (objects with ownerReferences in group 1,2)
283+ // owned by MachineDeployments
284+ "cluster.x-k8s.io/v1beta1, Kind=MachineSet, ns1/ms1" ,
285+ },
286+ { // group 4 (objects with ownerReferences in group 1,2,3)
287+ // owned by MachineSets
288+ "cluster.x-k8s.io/v1beta1, Kind=Machine, ns1/m1" ,
289+ "cluster.x-k8s.io/v1beta1, Kind=Machine, ns1/m2" ,
290+ },
291+ { // group 5 (objects with ownerReferences in group 1,2,3,4)
292+ // owned by Machines
293+ "infrastructure.cluster.x-k8s.io/v1beta1, Kind=GenericInfrastructureMachine, ns1/m1" ,
294+ "infrastructure.cluster.x-k8s.io/v1beta1, Kind=GenericInfrastructureMachine, ns1/m2" ,
295+ },
296+ },
297+ wantErr : false ,
298+ },
251299 {
252300 name : "Cluster with Control Plane" ,
253301 fields : moveTestsFields {
@@ -825,7 +873,7 @@ func Test_objectMover_restoreTargetObject(t *testing.T) {
825873 oTo .SetKind (node .identity .Kind )
826874
827875 if err := csTo .Get (ctx , key , oTo ); err != nil {
828- t .Errorf ("error = %v when checking for %v created in target cluster" , err , key )
876+ t .Errorf ("error = %v when checking for %s % v created in target cluster" , err , oTo . GetKind () , key )
829877 continue
830878 }
831879
@@ -853,7 +901,7 @@ func Test_objectMover_restoreTargetObject(t *testing.T) {
853901 oAfter .SetKind (node .identity .Kind )
854902
855903 if err := csAfter .Get (ctx , keyAfter , oAfter ); err != nil {
856- t .Errorf ("error = %v when checking for %v created in target cluster" , err , key )
904+ t .Errorf ("error = %v when checking for %s % v created in target cluster" , err , oAfter . GetKind () , key )
857905 continue
858906 }
859907
@@ -1076,7 +1124,7 @@ func Test_objectMover_fromDirectory(t *testing.T) {
10761124 oTo .SetKind (node .identity .Kind )
10771125
10781126 if err := csTo .Get (ctx , key , oTo ); err != nil {
1079- t .Errorf ("error = %v when checking for %v created in target cluster" , err , key )
1127+ t .Errorf ("error = %v when checking for %s % v created in target cluster" , err , oTo . GetKind () , key )
10801128 continue
10811129 }
10821130 }
@@ -1164,7 +1212,7 @@ func Test_objectMover_move_dryRun(t *testing.T) {
11641212 oFrom .SetKind (node .identity .Kind )
11651213
11661214 if err := csFrom .Get (ctx , key , oFrom ); err != nil {
1167- t .Errorf ("error = %v when checking for %v kept in source cluster" , err , key )
1215+ t .Errorf ("error = %v when checking for %s % v kept in source cluster" , err , oFrom . GetKind () , key )
11681216 continue
11691217 }
11701218
@@ -1176,11 +1224,11 @@ func Test_objectMover_move_dryRun(t *testing.T) {
11761224 err := csTo .Get (ctx , key , oTo )
11771225 if err == nil {
11781226 if oFrom .GetNamespace () != "" {
1179- t .Errorf ("%v created in target cluster which should not" , key )
1227+ t .Errorf ("%s % v created in target cluster which should not" , oFrom . GetKind () , key )
11801228 continue
11811229 }
11821230 } else if ! apierrors .IsNotFound (err ) {
1183- t .Errorf ("error = %v when checking for %v should not created ojects in target cluster" , err , key )
1231+ t .Errorf ("error = %v when checking for %s % v should not created ojects in target cluster" , err , oFrom . GetKind () , key )
11841232 continue
11851233 }
11861234 }
@@ -1240,11 +1288,11 @@ func Test_objectMover_move(t *testing.T) {
12401288 err := csFrom .Get (ctx , key , oFrom )
12411289 if err == nil {
12421290 if ! node .isGlobal && ! node .isGlobalHierarchy {
1243- t .Errorf ("%v not deleted in source cluster" , key )
1291+ t .Errorf ("%s % v not deleted in source cluster" , oFrom . GetKind () , key )
12441292 continue
12451293 }
12461294 } else if ! apierrors .IsNotFound (err ) {
1247- t .Errorf ("error = %v when checking for %v deleted in source cluster" , err , key )
1295+ t .Errorf ("error = %v when checking for %s % v deleted in source cluster" , err , oFrom . GetKind () , key )
12481296 continue
12491297 }
12501298
@@ -1254,7 +1302,7 @@ func Test_objectMover_move(t *testing.T) {
12541302 oTo .SetKind (node .identity .Kind )
12551303
12561304 if err := csTo .Get (ctx , key , oTo ); err != nil {
1257- t .Errorf ("error = %v when checking for %v created in target cluster" , err , key )
1305+ t .Errorf ("error = %v when checking for %s % v created in target cluster" , err , oFrom . GetKind () , key )
12581306 continue
12591307 }
12601308 }
@@ -1349,11 +1397,11 @@ func Test_objectMover_move_with_Mutator(t *testing.T) {
13491397 err := csFrom .Get (ctx , key , oFrom )
13501398 if err == nil {
13511399 if ! node .isGlobal && ! node .isGlobalHierarchy {
1352- t .Errorf ("%v not deleted in source cluster" , key )
1400+ t .Errorf ("%s % v not deleted in source cluster" , oFrom . GetKind () , key )
13531401 continue
13541402 }
13551403 } else if ! apierrors .IsNotFound (err ) {
1356- t .Errorf ("error = %v when checking for %v deleted in source cluster" , err , key )
1404+ t .Errorf ("error = %v when checking for %s % v deleted in source cluster" , err , oFrom . GetKind () , key )
13571405 continue
13581406 }
13591407
@@ -1366,7 +1414,7 @@ func Test_objectMover_move_with_Mutator(t *testing.T) {
13661414 }
13671415
13681416 if err := csTo .Get (ctx , key , oTo ); err != nil {
1369- t .Errorf ("error = %v when checking for %v created in target cluster" , err , key )
1417+ t .Errorf ("error = %v when checking for %s % v created in target cluster" , err , oFrom . GetKind () , key )
13701418 continue
13711419 }
13721420 if fields , knownKind := updateKnownKinds [oTo .GetKind ()]; knownKind {
0 commit comments