You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/09/22 14:57:25 UTC

[camel-k] 07/10: Fixes for e2e tests

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

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

commit 084196339c894e0df5c12f93fceb8863edcf0cb7
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Tue Jul 20 14:33:41 2021 +0100

    Fixes for e2e tests
    
    * upgrade.yml
     * Remove operator-sdk step as taken cared of in Makefile
     * Updates build variables to use CUSTOM_IMAGE
     * Replaces kustomize patching of 'replaces' property with sed as the
       manifest is no longer included in the kustomize.yaml
    
    * e2e/...
     * Tests for kustomize install
---
 .github/workflows/builder.yml         |  15 ++--
 .github/workflows/knative.yml         |  28 +++++---
 .github/workflows/kubernetes.yml      |  16 +++--
 .github/workflows/upgrade.yml         |  42 ++++-------
 e2e/common/kustomize/common.go        |  81 +++++++++++++++++++++
 e2e/common/kustomize/operator_test.go |  89 +++++++++++++++++++++++
 e2e/common/kustomize/setup_test.go    |  70 ++++++++++++++++++
 e2e/support/test_support.go           | 131 ++++++++++++++++++++++++++++++++--
 8 files changed, 416 insertions(+), 56 deletions(-)

diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml
index 317c907..368d636 100644
--- a/.github/workflows/builder.yml
+++ b/.github/workflows/builder.yml
@@ -92,9 +92,10 @@ jobs:
     - name: Build Operator
       run: |
         echo "Build project"
-        export LOCAL_IMAGE=${KIND_REGISTRY}/apache/camel-k
-        echo "LOCAL_IMAGE=${LOCAL_IMAGE}:$(make get-version)" >> $GITHUB_ENV
-        make IMAGE_NAME=${LOCAL_IMAGE} PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images images-push
+        export CUSTOM_IMAGE=${KIND_REGISTRY}/apache/camel-k
+        echo "LOCAL_IMAGE_NAME=${CUSTOM_IMAGE}" >> $GITHUB_ENV
+        echo "LOCAL_IMAGE_VERSION=$(make get-version)" >> $GITHUB_ENV
+        make PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images images-push
 
         sudo mv ./kamel /usr/local/bin
     - name: Run IT
@@ -112,14 +113,16 @@ jobs:
         kamel install --cluster-setup
 
         # Configure install options
+        export CUSTOM_IMAGE=${{ env.LOCAL_IMAGE_NAME }}
+        export CUSTOM_VERSION=${{ env.LOCAL_IMAGE_VERSION }}
         export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo)
         export KAMEL_INSTALL_REGISTRY=$KIND_REGISTRY
         export KAMEL_INSTALL_REGISTRY_INSECURE=true
-        export KAMEL_INSTALL_OPERATOR_IMAGE=$KIND_REGISTRY/apache/camel-k:$(make get-version)
+        export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION}
 
         # Configure test options
-        export CAMEL_K_TEST_IMAGE_NAME=$KIND_REGISTRY/apache/camel-k
-        export CAMEL_K_TEST_IMAGE_VERSION=$(make get-version)
+        export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE}
+        export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION}
 
         # Then run integration tests
         make test-builder
diff --git a/.github/workflows/knative.yml b/.github/workflows/knative.yml
index 366951a..7952bfa 100644
--- a/.github/workflows/knative.yml
+++ b/.github/workflows/knative.yml
@@ -133,9 +133,10 @@ jobs:
     - name: Build Operator
       run: |
         echo "Build project"
-        export LOCAL_IMAGE=$KIND_REGISTRY/apache/camel-k
-        echo "LOCAL_IMAGE=${LOCAL_IMAGE}:$(make get-version)" >> $GITHUB_ENV
-        make IMAGE_NAME=${LOCAL_IMAGE} PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images images-push
+        export CUSTOM_IMAGE=${KIND_REGISTRY}/apache/camel-k
+        echo "LOCAL_IMAGE_NAME=${CUSTOM_IMAGE}" >> $GITHUB_ENV
+        echo "LOCAL_IMAGE_VERSION=$(make get-version)" >> $GITHUB_ENV
+        make PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images images-push
 
         sudo mv ./kamel /usr/local/bin
     - name: Run IT
