From 39097a550ccc6b49408b31f09d4b42ecb1e1a456 Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Wed, 6 Mar 2024 23:23:33 +0100 Subject: [PATCH] chore(e2e): Fix E2E tests --- e2e/common/cli/bind_test.go | 2 +- e2e/common/cli/describe_test.go | 4 ++-- e2e/common/cli/dev_mode_test.go | 2 +- e2e/common/config/pipe_config_test.go | 2 +- e2e/common/misc/cron_test.go | 6 +++--- e2e/common/misc/registry_maven_wagon_test.go | 2 +- e2e/common/misc/scale_binding_test.go | 2 +- e2e/install/upgrade/cli_upgrade_test.go | 2 +- e2e/install/upgrade/helm_upgrade_test.go | 2 +- e2e/knative/knative_test.go | 2 ++ e2e/support/test_support.go | 5 +++++ pkg/cmd/builder_test.go | 2 +- 12 files changed, 20 insertions(+), 13 deletions(-) diff --git a/e2e/common/cli/bind_test.go b/e2e/common/cli/bind_test.go index a03c984c61..6e45011c6a 100644 --- a/e2e/common/cli/bind_test.go +++ b/e2e/common/cli/bind_test.go @@ -46,7 +46,7 @@ func TestKamelCLIBind(t *testing.T) { }) t.Run("unsuccessful binding, no property", func(t *testing.T) { - g.Expect(KamelBindWithID(t, operatorID, ns, "timer-source", "log:info").Execute()).NotTo(Succeed()) + g.Expect(KamelBindWithID(t, operatorID, ns, operatorNS+"/timer-source", "log:info").Execute()).NotTo(Succeed()) }) t.Run("bind uris", func(t *testing.T) { diff --git a/e2e/common/cli/describe_test.go b/e2e/common/cli/describe_test.go index 656b14d980..8e5f6a5623 100644 --- a/e2e/common/cli/describe_test.go +++ b/e2e/common/cli/describe_test.go @@ -71,10 +71,10 @@ func TestKamelCliDescribe(t *testing.T) { }) t.Run("Test kamel describe integration platform", func(t *testing.T) { - platform := GetOutputString(Kamel(t, "describe", "platform", operatorID, "-n", ns)) + platform := GetOutputString(Kamel(t, "describe", "platform", operatorID, "-n", operatorNS)) g.Expect(platform).To(ContainSubstring(fmt.Sprintf("Name: %s", operatorID))) - r, _ := regexp.Compile("(?sm).*Namespace:\\s+" + ns + ".*") + r, _ := regexp.Compile("(?sm).*Namespace:\\s+" + operatorNS + ".*") g.Expect(platform).To(MatchRegexp(r.String())) r, _ = regexp.Compile("(?sm).*Runtime Version:\\s+" + defaults.DefaultRuntimeVersion + ".*") diff --git a/e2e/common/cli/dev_mode_test.go b/e2e/common/cli/dev_mode_test.go index 6bfd136d70..c257a37234 100644 --- a/e2e/common/cli/dev_mode_test.go +++ b/e2e/common/cli/dev_mode_test.go @@ -143,7 +143,7 @@ func TestRunDevMode(t *testing.T) { go kamelRun.Execute() // Second run should start up within a few seconds - timeout := 10 * time.Second + timeout := 20 * time.Second g.Eventually(logScanner.IsFound(`integration "`+name+`" in phase Running`), timeout).Should(BeTrue()) g.Eventually(logScanner.IsFound("Magicstring!"), timeout).Should(BeTrue()) }) diff --git a/e2e/common/config/pipe_config_test.go b/e2e/common/config/pipe_config_test.go index b896e7f8ab..b471b10121 100644 --- a/e2e/common/config/pipe_config_test.go +++ b/e2e/common/config/pipe_config_test.go @@ -37,7 +37,7 @@ func TestPipeConfig(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(g *WithT, ns string) { - operatorID := "camel-k-config" + operatorID := "camel-k-pipe-config" g.Expect(CopyCamelCatalog(t, ns, operatorID)).To(Succeed()) g.Expect(CopyIntegrationKits(t, ns, operatorID)).To(Succeed()) g.Expect(KamelInstallWithID(t, operatorID, ns)).To(Succeed()) diff --git a/e2e/common/misc/cron_test.go b/e2e/common/misc/cron_test.go index 76948bbb86..339af3da71 100644 --- a/e2e/common/misc/cron_test.go +++ b/e2e/common/misc/cron_test.go @@ -46,21 +46,21 @@ func TestRunCronExample(t *testing.T) { t.Run("cron", func(t *testing.T) { g.Expect(KamelRunWithID(t, operatorID, ns, "files/cron.yaml").Execute()).To(Succeed()) - g.Eventually(IntegrationCronJob(t, ns, "cron"), TestTimeoutMedium).ShouldNot(BeNil()) + g.Eventually(IntegrationCronJob(t, ns, "cron"), TestTimeoutLong).ShouldNot(BeNil()) g.Eventually(IntegrationConditionStatus(t, ns, "cron", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue)) g.Eventually(IntegrationLogs(t, ns, "cron"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!")) }) t.Run("cron-yaml", func(t *testing.T) { g.Expect(KamelRunWithID(t, operatorID, ns, "files/cron-yaml.yaml").Execute()).To(Succeed()) - g.Eventually(IntegrationCronJob(t, ns, "cron-yaml"), TestTimeoutMedium).ShouldNot(BeNil()) + g.Eventually(IntegrationCronJob(t, ns, "cron-yaml"), TestTimeoutLong).ShouldNot(BeNil()) g.Eventually(IntegrationConditionStatus(t, ns, "cron-yaml", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue)) g.Eventually(IntegrationLogs(t, ns, "cron-yaml"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!")) }) t.Run("cron-timer", func(t *testing.T) { g.Expect(KamelRunWithID(t, operatorID, ns, "files/cron-timer.yaml").Execute()).To(Succeed()) - g.Eventually(IntegrationCronJob(t, ns, "cron-timer"), TestTimeoutMedium).ShouldNot(BeNil()) + g.Eventually(IntegrationCronJob(t, ns, "cron-timer"), TestTimeoutLong).ShouldNot(BeNil()) g.Eventually(IntegrationConditionStatus(t, ns, "cron-timer", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue)) g.Eventually(IntegrationLogs(t, ns, "cron-timer"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!")) }) diff --git a/e2e/common/misc/registry_maven_wagon_test.go b/e2e/common/misc/registry_maven_wagon_test.go index a7643f175f..3d590a3e8f 100644 --- a/e2e/common/misc/registry_maven_wagon_test.go +++ b/e2e/common/misc/registry_maven_wagon_test.go @@ -48,7 +48,7 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) { } WithNewTestNamespace(t, func(g *WithT, ns string) { - operatorID := "camel-k-rest" + operatorID := "camel-k-registry-maven-repo" g.Expect(CopyCamelCatalog(t, ns, operatorID)).To(Succeed()) g.Expect(CopyIntegrationKits(t, ns, operatorID)).To(Succeed()) g.Expect(KamelInstallWithID(t, operatorID, ns)).To(Succeed()) diff --git a/e2e/common/misc/scale_binding_test.go b/e2e/common/misc/scale_binding_test.go index adc9fd36b1..dc9bbe3b57 100644 --- a/e2e/common/misc/scale_binding_test.go +++ b/e2e/common/misc/scale_binding_test.go @@ -46,7 +46,7 @@ func TestPipeScale(t *testing.T) { operatorID := "camel-k-pipe-scale" g.Expect(CopyCamelCatalog(t, ns, operatorID)).To(Succeed()) g.Expect(CopyIntegrationKits(t, ns, operatorID)).To(Succeed()) - g.Expect(KamelInstallWithID(t, operatorID, ns)).To(Succeed()) + g.Expect(KamelInstallWithIDAndKameletCatalog(t, operatorID, ns)).To(Succeed()) g.Eventually(SelectedPlatformPhase(t, ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) diff --git a/e2e/install/upgrade/cli_upgrade_test.go b/e2e/install/upgrade/cli_upgrade_test.go index 2fffef78a4..12c38f20ed 100644 --- a/e2e/install/upgrade/cli_upgrade_test.go +++ b/e2e/install/upgrade/cli_upgrade_test.go @@ -95,7 +95,7 @@ func TestCLIOperatorUpgrade(t *testing.T) { g.Expect(os.Setenv("KAMEL_BIN", "")).To(Succeed()) // Upgrade the operator by installing the current version - g.Expect(KamelInstall(t, ns, "--olm=false", "--force", "--operator-image", image, "--base-image", defaults.BaseImage())).To(Succeed()) + g.Expect(Kamel(t, "install", "-n", ns, "--olm=false", "--skip-default-kamelets-setup", "--force", "--operator-image", image, "--base-image", defaults.BaseImage()).Execute()).To(Succeed()) // Check the operator image is the current built one g.Eventually(OperatorImage(t, ns)).Should(Equal(image)) diff --git a/e2e/install/upgrade/helm_upgrade_test.go b/e2e/install/upgrade/helm_upgrade_test.go index edffae0900..927b08bcb0 100644 --- a/e2e/install/upgrade/helm_upgrade_test.go +++ b/e2e/install/upgrade/helm_upgrade_test.go @@ -65,7 +65,7 @@ func TestHelmOperatorUpgrade(t *testing.T) { t.FailNow() } } - g.Eventually(CRDs(t)).Should(HaveLen(0)) + g.Eventually(CRDs(t), TestTimeoutMedium).Should(HaveLen(0)) WithNewTestNamespace(t, func(g *WithT, ns string) { // Install operator in last released version diff --git a/e2e/knative/knative_test.go b/e2e/knative/knative_test.go index 600f423fa6..e35b44ed2d 100644 --- a/e2e/knative/knative_test.go +++ b/e2e/knative/knative_test.go @@ -141,6 +141,8 @@ func TestRunBroker(t *testing.T) { operatorID := fmt.Sprintf("camel-k-%s", ns) g.Expect(KamelInstallWithID(t, operatorID, ns, "--trait-profile", "knative")).To(Succeed()) + g.Eventually(SelectedPlatformPhase(t, ns, operatorID), TestTimeoutMedium).Should(Equal(camelv1.IntegrationPlatformPhaseReady)) + g.Expect(KamelRunWithID(t, operatorID, ns, "files/knativeevt1.groovy").Execute()).To(Succeed()) g.Expect(KamelRunWithID(t, operatorID, ns, "files/knativeevt2.groovy").Execute()).To(Succeed()) g.Eventually(IntegrationPodPhase(t, ns, "knativeevt1"), TestTimeoutLong).Should(Equal(v1.PodRunning)) diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go index c088c33d8e..cce80567d6 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -140,6 +140,7 @@ var TestContext context.Context var testClient client.Client var clientMutex = sync.Mutex{} +var testSetupMutex = sync.Mutex{} var kamelInstallMutex = sync.Mutex{} // Only panic the test if absolutely necessary and there is @@ -2069,12 +2070,16 @@ func UpdateIntegrationProfile(t *testing.T, ns string, upd func(ipr *v1.Integrat func CreateCamelCatalog(t *testing.T, catalog *v1.CamelCatalog) func() error { return func() error { + testSetupMutex.Lock() + defer testSetupMutex.Unlock() return TestClient(t).Create(TestContext, catalog) } } func CreateIntegrationKit(t *testing.T, kit *v1.IntegrationKit) func() error { return func() error { + testSetupMutex.Lock() + defer testSetupMutex.Unlock() return TestClient(t).Create(TestContext, kit) } } diff --git a/pkg/cmd/builder_test.go b/pkg/cmd/builder_test.go index 0d506edaf8..4f5ee39e30 100644 --- a/pkg/cmd/builder_test.go +++ b/pkg/cmd/builder_test.go @@ -56,7 +56,7 @@ func addTestBuilderCmd(options RootCmdOptions, rootCmd *cobra.Command) *builderC func TestBuilderNonExistingFlag(t *testing.T) { _, rootCmd, _ := initializeBuilderCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdBuilder, "--nonExistingFlag") - require.NoError(t, err) + require.Error(t, err) } func TestBuilderBuildNameFlag(t *testing.T) {