This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/release-1.8.x by this push:
     new 6424294  [TEST] Add Global operator + namespaced kamelet test
6424294 is described below

commit 6424294d56ffa12fc4fe6ab8d62a2b364e2cdacc
Author: Jan Bouska <jbou...@redhat.com>
AuthorDate: Thu Jan 27 14:47:04 2022 +0100

    [TEST] Add Global operator + namespaced kamelet test
---
 e2e/builder/global_test.go            | 15 ++---------
 e2e/common/cli/global_kamelet_test.go | 49 +++++++++++++++++++++--------------
 e2e/support/test_support.go           | 13 ++++++++++
 3 files changed, 44 insertions(+), 33 deletions(-)

diff --git a/e2e/builder/global_test.go b/e2e/builder/global_test.go
index b91971a..359951b 100644
--- a/e2e/builder/global_test.go
+++ b/e2e/builder/global_test.go
@@ -51,7 +51,7 @@ func TestRunGlobalInstall(t *testing.T) {
                }
        }
 
-       test := func(operatorNamespace string) {
+       WithGlobalOperatorNamespace(t, func(operatorNamespace string) {
                Expect(Kamel("install", "-n", operatorNamespace, "--global", 
"--force").Execute()).To(Succeed())
 
                t.Run("Global test on namespace with platform", func(t 
*testing.T) {
@@ -139,18 +139,7 @@ func TestRunGlobalInstall(t *testing.T) {
                })
 
                Expect(Kamel("uninstall", "-n", operatorNamespace, 
"--skip-crd", "--skip-cluster-roles").Execute()).To(Succeed())
-       }
-
-       ocp, err := openshift.IsOpenShift(TestClient())
-       assert.Nil(t, err)
-       if ocp {
-               // global operators are always installed in the 
openshift-operators namespace
-               RegisterTestingT(t)
-               test("openshift-operators")
-       } else {
-               // create new namespace for the global operator
-               WithNewTestNamespace(t, test)
-       }
+       })
 }
 
 func integrationKitsToNamesTransform() func([]v1.IntegrationKit) []string {
diff --git a/e2e/common/cli/global_kamelet_test.go 
b/e2e/common/cli/global_kamelet_test.go
index 337a187..a58465f 100644
--- a/e2e/common/cli/global_kamelet_test.go
+++ b/e2e/common/cli/global_kamelet_test.go
@@ -46,32 +46,41 @@ func TestRunGlobalKamelet(t *testing.T) {
                }
        }
 
-       test := func(operatorNamespace string) {
+       WithGlobalOperatorNamespace(t, func(operatorNamespace string) {
                Expect(Kamel("install", "-n", operatorNamespace, "--global", 
"--force").Execute()).To(Succeed())
 
-               Expect(CreateTimerKamelet(operatorNamespace, 
"my-own-timer-source")()).To(Succeed())
+               t.Run("Global operator + namespaced kamelet test", func(t 
*testing.T) {
 
-               // NS2: namespace without operator
-               WithNewTestNamespace(t, func(ns2 string) {
-                       Expect(Kamel("install", "-n", ns2, 
"--skip-operator-setup", "--olm=false").Execute()).To(Succeed())
+                       // NS2: namespace without operator
+                       WithNewTestNamespace(t, func(ns2 string) {
+                               Expect(CreateTimerKamelet(ns2, 
"my-own-timer-source")()).To(Succeed())
 
-                       Expect(Kamel("run", "-n", ns2, 
"files/timer-kamelet-usage.groovy").Execute()).To(Succeed())
-                       Eventually(IntegrationPodPhase(ns2, 
"timer-kamelet-usage"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
-                       Eventually(IntegrationLogs(ns2, "timer-kamelet-usage"), 
TestTimeoutShort).Should(ContainSubstring("Hello world"))
-                       Expect(Kamel("delete", "--all", "-n", 
ns2).Execute()).To(Succeed())
+                               Expect(Kamel("install", "-n", ns2, 
"--skip-operator-setup", "--olm=false").Execute()).To(Succeed())
+
+                               Expect(Kamel("run", "-n", ns2, 
"files/timer-kamelet-usage.groovy").Execute()).To(Succeed())
+                               Eventually(IntegrationPodPhase(ns2, 
"timer-kamelet-usage"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
+                               Eventually(IntegrationLogs(ns2, 
"timer-kamelet-usage"), TestTimeoutShort).Should(ContainSubstring("Hello 
world"))
+                               Expect(Kamel("delete", "--all", "-n", 
ns2).Execute()).To(Succeed())
+                       })
+               })
+
+               t.Run("Global operator + global kamelet test", func(t 
*testing.T) {
+
+                       Expect(CreateTimerKamelet(operatorNamespace, 
"my-own-timer-source")()).To(Succeed())
+
+                       // NS3: namespace without operator
+                       WithNewTestNamespace(t, func(ns3 string) {
+                               Expect(Kamel("install", "-n", ns3, 
"--skip-operator-setup", "--olm=false").Execute()).To(Succeed())
+
+                               Expect(Kamel("run", "-n", ns3, 
"files/timer-kamelet-usage.groovy").Execute()).To(Succeed())
+                               Eventually(IntegrationPodPhase(ns3, 
"timer-kamelet-usage"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
+                               Eventually(IntegrationLogs(ns3, 
"timer-kamelet-usage"), TestTimeoutShort).Should(ContainSubstring("Hello 
world"))
+                               Expect(Kamel("delete", "--all", "-n", 
ns3).Execute()).To(Succeed())
+                               Expect(TestClient().Delete(TestContext, 
Kamelet("my-own-timer-source", operatorNamespace)())).To(Succeed())
+                       })
                })
 
                Expect(Kamel("uninstall", "-n", operatorNamespace, 
"--skip-crd", "--skip-cluster-roles=false", 
"--skip-cluster-role-bindings=false").Execute()).To(Succeed())
-       }
+       })
 
-       ocp, err := openshift.IsOpenShift(TestClient())
-       assert.Nil(t, err)
-       if ocp {
-               // global operators are always installed in the 
openshift-operators namespace
-               RegisterTestingT(t)
-               test("openshift-operators")
-       }else {
-               // create new namespace for the global operator
-               WithNewTestNamespace(t, test)
-       }
 }
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 1a69db0..436f5b4 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -28,6 +28,7 @@ import (
        "context"
        "encoding/json"
        "fmt"
+       "github.com/stretchr/testify/assert"
        "io"
        "io/ioutil"
        "os"
@@ -1642,6 +1643,18 @@ func WithNewTestNamespace(t *testing.T, doRun 
func(string)) {
        InvokeUserTestCode(t, ns.GetName(), doRun)
 }
 
+func WithGlobalOperatorNamespace(t *testing.T, test func(string)) {
+       ocp, err := openshift.IsOpenShift(TestClient())
+       assert.Nil(t, err)
+       if ocp {
+               // global operators are always installed in the 
openshift-operators namespace
+               InvokeUserTestCode(t, "openshift-operators", test)
+       }else {
+               // create new namespace for the global operator
+               WithNewTestNamespace(t, test)
+       }
+}
+
 func WithNewTestNamespaceWithKnativeBroker(t *testing.T, doRun func(string)) {
        ns := NewTestNamespace(true)
        defer DeleteTestNamespace(t, ns)

Reply via email to