@@ -144,15 +145,17 @@ jobs:
         kamel install --cluster-setup
 
         # Configure install options
+        export CUSTOM_IMAGE=${{ env.LOCAL_IMAGE_NAME }}
+        export CUSTOM_VERSION=${{ env.LOCAL_IMAGE_VERSION }}
         export KAMEL_INSTALL_BUILD_PUBLISH_STRATEGY=Spectrum
         export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo)
         export KAMEL_INSTALL_REGISTRY=$KIND_REGISTRY
         export KAMEL_INSTALL_REGISTRY_INSECURE=true
-        export KAMEL_INSTALL_OPERATOR_IMAGE=$KIND_REGISTRY/apache/camel-k:$(make get-version)
+        export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION}
 
         # Configure test options
-        export CAMEL_K_TEST_IMAGE_NAME=$KIND_REGISTRY/apache/camel-k
-        export CAMEL_K_TEST_IMAGE_VERSION=$(make get-version)
+        export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE}
+        export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION}
 
         # Then run integration tests
         make test-knative
@@ -251,9 +254,10 @@ jobs:
       - name: Build Operator
         run: |
           echo "Build project"
-          export LOCAL_IMAGE=$KIND_REGISTRY/apache/camel-k
-          echo "LOCAL_IMAGE=${LOCAL_IMAGE}:$(make get-version)" >> $GITHUB_ENV
-          make IMAGE_NAME=${LOCAL_IMAGE} PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images images-push
+          export CUSTOM_IMAGE=${KIND_REGISTRY}/apache/camel-k
+          echo "LOCAL_IMAGE_NAME=${CUSTOM_IMAGE}" >> $GITHUB_ENV
+          echo "LOCAL_IMAGE_VERSION=$(make get-version)" >> $GITHUB_ENV
+          make PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images images-push
 
           sudo mv ./kamel /usr/local/bin
       - name: Run IT
@@ -262,15 +266,17 @@ jobs:
           kamel install --cluster-setup
 
           # Configure install options
+          export CUSTOM_IMAGE=${{ env.LOCAL_IMAGE_NAME }}
+          export CUSTOM_VERSION=${{ env.LOCAL_IMAGE_VERSION }}
           export KAMEL_INSTALL_BUILD_PUBLISH_STRATEGY=Spectrum
           export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo)
           export KAMEL_INSTALL_REGISTRY=$KIND_REGISTRY
           export KAMEL_INSTALL_REGISTRY_INSECURE=true
-          export KAMEL_INSTALL_OPERATOR_IMAGE=$KIND_REGISTRY/apache/camel-k:$(make get-version)
+          export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION}
 
           # Configure test options
           export CAMEL_K_TEST_IMAGE_NAME=$KIND_REGISTRY/apache/camel-k
-          export CAMEL_K_TEST_IMAGE_VERSION=$(make get-version)
+          export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION}
 
           # Install Yaks globally
           yaks install
diff --git a/.github/workflows/kubernetes.yml b/.github/workflows/kubernetes.yml
index 33f7f01..872a8c6 100644
--- a/.github/workflows/kubernetes.yml
+++ b/.github/workflows/kubernetes.yml
@@ -93,9 +93,10 @@ jobs:
     - name: Build Operator
       run: |
         echo "Build project"
-        export LOCAL_IMAGE=$KIND_REGISTRY/apache/camel-k
-        echo "LOCAL_IMAGE=${LOCAL_IMAGE}:$(make get-version)" >> $GITHUB_ENV
-        make IMAGE_NAME=${LOCAL_IMAGE} PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images images-push
+        export CUSTOM_IMAGE=${KIND_REGISTRY}/apache/camel-k
+        echo "LOCAL_IMAGE_NAME=${CUSTOM_IMAGE}" >> $GITHUB_ENV
+        echo "LOCAL_IMAGE_VERSION=$(make get-version)" >> $GITHUB_ENV
+        make PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images images-push
 
         sudo mv ./kamel /usr/local/bin
     - name: Install Service Binding
