Skip to content

Commit 7062ab0

Browse files
authored
Merge pull request #11124 from cahillsf/improve-mpc-unit-test
🌱 Improve TestReconcileMachinePoolMachines unit test
2 parents 3232abc + 35cf278 commit 7062ab0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

exp/internal/controllers/machinepool_controller_phases_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,20 +1322,20 @@ func TestReconcileMachinePoolMachines(t *testing.T) {
13221322
g.Expect(err).ToNot(HaveOccurred())
13231323

13241324
cluster := builder.Cluster(ns.Name, clusterName).Build()
1325-
g.Expect(env.Create(ctx, cluster)).To(Succeed())
1325+
g.Expect(env.CreateAndWait(ctx, cluster)).To(Succeed())
13261326

13271327
t.Run("Should do nothing if machines already exist", func(*testing.T) {
13281328
machinePool := getMachinePool(2, "machinepool-test-1", clusterName, ns.Name)
1329-
g.Expect(env.Create(ctx, &machinePool)).To(Succeed())
1329+
g.Expect(env.CreateAndWait(ctx, &machinePool)).To(Succeed())
13301330

13311331
infraMachines := getInfraMachines(2, machinePool.Name, clusterName, ns.Name)
13321332
for i := range infraMachines {
1333-
g.Expect(env.Create(ctx, &infraMachines[i])).To(Succeed())
1333+
g.Expect(env.CreateAndWait(ctx, &infraMachines[i])).To(Succeed())
13341334
}
13351335

13361336
machines := getMachines(2, machinePool.Name, clusterName, ns.Name)
13371337
for i := range machines {
1338-
g.Expect(env.Create(ctx, &machines[i])).To(Succeed())
1338+
g.Expect(env.CreateAndWait(ctx, &machines[i])).To(Succeed())
13391339
}
13401340

13411341
infraConfig := map[string]interface{}{
@@ -1365,7 +1365,7 @@ func TestReconcileMachinePoolMachines(t *testing.T) {
13651365
"infrastructureMachineKind": builder.GenericInfrastructureMachineKind,
13661366
},
13671367
}
1368-
g.Expect(env.Create(ctx, &unstructured.Unstructured{Object: infraConfig})).To(Succeed())
1368+
g.Expect(env.CreateAndWait(ctx, &unstructured.Unstructured{Object: infraConfig})).To(Succeed())
13691369

13701370
r := &MachinePoolReconciler{
13711371
Client: env,
@@ -1394,11 +1394,11 @@ func TestReconcileMachinePoolMachines(t *testing.T) {
13941394

13951395
t.Run("Should create two machines if two infra machines exist", func(*testing.T) {
13961396
machinePool := getMachinePool(2, "machinepool-test-2", clusterName, ns.Name)
1397-
g.Expect(env.Create(ctx, &machinePool)).To(Succeed())
1397+
g.Expect(env.CreateAndWait(ctx, &machinePool)).To(Succeed())
13981398

13991399
infraMachines := getInfraMachines(2, machinePool.Name, clusterName, ns.Name)
14001400
for i := range infraMachines {
1401-
g.Expect(env.Create(ctx, &infraMachines[i])).To(Succeed())
1401+
g.Expect(env.CreateAndWait(ctx, &infraMachines[i])).To(Succeed())
14021402
}
14031403

14041404
infraConfig := map[string]interface{}{
@@ -1428,7 +1428,7 @@ func TestReconcileMachinePoolMachines(t *testing.T) {
14281428
"infrastructureMachineKind": builder.GenericInfrastructureMachineKind,
14291429
},
14301430
}
1431-
g.Expect(env.Create(ctx, &unstructured.Unstructured{Object: infraConfig})).To(Succeed())
1431+
g.Expect(env.CreateAndWait(ctx, &unstructured.Unstructured{Object: infraConfig})).To(Succeed())
14321432

14331433
r := &MachinePoolReconciler{
14341434
Client: env,
@@ -1487,7 +1487,7 @@ func TestReconcileMachinePoolMachines(t *testing.T) {
14871487
},
14881488
},
14891489
}
1490-
g.Expect(env.Create(ctx, &unstructured.Unstructured{Object: infraConfig})).To(Succeed())
1490+
g.Expect(env.CreateAndWait(ctx, &unstructured.Unstructured{Object: infraConfig})).To(Succeed())
14911491

14921492
r := &MachinePoolReconciler{
14931493
Client: env,

0 commit comments

Comments
 (0)