squakez commented on code in PR #4330: URL: https://github.com/apache/camel-k/pull/4330#discussion_r1186139328
########## e2e/builder/build_test.go: ########## @@ -57,76 +58,86 @@ func TestKitMaxBuildLimit(t *testing.T) { buildB := "integration-b" buildC := "integration-c" - ns1 := NewTestNamespace(false).GetName() - defer DumpNamespace(t, ns1) - defer DeleteNamespace(t, ns1) - - pl1 := v1.NewIntegrationPlatform(ns1, fmt.Sprintf("camel-k-%s", ns)) - pl.Spec.DeepCopyInto(&pl1.Spec) - pl1.Spec.Build.Maven.Settings = v1.ValueSource{} - pl1.SetOperatorID(fmt.Sprintf("camel-k-%s", ns)) - if err := TestClient().Create(TestContext, &pl1); err != nil { - t.Error(err) - t.FailNow() - } - - Eventually(PlatformPhase(ns1), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) - - ns2 := NewTestNamespace(false).GetName() - defer DumpNamespace(t, ns2) - defer DeleteNamespace(t, ns2) - - pl2 := v1.NewIntegrationPlatform(ns2, fmt.Sprintf("camel-k-%s", ns)) - pl.Spec.DeepCopyInto(&pl2.Spec) - pl2.Spec.Build.Maven.Settings = v1.ValueSource{} - pl2.SetOperatorID(fmt.Sprintf("camel-k-%s", ns)) - if err := TestClient().Create(TestContext, &pl2); err != nil { - t.Error(err) - t.FailNow() - } - - Eventually(PlatformPhase(ns2), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) - - doKitBuildInNamespace(buildA, ns, TestTimeoutShort, kitOptions{ - operatorID: fmt.Sprintf("camel-k-%s", ns), - dependencies: []string{ - "camel:timer", "camel:log", - }, - traits: []string{ - "builder.properties=build-property=A", - }, - }, v1.BuildPhaseRunning, v1.IntegrationKitPhaseBuildRunning) - - doKitBuildInNamespace(buildB, ns1, TestTimeoutShort, kitOptions{ - operatorID: fmt.Sprintf("camel-k-%s", ns), - dependencies: []string{ - "camel:timer", "camel:log", - }, - traits: []string{ - "builder.properties=build-property=B", - }, - }, v1.BuildPhaseRunning, v1.IntegrationKitPhaseBuildRunning) - - doKitBuildInNamespace(buildC, ns2, TestTimeoutShort, kitOptions{ - operatorID: fmt.Sprintf("camel-k-%s", ns), - dependencies: []string{ - "camel:timer", "camel:log", - }, - traits: []string{ - "builder.properties=build-property=C", - }, - }, v1.BuildPhaseScheduling, v1.IntegrationKitPhaseNone) - - // verify that buildC is allowed to build as soon as buildA has finished - Eventually(BuildPhase(ns, buildA), TestTimeoutLong).Should(Equal(v1.BuildPhaseSucceeded)) - Eventually(BuildPhase(ns2, buildC), TestTimeoutShort).Should(Equal(v1.BuildPhaseRunning)) - Eventually(KitPhase(ns2, buildC), TestTimeoutLong).Should(Equal(v1.IntegrationKitPhaseBuildRunning)) - - // verify that all builds are successful - Eventually(BuildPhase(ns1, buildB), TestTimeoutLong).Should(Equal(v1.BuildPhaseSucceeded)) - Eventually(KitPhase(ns1, buildB), TestTimeoutLong).Should(Equal(v1.IntegrationKitPhaseReady)) - Eventually(BuildPhase(ns2, buildC), TestTimeoutLong).Should(Equal(v1.BuildPhaseSucceeded)) - Eventually(KitPhase(ns2, buildC), TestTimeoutLong).Should(Equal(v1.IntegrationKitPhaseReady)) + WithNewTestNamespace(t, func(ns1 string) { + WithNewTestNamespace(t, func(ns2 string) { + pl1 := v1.NewIntegrationPlatform(ns1, fmt.Sprintf("camel-k-%s", ns)) + pl.Spec.DeepCopyInto(&pl1.Spec) + pl1.Spec.Build.Maven.Settings = v1.ValueSource{} + pl1.SetOperatorID(fmt.Sprintf("camel-k-%s", ns)) + if err := TestClient().Create(TestContext, &pl1); err != nil { + t.Error(err) + t.FailNow() + } + + Eventually(PlatformPhase(ns1), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) + + pl2 := v1.NewIntegrationPlatform(ns2, fmt.Sprintf("camel-k-%s", ns)) + pl.Spec.DeepCopyInto(&pl2.Spec) + pl2.Spec.Build.Maven.Settings = v1.ValueSource{} + pl2.SetOperatorID(fmt.Sprintf("camel-k-%s", ns)) + if err := TestClient().Create(TestContext, &pl2); err != nil { + t.Error(err) + t.FailNow() + } + + Eventually(PlatformPhase(ns2), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) + + doKitBuildInNamespace(buildA, ns, TestTimeoutShort, kitOptions{ + operatorID: fmt.Sprintf("camel-k-%s", ns), + dependencies: []string{ + "camel:timer", "camel:log", + }, + traits: []string{ + "builder.properties=build-property=A", + }, + }, v1.BuildPhaseRunning, v1.IntegrationKitPhaseBuildRunning) + + doKitBuildInNamespace(buildB, ns1, TestTimeoutShort, kitOptions{ + operatorID: fmt.Sprintf("camel-k-%s", ns), + dependencies: []string{ + "camel:timer", "camel:log", + }, + traits: []string{ + "builder.properties=build-property=B", + }, + }, v1.BuildPhaseRunning, v1.IntegrationKitPhaseBuildRunning) + + doKitBuildInNamespace(buildC, ns2, TestTimeoutShort, kitOptions{ + operatorID: fmt.Sprintf("camel-k-%s", ns), + dependencies: []string{ + "camel:timer", "camel:log", + }, + traits: []string{ + "builder.properties=build-property=C", + }, + }, v1.BuildPhaseScheduling, v1.IntegrationKitPhaseNone) + + var notExceedsMaxBuildLimit = func(runningBuilds int) bool { + return runningBuilds <= 2 + } + + limit := 0 + for limit < 5 && BuildPhase(ns, buildA)() == v1.BuildPhaseRunning { Review Comment: I think you need to check all BuildPhases in order to constantly check while any build is still running. I think you can indefinetely loop while any build is running and verify that the number is always lower than the limit. I think this could be a better approach then the `Consistently` usage which seem more appropriate when you want to test something in a period of time (which in our case we do not have). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org