@@ -119,17 +120,20 @@ jobs:
         kamel install --cluster-setup
 
         # Configure install options
+        export CUSTOM_IMAGE=${{ env.LOCAL_IMAGE_NAME }}
+        export CUSTOM_VERSION=${{ env.LOCAL_IMAGE_VERSION }}
         export KAMEL_INSTALL_BUILD_PUBLISH_STRATEGY=Spectrum
         export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo)
         export KAMEL_INSTALL_REGISTRY=$KIND_REGISTRY
         export KAMEL_INSTALL_REGISTRY_INSECURE=true
-        export KAMEL_INSTALL_OPERATOR_IMAGE=$KIND_REGISTRY/apache/camel-k:$(make get-version)
+        export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION}
 
         # Configure test options
-        export CAMEL_K_TEST_IMAGE_NAME=$KIND_REGISTRY/apache/camel-k
-        export CAMEL_K_TEST_IMAGE_VERSION=$(make get-version)
+        export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE}
+        export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION}
 
         # Then run integration tests
         make test-integration
         make test-service-binding
         make test-quarkus-native
+        make test-kustomize
diff --git a/.github/workflows/upgrade.yml b/.github/workflows/upgrade.yml
index b073c11..5ffd401 100644
--- a/.github/workflows/upgrade.yml
+++ b/.github/workflows/upgrade.yml
@@ -77,11 +77,6 @@ jobs:
       uses: actions/setup-go@v2
       with:
         go-version: 1.15.x
-    - name: Set up operator-sdk
-      run: |
-        curl -L https://github.com/operator-framework/operator-sdk/releases/download/v1.3.0/operator-sdk_linux_amd64 -o operator-sdk
-        chmod +x operator-sdk
-        sudo mv operator-sdk /usr/local/bin/
     - name: Set up opm tool
       run: |
         curl -L https://github.com/operator-framework/operator-registry/releases/download/v1.16.1/linux-amd64-opm -o opm
@@ -111,9 +106,10 @@ jobs:
     - name: Build Operator
       run: |
         echo "Build project"
-        export LOCAL_IMAGE=$KIND_REGISTRY/apache/camel-k
-        echo "LOCAL_IMAGE=${LOCAL_IMAGE}:$(make get-version)" >> $GITHUB_ENV
-        make IMAGE_NAME=${LOCAL_IMAGE} PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images images-push
+        export CUSTOM_IMAGE=${KIND_REGISTRY}/apache/camel-k
+        echo "LOCAL_IMAGE_NAME=${CUSTOM_IMAGE}" >> $GITHUB_ENV
+        echo "LOCAL_IMAGE_VERSION=$(make get-version)" >> $GITHUB_ENV
+        make PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images images-push
     - name: Build Operator bundle
       run: |
         echo "Build Operator bundle"
@@ -124,30 +120,20 @@ jobs:
         make kustomize
 
         # replace image
-        $(cd config/manifests && kustomize edit set image "docker.io/apache/camel-k=${{ env.LOCAL_IMAGE }}")
+        $(cd config/manifests && kustomize edit set image "docker.io/apache/camel-k=${{ env.LOCAL_IMAGE_NAME }}:${{ env.LOCAL_IMAGE_VERSION }}")
 
         # Patch CSV with the 'replaces' field to define the upgrade graph
-        cat <<EOF > config/manifests/patch.yml
-        apiVersion: operators.coreos.com/v1alpha1
-        kind: ClusterServiceVersion
-        metadata:
-          namespace: placeholder
-          name: camel-k.v$(make get-version | grep -Po "\d.\d.\d")
-        spec:
-          replaces: camel-k-operator.v$(make get-last-released-version)
-        EOF
-
-        echo "Patching CSV with"
-        cat config/manifests/patch.yml
-        $(cd config/manifests && kustomize edit add patch patch.yml)
-
-        export LOCAL_IMAGE_BUNDLE=$KIND_REGISTRY/apache/camel-k-bundle:$(make get-version)
+        # Use sed as the manifest/bases file is not included in the kustomize config
+        BASE_VERSION=$(echo ${{ env.LOCAL_IMAGE_VERSION }} | grep -Po "\d.\d.\d")
+        sed -i "/  version: ${BASE_VERSION}/a \ \ replaces: camel-k-operator.v$(make get-last-released-version)" config/manifests/bases/camel-k.clusterserviceversion.yaml
+        export CUSTOM_IMAGE=${{ env.LOCAL_IMAGE_NAME }}
+        export LOCAL_IMAGE_BUNDLE=$KIND_REGISTRY/apache/camel-k-bundle:${{ env.LOCAL_IMAGE_VERSION }}
         echo "LOCAL_IMAGE_BUNDLE=${LOCAL_IMAGE_BUNDLE}" >> $GITHUB_ENV
