From 1f01fbace7a9a5c4a4c0dfb0cfc599d2927142f3 Mon Sep 17 00:00:00 2001 From: Pasquale Congiusti Date: Wed, 21 Jun 2023 16:03:51 +0200 Subject: [PATCH] chore(e2e): wait for the catalog to be ready --- .../operator_id_filtering_test.go | 5 +---- e2e/install/cli/uninstall_test.go | 5 +++-- e2e/install/upgrade/cli_upgrade_test.go | 3 +++ e2e/support/test_support.go | 11 +++++++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/e2e/commonwithcustominstall/operator_id_filtering_test.go b/e2e/commonwithcustominstall/operator_id_filtering_test.go index 373b2e37cf..5164096cbf 100644 --- a/e2e/commonwithcustominstall/operator_id_filtering_test.go +++ b/e2e/commonwithcustominstall/operator_id_filtering_test.go @@ -25,7 +25,6 @@ package commonwithcustominstall import ( "fmt" "os" - "strings" "testing" "time" @@ -36,7 +35,6 @@ import ( . "github.com/apache/camel-k/v2/e2e/support" v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" - "github.com/apache/camel-k/v2/pkg/util/defaults" "github.com/apache/camel-k/v2/pkg/util/openshift" ) @@ -45,8 +43,7 @@ func TestOperatorIDCamelCatalogReconciliation(t *testing.T) { operator1 := "operator-1" Expect(KamelInstallWithID(operator1, ns, "--global", "--force").Execute()).To(Succeed()) Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) - catalogName := fmt.Sprintf("camel-catalog-%s", strings.ToLower(defaults.DefaultRuntimeVersion)) - Eventually(CamelCatalogPhase(ns, catalogName), TestTimeoutMedium).Should(Equal(v1.CamelCatalogPhaseReady)) + Eventually(DefaultCamelCatalogPhase(ns), TestTimeoutMedium).Should(Equal(v1.CamelCatalogPhaseReady)) }) } diff --git a/e2e/install/cli/uninstall_test.go b/e2e/install/cli/uninstall_test.go index 7afec98122..0ff450d115 100644 --- a/e2e/install/cli/uninstall_test.go +++ b/e2e/install/cli/uninstall_test.go @@ -24,11 +24,11 @@ package cli import ( "fmt" - "testing" - . "github.com/onsi/gomega" + "testing" . "github.com/apache/camel-k/v2/e2e/support" + "github.com/apache/camel-k/v2/pkg/apis/camel/v1" "github.com/apache/camel-k/v2/pkg/util/olm" ) @@ -38,6 +38,7 @@ func TestBasicUninstall(t *testing.T) { operatorID := fmt.Sprintf("camel-k-%s", ns) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) Eventually(OperatorPod(ns)).ShouldNot(BeNil()) + Eventually(DefaultCamelCatalogPhase(ns), TestTimeoutMedium).Should(Equal(v1.CamelCatalogPhaseReady)) // should be completely removed on uninstall Expect(Kamel("uninstall", "-n", ns, "--skip-crd", "--skip-cluster-roles").Execute()).To(Succeed()) diff --git a/e2e/install/upgrade/cli_upgrade_test.go b/e2e/install/upgrade/cli_upgrade_test.go index 8e9d769c9f..3d9ef05cb6 100644 --- a/e2e/install/upgrade/cli_upgrade_test.go +++ b/e2e/install/upgrade/cli_upgrade_test.go @@ -91,6 +91,7 @@ func TestCLIOperatorUpgrade(t *testing.T) { // Check the operator pod is running Eventually(OperatorPodPhase(ns), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) // Check the IntegrationPlatform has been reconciled + Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) Eventually(PlatformVersion(ns), TestTimeoutMedium).Should(Equal(defaults.Version)) // Check the Integration hasn't been upgraded @@ -99,6 +100,8 @@ func TestCLIOperatorUpgrade(t *testing.T) { // Force the Integration upgrade Expect(Kamel("rebuild", name, "-n", ns).Execute()).To(Succeed()) + // A catalog should be created with the new configuration + Eventually(DefaultCamelCatalogPhase(ns), TestTimeoutMedium).Should(Equal(v1.CamelCatalogPhaseReady)) // Check the Integration version has been upgraded Eventually(IntegrationVersion(ns, name), TestTimeoutMedium).Should(Equal(defaults.Version)) diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go index e7541e906c..e42d687e2b 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -1752,6 +1752,17 @@ func DeleteCamelCatalog(ns, name string) func() bool { } } +func DefaultCamelCatalogPhase(ns string) func() v1.CamelCatalogPhase { + return func() v1.CamelCatalogPhase { + catalogName := fmt.Sprintf("camel-catalog-%s", strings.ToLower(defaults.DefaultRuntimeVersion)) + c := CamelCatalog(ns, catalogName)() + if c == nil { + return "" + } + return c.Status.Phase + } +} + func CamelCatalogPhase(ns, name string) func() v1.CamelCatalogPhase { return func() v1.CamelCatalogPhase { c := CamelCatalog(ns, name)()