Skip to content

Commit 1f11aef

Browse files
Merge pull request #5396 from ngopalak-redhat/ngopalak/backport-5239-to-4.20
OCPBUGS-65556: [release-4.20] Backport: Add delays to reduce TestOSBuildController failures
2 parents e2499c0 + 4e665d9 commit 1f11aef

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/controller/build/osbuildcontroller_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func TestOSBuildController(t *testing.T) {
291291
// new MachineOSBuild is produced from it. We'll do this 10 times.
292292
for i := 0; i <= 5; i++ {
293293
apiMosc := testhelpers.SetContainerfileContentsOnMachineOSConfig(ctx, t, mcfgclient, mosc, "FROM configs AS final"+fmt.Sprintf("%d", i))
294-
294+
time.Sleep(time.Millisecond * 200)
295295
apiMCP, err := mcfgclient.MachineconfigurationV1().MachineConfigPools().Get(ctx, apiMosc.Spec.MachineConfigPool.Name, metav1.GetOptions{})
296296
require.NoError(t, err)
297297

@@ -306,6 +306,7 @@ func TestOSBuildController(t *testing.T) {
306306
// Set the successful status on the job.
307307
fixtures.SetJobStatus(ctx, t, kubeclient, mosb, fixtures.JobStatus{Succeeded: 1})
308308
// The MachineOSBuild should be successful.
309+
time.Sleep(time.Millisecond * 200)
309310
kubeassert.MachineOSBuildIsSuccessful(mosb, "Expected the MachineOSBuild %s status to be successful", mosb.Name)
310311
// And the build job should be deleted.
311312
assertBuildObjectsAreDeleted(ctx, t, kubeassert, mosb)
@@ -333,6 +334,7 @@ func TestOSBuildController(t *testing.T) {
333334
require.NoError(t, err)
334335

335336
apiMCP := insertNewRenderedMachineConfigAndUpdatePool(ctx, t, mcfgclient, mosc.Spec.MachineConfigPool.Name, getConfigNameForPool(i+2))
337+
time.Sleep(time.Millisecond * 200)
336338

337339
mosb := buildrequest.NewMachineOSBuildFromAPIOrDie(ctx, kubeclient, apiMosc, apiMCP)
338340
buildJobName := utils.GetBuildJobName(mosb)
@@ -342,6 +344,7 @@ func TestOSBuildController(t *testing.T) {
342344
kubeassert.JobExists(buildJobName, "Build job did not get created for MachineConfigPool %q change", mcp.Name)
343345
// Set the successful status on the job.
344346
fixtures.SetJobStatus(ctx, t, kubeclient, mosb, fixtures.JobStatus{Succeeded: 1})
347+
time.Sleep(time.Millisecond * 200)
345348
// The MachineOSBuild should be successful.
346349
kubeassert.MachineOSBuildIsSuccessful(mosb, "Expected the MachineOSBuild %s status to be successful", mosb.Name)
347350
// And the build job should be deleted.
@@ -660,7 +663,7 @@ func setupOSBuildControllerForTestWithRunningBuild(ctx context.Context, t *testi
660663
t.Helper()
661664

662665
kubeclient, mcfgclient, imageclient, routeclient, mosc, mosb, mcp, kubeassert, ctrl := setupOSBuildControllerForTestWithBuild(ctx, t, poolName)
663-
666+
time.Sleep(time.Millisecond * 200)
664667
initialBuildJobName := utils.GetBuildJobName(mosb)
665668

666669
// After creating the new MachineOSConfig, a MachineOSBuild should be created.
@@ -671,7 +674,7 @@ func setupOSBuildControllerForTestWithRunningBuild(ctx context.Context, t *testi
671674

672675
// Set the running status on the job.
673676
fixtures.SetJobStatus(ctx, t, kubeclient, mosb, fixtures.JobStatus{Active: 1})
674-
677+
time.Sleep(time.Millisecond * 200)
675678
// The MachineOSBuild should be running.
676679
kubeassert.Eventually().WithContext(ctx).MachineOSBuildIsRunning(mosb, "Expected the MachineOSBuild %s status to be running", mosb.Name)
677680

@@ -682,10 +685,11 @@ func setupOSBuildControllerForTestWithSuccessfulBuild(ctx context.Context, t *te
682685
t.Helper()
683686

684687
kubeclient, mcfgclient, imageclient, routeclient, mosc, mosb, mcp, kubeassert, _ := setupOSBuildControllerForTestWithRunningBuild(ctx, t, poolName)
685-
688+
time.Sleep(time.Millisecond * 200)
686689
kubeassert.MachineOSBuildExists(mosb)
687690
kubeassert.JobExists(utils.GetBuildJobName(mosb))
688691
fixtures.SetJobStatus(ctx, t, kubeclient, mosb, fixtures.JobStatus{Succeeded: 1})
692+
time.Sleep(time.Millisecond * 200)
689693
kubeassert.MachineOSBuildIsSuccessful(mosb)
690694
kubeassert.JobDoesNotExist(utils.GetBuildJobName(mosb))
691695

0 commit comments

Comments
 (0)