-        make bundle-build METADATA_IMAGE_NAME=${LOCAL_IMAGE_BUNDLE} BUNDLE_METADATA_OPTS="--channels stable"
+        make bundle-build BUNDLE_IMAGE_NAME=${LOCAL_IMAGE_BUNDLE} DEFAULT_CHANNEL="stable" CHANNELS="stable"
         docker push ${LOCAL_IMAGE_BUNDLE}
     - name: Create new index image
       run: |
-        export LOCAL_IIB=$KIND_REGISTRY/apache/camel-k-iib:$(make get-version)
+        export LOCAL_IIB=$KIND_REGISTRY/apache/camel-k-iib:${{ env.LOCAL_IMAGE_VERSION }}
         echo "LOCAL_IIB=${LOCAL_IIB}" >> $GITHUB_ENV
         opm index add --bundles ${{ env.LOCAL_IMAGE_BUNDLE }} -c docker --from-index quay.io/operatorhubio/catalog:latest --tag ${LOCAL_IIB} --skip-tls
         docker push ${LOCAL_IIB}
@@ -157,6 +143,8 @@ jobs:
         export RELEASED_KAMEL_BIN=/usr/local/bin/kamel
 
         # Configure install options
+        export CUSTOM_IMAGE=${{ env.LOCAL_IMAGE_NAME }}
+        export CUSTOM_VERSION=${{ env.LOCAL_IMAGE_VERSION }}
         export KAMEL_INSTALL_BUILD_PUBLISH_STRATEGY=Spectrum
         export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo)
         export KAMEL_INSTALL_REGISTRY=$KIND_REGISTRY
@@ -166,7 +154,7 @@ jobs:
         export CAMEL_K_PREV_IIB=quay.io/operatorhubio/catalog:latest
         export CAMEL_K_NEW_IIB=${{ env.LOCAL_IIB }}
         export KAMEL_K_TEST_RELEASE_VERSION=$(make get-last-released-version)
-        export KAMEL_K_TEST_OPERATOR_CURRENT_IMAGE=$KIND_REGISTRY/apache/camel-k:$(make get-version)
+        export KAMEL_K_TEST_OPERATOR_CURRENT_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION}
 
         # Then run integration tests
         make test-upgrade
diff --git a/e2e/common/kustomize/common.go b/e2e/common/kustomize/common.go
new file mode 100644
index 0000000..155747b
--- /dev/null
+++ b/e2e/common/kustomize/common.go
@@ -0,0 +1,81 @@
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package kustomize
+
+import (
+	"os/exec"
+	"strings"
+	"testing"
+
+	. "github.com/apache/camel-k/e2e/support"
+	. "github.com/onsi/gomega"
+	"github.com/onsi/gomega/gexec"
+	"github.com/stretchr/testify/assert"
+)
+
+const (
+	// v1.Build,          v1.Integration
+	// v1.IntegrationKit, v1.IntegrationPlatform
+	// v1alpha1.Kamelet,  v1alpha1.KameletBinding
+	ExpCrds = 6
+
+	// camel-k-operator, 				 		 camel-k-operator-events,
+	// camel-k-operator-knative, 		 camel-k-operator-leases,
+	// camel-k-operator-podmonitors, camel-k-operator-service-binding
+	// camel-k-operator-strimzi
+	ExpKubePromoteRoles = 7
+
+	// camel-k-edit
+	ExpKubeClusterRoles = 1
+
+	// camel-k-operator-openshift
+	ExpOSPromoteRoles = 1
+
+	// camel-k-operator-console-openshift
+	ExpOSClusterRoles = 1
+)
+
+func ExecMake(t *testing.T, command *exec.Cmd) {
+	var cmdOut strings.Builder
+	var cmdErr strings.Builder
+
+	defer func() {
+		if t.Failed() {
+			t.Logf("Output from make command:\n%s\n", cmdOut.String())
+			t.Logf("Error from make command:\n%s\n", cmdErr.String())
+		}
+	}()
+
+	session, err := gexec.Start(command, &cmdOut, &cmdErr)
+	session.Wait()
+	Eventually(session).Should(gexec.Exit(0))
+	assert.Nil(t, err)
+	assert.NotContains(t, cmdErr.String(), "Error")
+	assert.NotContains(t, cmdErr.String(), "ERROR")
+}
+
+func Uninstall() {
+	//
+	// Removes all items including CRDs and ClusterRoles
+	//
+	Kamel("uninstall", "--olm=false", "--all").Execute()
+}
diff --git a/e2e/common/kustomize/operator_test.go b/e2e/common/kustomize/operator_test.go
new file mode 100644
index 0000000..ff5a231
--- /dev/null
+++ b/e2e/common/kustomize/operator_test.go
@@ -0,0 +1,89 @@
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package kustomize
+
+import (
+	"fmt"
+	"testing"
+
+	. "github.com/apache/camel-k/e2e/support"
+	. "github.com/onsi/gomega"
+)
+
+func TestBasicOperator(t *testing.T) {
+	defer Uninstall()
+
+	WithNewTestNamespace(t, func(ns string) {
+		ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
+		ExecMake(t, Make("setup", fmt.Sprintf("NAMESPACE=%s", ns)))
+		ExecMake(t, Make("operator", fmt.Sprintf("NAMESPACE=%s", ns)))
+
+		Eventually(OperatorPod(ns)).ShouldNot(BeNil())
+	})
+}
+
+func TestAlternativeImageOperator(t *testing.T) {
+	defer Uninstall()
+
+	WithNewTestNamespace(t, func(ns string) {
+
+		ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
+		ExecMake(t, Make("setup", fmt.Sprintf("NAMESPACE=%s", ns)))
+
+		newImage := "quay.io/kameltest/kamel-operator"
+		newTag := "1.1.1"
+		ExecMake(t, Make("operator", fmt.Sprintf("CUSTOM_IMAGE=%s", newImage), fmt.Sprintf("CUSTOM_VERSION=%s", newTag), fmt.Sprintf("NAMESPACE=%s", ns)))
+
+		Eventually(OperatorImage(ns)).Should(Equal(fmt.Sprintf("%s:%s", newImage, newTag)))
+	})
+}
+
+func TestGlobalOperator(t *testing.T) {
+	defer Uninstall()
+
+	WithNewTestNamespace(t, func(ns string) {
+		ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
+		ExecMake(t, Make("setup", fmt.Sprintf("NAMESPACE=%s", ns), "GLOBAL=true"))
+
+		ExecMake(t, Make("operator", fmt.Sprintf("NAMESPACE=%s", ns), "GLOBAL=true"))
+
+		podFunc := OperatorPod(ns)
+		Eventually(podFunc).Should(Not(BeNil()))
+		pod := podFunc()
+
+		containers := pod.Spec.Containers
+		Expect(containers).NotTo(BeEmpty())
+
+		envvars := containers[0].Env
+		Expect(envvars).NotTo(BeEmpty())
+
+		found := false
+		for _, v := range envvars {
+			if v.Name == "WATCH_NAMESPACE" {
+				Expect(v.Value).To(Equal("\"\""))
+				found = true
+				break
+			}
+		}
+		Expect(found).To(BeTrue())
+	})
+}
diff --git a/e2e/common/kustomize/setup_test.go b/e2e/common/kustomize/setup_test.go
new file mode 100644
index 0000000..5f536d7
--- /dev/null
+++ b/e2e/common/kustomize/setup_test.go
@@ -0,0 +1,70 @@
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package kustomize
+
+import (
+	"fmt"
+	"testing"
+
+	. "github.com/apache/camel-k/e2e/support"
+	. "github.com/onsi/gomega"
+)
+
+func TestBasicSetup(t *testing.T) {
+	defer Uninstall()
+
+	WithNewTestNamespace(t, func(ns string) {
+		ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
+		Eventually(CRDs()).Should(HaveLen(ExpCrds))
+
+		ExecMake(t, Make("setup", fmt.Sprintf("NAMESPACE=%s", ns)))
+
+		kroles := ExpKubePromoteRoles
+		osroles := kroles + ExpOSPromoteRoles
+		Eventually(Role(ns)).Should(Or(HaveLen(kroles), HaveLen(osroles)))
+
+		kcroles := ExpKubeClusterRoles
+		oscroles := kcroles + ExpOSClusterRoles
+		Eventually(ClusterRole()).Should(Or(HaveLen(kcroles), HaveLen(oscroles)))
+
+		// Tidy up to ensure next test works
+		Expect(Kamel("uninstall", "-n", ns).Execute()).To(Succeed())
+	})
+
+}
+
+func TestGlobalSetup(t *testing.T) {
+	defer Uninstall()
+
+	WithNewTestNamespace(t, func(ns string) {
+		ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
+		Eventually(CRDs()).Should(HaveLen(ExpCrds))
+
+		ExecMake(t, Make("setup", "GLOBAL=true", fmt.Sprintf("NAMESPACE=%s", ns)))
+
+		Eventually(Role(ns)).Should(HaveLen(0))
+
+		kcroles := ExpKubeClusterRoles + ExpKubePromoteRoles
+		oscroles := kcroles + ExpOSClusterRoles + ExpOSPromoteRoles
+		Eventually(ClusterRole()).Should(Or(HaveLen(kcroles), HaveLen(oscroles)))
+	})
+}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 1caf64d..8c12fbf 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -30,7 +30,8 @@ import (
 	"io"
 	"io/ioutil"
 	"os"
-	"os/exec"
+	exec "os/exec"
+	"reflect"
 	"strings"
 	"testing"
 	"time"
@@ -226,6 +227,33 @@ func KamelWithContext(ctx context.Context, args ...string) *cobra.Command {
 	return c
 }
 
+func Make(rule string, args ...string) *exec.Cmd {
+	return MakeWithContext(TestContext, rule, args...)
+}
+
+func MakeWithContext(ctx context.Context, rule string, args ...string) *exec.Cmd {
+	makeArgs := os.Getenv("MAKE_ARGS")
+	defaultArgs := strings.Fields(makeArgs)
+	args = append(defaultArgs, args...)
+
+	makeDir := os.Getenv("MAKE_DIR")
+	if makeDir == "" {
+		makeDir = "../../../install"
+	} else {
+		fmt.Printf("Using alternative make directory on path %s\n", makeDir)
+	}
+
+	if fi, e := os.Stat(makeDir); e != nil && os.IsNotExist(e) {
+		panic(e)
+	} else if !fi.Mode().IsDir() {
+		panic(e)
+	}
+
+	args = append([]string{"-C", makeDir, rule}, args...)
+
+	return exec.Command("make", args...)
+}
+
 /*
 	Curryied utility functions for testing
 */
@@ -997,6 +1025,46 @@ func PlatformProfile(ns string) func() v1.TraitProfile {
 	}
 }
 
+func CRDs() func() []metav1.APIResource {
+	return func() []metav1.APIResource {
+
+		kinds := []string{
+			reflect.TypeOf(v1.Build{}).Name(),
+			reflect.TypeOf(v1.Integration{}).Name(),
+			reflect.TypeOf(v1.IntegrationKit{}).Name(),
+			reflect.TypeOf(v1.IntegrationPlatform{}).Name(),
+			reflect.TypeOf(v1alpha1.Kamelet{}).Name(),
+			reflect.TypeOf(v1alpha1.KameletBinding{}).Name(),
+		}
+
+		versions := []string{"v1", "v1alpha1"}
+		present := []metav1.APIResource{}
+
+		for _, version := range versions {
+			lst, err := TestClient().Discovery().ServerResourcesForGroupVersion("camel.apache.org/" + version)
+			if err != nil && k8serrors.IsNotFound(err) {
+				return nil
+			} else if err != nil {
+				panic(err)
+			}
+
+			for _, res := range lst.APIResources {
+				if strings.Contains(res.Name, "/") {
+					continue // ignore sub types like status
+				}
+
+				for _, k := range kinds {
+					if k == res.Kind {
+						present = append(present, res)
+					}
+				}
+			}
+		}
+
+		return present
+	}
+}
+
 func OperatorPod(ns string) func() *corev1.Pod {
 	return func() *corev1.Pod {
 		lst := corev1.PodList{
@@ -1020,8 +1088,59 @@ func OperatorPod(ns string) func() *corev1.Pod {
 	}
 }
 
-func Role(ns string) func() *rbacv1.Role {
-	return func() *rbacv1.Role {
+func OperatorTryPodForceKill(ns string, timeSeconds int) {
+	pod := OperatorPod(ns)()
+	if pod != nil {
+		if err := TestClient().Delete(TestContext, pod, ctrl.GracePeriodSeconds(timeSeconds)); err != nil {
+			log.Error(err, "cannot forcefully kill the pod")
+		}
+	}
+}
+
+func ScaleOperator(ns string, replicas int32) func() error {
+	return func() error {
+		operator, err := TestClient().AppsV1().Deployments(ns).Get(TestContext, "camel-k-operator", metav1.GetOptions{})
+		if err != nil {
+			return err
+		}
+		operator.Spec.Replicas = &replicas
+		_, err = TestClient().AppsV1().Deployments(ns).Update(TestContext, operator, metav1.UpdateOptions{})
+		if err != nil {
+			return err
+		}
+
+		if replicas == 0 {
+			// speedup scale down by killing the pod
+			OperatorTryPodForceKill(ns, 10)
+		}
+		return nil
+	}
+}
+
+func ClusterRole() func() []rbacv1.ClusterRole {
+	return func() []rbacv1.ClusterRole {
+		lst := rbacv1.ClusterRoleList{
+			TypeMeta: metav1.TypeMeta{
+				Kind:       "ClusterRole",
+				APIVersion: rbacv1.SchemeGroupVersion.String(),
+			},
+		}
+		err := TestClient().List(TestContext, &lst,
+			ctrl.MatchingLabels{
+				"app": "camel-k",
+			})
+		if err != nil {
+			panic(err)
+		}
+		if len(lst.Items) == 0 {
+			return nil
+		}
+		return lst.Items
+	}
+}
+
+func Role(ns string) func() []rbacv1.Role {
+	return func() []rbacv1.Role {
 		lst := rbacv1.RoleList{
 			TypeMeta: metav1.TypeMeta{
 				Kind:       "Role",
@@ -1039,7 +1158,7 @@ func Role(ns string) func() *rbacv1.Role {
 		if len(lst.Items) == 0 {
 			return nil
 		}
-		return &lst.Items[0]
+		return lst.Items
 	}
 }
 
@@ -1153,7 +1272,7 @@ func CreateOperatorRole(ns string) (err error) {
 		return err
 	}
 	if oc {
-		return install.Resource(TestContext, TestClient(), ns, true, install.IdentityResourceCustomizer, "/rbac/operator-role-openshift.yaml")
+		return install.Resource(TestContext, TestClient(), ns, true, install.IdentityResourceCustomizer, "/rbac/openshift/operator-role-openshift.yaml")
 	}
 	return nil
 }
@@ -1168,7 +1287,7 @@ func CreateOperatorRoleBinding(ns string) error {
 		return err
 	}
 	if oc {
-		return install.Resource(TestContext, TestClient(), ns, true, install.IdentityResourceCustomizer, "/rbac/operator-role-binding-openshift.yaml")
+		return install.Resource(TestContext, TestClient(), ns, true, install.IdentityResourceCustomizer, "/rbac/openshift/operator-role-binding-openshift.yaml")
 	}
 	return nil
 }