This is an automated email from the ASF dual-hosted git repository. pcongiusti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 9e8876974d931d37edc711468d3da31bb47d759d Author: Pasquale Congiusti <[email protected]> AuthorDate: Wed Feb 22 12:06:07 2023 +0100 chore(test): e2e folder reorganization --- .github/actions/e2e-builder/exec-tests.sh | 2 +- .github/actions/e2e-common/action.yml | 4 ++ .github/actions/e2e-common/exec-tests.sh | 11 ++- .github/actions/e2e-install/exec-tests.sh | 2 +- .github/actions/e2e-knative/exec-tests.sh | 2 +- .../{e2e-install-native => e2e-native}/action.yml | 6 +- .../exec-tests.sh | 4 +- .github/actions/e2e-telemetry/exec-tests.sh | 2 +- .github/actions/e2e-upgrade/exec-tests.sh | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/builder.yml | 2 +- .github/workflows/common.yml | 26 +++++++- .github/workflows/install.yml | 26 +++++++- .github/workflows/knative.yml | 8 +-- .github/workflows/native.yml | 8 +-- e2e/common/cli/bind_test.go | 5 +- e2e/common/cli/debug_test.go | 8 +-- e2e/common/cli/default.go | 6 +- e2e/common/cli/delete_test.go | 12 ++-- e2e/common/cli/describe_test.go | 6 +- e2e/common/cli/dump_test.go | 9 --- e2e/common/cli/get_test.go | 6 +- e2e/common/cli/kamel-config.yaml | 3 - e2e/common/cli/log_test.go | 2 +- e2e/common/config/default.go | 6 +- e2e/common/languages/default.go | 6 +- e2e/common/misc/default.go | 6 +- e2e/common/startup_test.go | 18 ++--- e2e/common/teardown_test.go | 5 +- e2e/common/traits/default.go | 6 +- e2e/common/traits/health_test.go | 4 ++ .../environment_test.go | 2 +- .../files/Java.java | 0 .../files/yaml.yaml | 0 .../incremental_build_test.go | 2 +- .../maven_http_proxy_test.go | 2 +- .../operator_id_filtering_test.go | 2 +- .../operator_metrics_test.go | 2 +- .../promote_test.go | 2 +- .../misc => commonwithcustominstall}/reset_test.go | 2 +- .../secondary_platform_test.go | 2 +- .../tekton_test.go | 18 ++--- .../install/cli/files/Java.java | 0 .../install/cli/files/timer-kamelet-usage.groovy | 0 .../misc => install/cli}/files/yaml.yaml | 0 .../install/cli/global_kamelet_test.go | 0 .../install/cli/global_test.go | 0 .../install/cli/install_test.go | 0 .../install/cli/maven_ca_secret_test.go | 0 .../install/cli/uninstall_test.go | 0 .../install/kustomize/common.go | 0 .../install/kustomize/operator_test.go | 0 .../install/kustomize/setup_test.go | 0 .../install/kustomize/uninstall_test.go | 0 e2e/{upgrade => install/olm}/files/yaml.yaml | 0 e2e/{upgrade => install/olm}/olm_install_test.go | 12 ++-- e2e/{ => install}/upgrade/cli_upgrade_test.go | 0 e2e/{ => install}/upgrade/files/yaml.yaml | 0 e2e/{ => install}/upgrade/olm_upgrade_test.go | 22 +++--- e2e/{upgrade/util.go => support/csv.go} | 27 ++++---- e2e/support/test_support.go | 24 +++++++ script/Makefile | 78 +++++++++++++++------- 62 files changed, 265 insertions(+), 147 deletions(-) diff --git a/.github/actions/e2e-builder/exec-tests.sh b/.github/actions/e2e-builder/exec-tests.sh index a622897a3..76fbbea54 100755 --- a/.github/actions/e2e-builder/exec-tests.sh +++ b/.github/actions/e2e-builder/exec-tests.sh @@ -132,4 +132,4 @@ if [ -n "${GLOBAL_OPERATOR_NAMESPACE}" ]; then fi # Then run integration tests -DO_TEST_PREBUILD=false make test-builder +DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-builder diff --git a/.github/actions/e2e-common/action.yml b/.github/actions/e2e-common/action.yml index e75c35149..ba9052873 100644 --- a/.github/actions/e2e-common/action.yml +++ b/.github/actions/e2e-common/action.yml @@ -25,6 +25,9 @@ inputs: cluster-kube-config-data: description: 'Base16 encoded kube config - required for custom cluster type only' required: false + with-custom-install: + description: 'Special type of common tests which require customized installation procedure' + required: false runs: using: "composite" @@ -120,6 +123,7 @@ runs: -s "${{steps.config-cluster.outputs.cluster-image-registry-insecure }}" \ -v "${{ steps.build-kamel.outputs.build-binary-local-image-version }}" \ -x "${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }}" + -z "${{ inputs.with-custom-install }}" - name: Cleanup uses: ./.github/actions/kamel-cleanup diff --git a/.github/actions/e2e-common/exec-tests.sh b/.github/actions/e2e-common/exec-tests.sh index 0d2d75c6a..00ec6e804 100755 --- a/.github/actions/e2e-common/exec-tests.sh +++ b/.github/actions/e2e-common/exec-tests.sh @@ -25,7 +25,7 @@ set -e -while getopts ":b:c:g:i:l:n:q:s:v:x:" opt; do +while getopts ":b:c:g:i:l:n:q:s:v:x:z:" opt; do case "${opt}" in b) BUILD_CATALOG_SOURCE_NAME=${OPTARG} @@ -57,6 +57,9 @@ while getopts ":b:c:g:i:l:n:q:s:v:x:" opt; do x) SAVE_FAILED_TEST_NS=${OPTARG} ;; + z) + CUSTOM_INSTALL_TEST=${OPTARG} + ;; :) echo "ERROR: Option -$OPTARG requires an argument" exit 1 @@ -134,7 +137,11 @@ fi # Then run all integration tests rather than ending on first failure set -e exit_code=0 -DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-common || exit_code=1 +if [ -z "${CUSTOM_INSTALL_TEST}" ]; then + DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-common-with-custom-install || exit_code=1 +else + DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-common || exit_code=1 +fi set +e echo "Tests completed with exit code: ${exit_code}" diff --git a/.github/actions/e2e-install/exec-tests.sh b/.github/actions/e2e-install/exec-tests.sh index 44d5b75b3..068956e04 100755 --- a/.github/actions/e2e-install/exec-tests.sh +++ b/.github/actions/e2e-install/exec-tests.sh @@ -124,4 +124,4 @@ export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} # Then run integration tests -DO_TEST_PREBUILD=false make test-install +DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-install diff --git a/.github/actions/e2e-knative/exec-tests.sh b/.github/actions/e2e-knative/exec-tests.sh index aa365c96a..2ca4598fb 100755 --- a/.github/actions/e2e-knative/exec-tests.sh +++ b/.github/actions/e2e-knative/exec-tests.sh @@ -135,4 +135,4 @@ if [ -n "${GLOBAL_OPERATOR_NAMESPACE}" ]; then fi # Then run integration tests -DO_TEST_PREBUILD=false make test-knative +DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-knative diff --git a/.github/actions/e2e-install-native/action.yml b/.github/actions/e2e-native/action.yml similarity index 96% rename from .github/actions/e2e-install-native/action.yml rename to .github/actions/e2e-native/action.yml index 70b4556f2..ba1656478 100644 --- a/.github/actions/e2e-install-native/action.yml +++ b/.github/actions/e2e-native/action.yml @@ -15,8 +15,8 @@ # limitations under the License. # --------------------------------------------------------------------------- -name: e2e-install-native -description: 'End-to-End tests for install use-cases (namespaced rather than global operator so no global operator install) with native builds' +name: e2e-native +description: 'End-to-End tests for Quarkus native builds' inputs: cluster-config-data: @@ -100,7 +100,7 @@ runs: name: Run IT shell: bash run: | - ./.github/actions/e2e-install-native/exec-tests.sh \ + ./.github/actions/e2e-native/exec-tests.sh \ -b "${{ steps.config-cluster.outputs.cluster-catalog-source-name }}" \ -c "${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }}" \ -i "${{ steps.config-cluster.outputs.cluster-image-namespace }}" \ diff --git a/.github/actions/e2e-install-native/exec-tests.sh b/.github/actions/e2e-native/exec-tests.sh similarity index 95% rename from .github/actions/e2e-install-native/exec-tests.sh rename to .github/actions/e2e-native/exec-tests.sh index 2d9192fd5..9c637e775 100755 --- a/.github/actions/e2e-install-native/exec-tests.sh +++ b/.github/actions/e2e-native/exec-tests.sh @@ -129,7 +129,7 @@ fi # Then run integration tests if [ "${HIGH_MEMORY}" == "true" ]; then - DO_TEST_PREBUILD=false make test-quarkus-native-high-memory + DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-quarkus-native-high-memory else - DO_TEST_PREBUILD=false make test-quarkus-native + DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-quarkus-native fi diff --git a/.github/actions/e2e-telemetry/exec-tests.sh b/.github/actions/e2e-telemetry/exec-tests.sh index 92ba0a7c4..1373ad39a 100755 --- a/.github/actions/e2e-telemetry/exec-tests.sh +++ b/.github/actions/e2e-telemetry/exec-tests.sh @@ -134,7 +134,7 @@ fi # Then run all integration telemetry test rather than ending on first failure set -e exit_code=0 -DO_TEST_PREBUILD=false make test-telemetry || exit_code=1 +DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-telemetry || exit_code=1 set +e echo "Tests completed with exit code: ${exit_code}" diff --git a/.github/actions/e2e-upgrade/exec-tests.sh b/.github/actions/e2e-upgrade/exec-tests.sh index 38dd6a626..a3cd9414e 100755 --- a/.github/actions/e2e-upgrade/exec-tests.sh +++ b/.github/actions/e2e-upgrade/exec-tests.sh @@ -128,4 +128,4 @@ export KAMEL_K_TEST_OPERATOR_CURRENT_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} # Then run integration tests -DO_TEST_PREBUILD=false make test-upgrade +DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-install-upgrade diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ae3a203c..41a5e86c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,5 +67,5 @@ jobs: with: persist-credentials: false submodules: recursive - - name: Execute Build Tests + - name: Execute Build (make) uses: ./.github/actions/e2e-build diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml index 35c00fd71..36920d3e3 100644 --- a/.github/workflows/builder.yml +++ b/.github/workflows/builder.yml @@ -91,7 +91,7 @@ jobs: -q "${{ github.event.inputs.log-level }}" \ -t "${{ github.event.inputs.test-filters }}" - - name: Execute Builder Tests + - name: Builder Tests uses: ./.github/actions/e2e-builder with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index 516090aae..5a47790a8 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -71,8 +71,7 @@ concurrency: cancel-in-progress: true jobs: - common-it: - + common-it-single-operator-installation: runs-on: ubuntu-20.04 steps: @@ -89,9 +88,32 @@ jobs: -p "${{ github.event.inputs.skip-problematic }}" \ -q "${{ github.event.inputs.log-level }}" \ -t "${{ github.event.inputs.test-filters }}" + - name: Smoke tests + uses: ./.github/actions/e2e-common + with: + cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} + cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} + common-it-custom-operator-installation: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + persist-credentials: false + submodules: recursive + - name: Convert input parameters to env vars + shell: bash + run: | + ./.github/workflows/manual-exec-process-inputs.sh \ + -i "${{ github.event.inputs.pre-built-kamel-image }}" \ + -p "${{ github.event.inputs.skip-problematic }}" \ + -q "${{ github.event.inputs.log-level }}" \ + -t "${{ github.event.inputs.test-filters }}" - name: Execute Tests uses: ./.github/actions/e2e-common with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} + with-custom-install: true diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 45bbaadf0..d75425bca 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -87,8 +87,32 @@ jobs: -q "${{ github.event.inputs.log-level }}" \ -t "${{ github.event.inputs.test-filters }}" - - name: Execute Tests + - name: Install Tests uses: ./.github/actions/e2e-install with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} + + upgrade-it: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + persist-credentials: false + submodules: recursive + - name: Convert input parameters to env vars + shell: bash + run: | + ./.github/workflows/manual-exec-process-inputs.sh \ + -i "${{ github.event.inputs.pre-built-kamel-image }}" \ + -p "${{ github.event.inputs.skip-problematic }}" \ + -q "${{ github.event.inputs.log-level }}" \ + -t "${{ github.event.inputs.test-filters }}" + + - name: Upgrade Tests + uses: ./.github/actions/e2e-upgrade + with: + cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} + cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} diff --git a/.github/workflows/knative.yml b/.github/workflows/knative.yml index b76662e0d..2c7f84cb9 100644 --- a/.github/workflows/knative.yml +++ b/.github/workflows/knative.yml @@ -68,7 +68,7 @@ concurrency: cancel-in-progress: true jobs: - test: + knative-test: runs-on: ubuntu-20.04 steps: @@ -86,13 +86,13 @@ jobs: -q "${{ github.event.inputs.log-level }}" \ -t "${{ github.event.inputs.test-filters }}" - - name: Execute KNative Tests + - name: KNative Tests uses: ./.github/actions/e2e-knative with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} - yaks: + yaks-test: runs-on: ubuntu-20.04 steps: - name: Checkout code @@ -101,7 +101,7 @@ jobs: persist-credentials: false submodules: recursive - - name: Execute Knative YAKS Tests + - name: YAKS Tests uses: ./.github/actions/e2e-knative-yaks with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index 3888ec282..e5b38a19f 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -80,8 +80,8 @@ jobs: -p "${{ github.event.inputs.skip-problematic }}" \ -q "${{ github.event.inputs.log-level }}" \ -t "${{ github.event.inputs.test-filters }}" - - name: Native smoke tests - uses: ./.github/actions/e2e-install-native + - name: Native test + uses: ./.github/actions/e2e-native with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} @@ -105,8 +105,8 @@ jobs: -p "${{ github.event.inputs.skip-problematic }}" \ -q "${{ github.event.inputs.log-level }}" \ -t "${{ github.event.inputs.test-filters }}" - - name: Native smoke tests - uses: ./.github/actions/e2e-install-native + - name: Native test + uses: ./.github/actions/e2e-native with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} diff --git a/e2e/common/cli/bind_test.go b/e2e/common/cli/bind_test.go index cc2341c15..00b87ad0b 100644 --- a/e2e/common/cli/bind_test.go +++ b/e2e/common/cli/bind_test.go @@ -35,10 +35,11 @@ import ( func TestKamelCLIBind(t *testing.T) { RegisterTestingT(t) - Expect(CreateTimerKamelet(ns, "test-timer-source")()).To(Succeed()) + kameletName := "test-timer-source" + Expect(CreateTimerKamelet(ns, kameletName)()).To(Succeed()) t.Run("bind timer to log", func(t *testing.T) { - Expect(KamelBindWithID(operatorID, ns, "test-timer-source", "log:info", "-p", "source.message=helloTest").Execute()).To(Succeed()) + Expect(KamelBindWithID(operatorID, ns, kameletName, "log:info", "-p", "source.message=helloTest").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "test-timer-source-to-log"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) Eventually(IntegrationLogs(ns, "test-timer-source-to-log")).Should(ContainSubstring("Body: helloTest")) Expect(KamelBindWithID(operatorID, ns, "test-timer-source", "log:info", "-p", "source.message=newText").Execute()).To(Succeed()) diff --git a/e2e/common/cli/debug_test.go b/e2e/common/cli/debug_test.go index 2b3d75b2e..9633375fa 100644 --- a/e2e/common/cli/debug_test.go +++ b/e2e/common/cli/debug_test.go @@ -36,7 +36,7 @@ func TestKamelCLIDebug(t *testing.T) { RegisterTestingT(t) t.Run("debug local default port check", func(t *testing.T) { - Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(v1.PodRunning)) Expect(portIsInUse("127.0.0.1", "5005")()).To(BeFalse()) @@ -49,7 +49,7 @@ func TestKamelCLIDebug(t *testing.T) { }) t.Run("debug local port check", func(t *testing.T) { - Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(v1.PodRunning)) Expect(portIsInUse("127.0.0.1", "5006")()).To(BeFalse()) @@ -62,7 +62,7 @@ func TestKamelCLIDebug(t *testing.T) { }) t.Run("debug logs check", func(t *testing.T) { - Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(v1.PodRunning)) debugTestContext, cancel := context.WithCancel(TestContext) @@ -74,7 +74,7 @@ func TestKamelCLIDebug(t *testing.T) { }) t.Run("Pod config test", func(t *testing.T) { - Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(v1.PodRunning)) debugTestContext, cancel := context.WithCancel(TestContext) diff --git a/e2e/common/cli/default.go b/e2e/common/cli/default.go index 1f7169227..a54257110 100644 --- a/e2e/common/cli/default.go +++ b/e2e/common/cli/default.go @@ -20,5 +20,7 @@ limitations under the License. package cli -const ns = "camel-k-test-integration" -const operatorID = "camel-k-test-integration" +import "github.com/apache/camel-k/e2e/support" + +var ns = support.GetCIProcessID() +var operatorID = support.GetCIProcessID() diff --git a/e2e/common/cli/delete_test.go b/e2e/common/cli/delete_test.go index 3b25ba949..d0bc1cb3d 100644 --- a/e2e/common/cli/delete_test.go +++ b/e2e/common/cli/delete_test.go @@ -36,7 +36,7 @@ func TestKamelCLIDelete(t *testing.T) { RegisterTestingT(t) t.Run("delete running integration", func(t *testing.T) { - Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed()) Eventually(Integration(ns, "yaml")).Should(BeNil()) @@ -44,7 +44,7 @@ func TestKamelCLIDelete(t *testing.T) { }) t.Run("delete building integration", func(t *testing.T) { - Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed()) Eventually(Integration(ns, "yaml")).Should(BeNil()) Eventually(IntegrationPod(ns, "yaml"), TestTimeoutLong).Should(BeNil()) @@ -59,8 +59,8 @@ func TestKamelCLIDelete(t *testing.T) { }) t.Run("delete several integrations", func(t *testing.T) { - Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed()) - Expect(KamelRunWithID(operatorID, ns, "../files/Java.java").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed()) @@ -72,8 +72,8 @@ func TestKamelCLIDelete(t *testing.T) { }) t.Run("delete all integrations", func(t *testing.T) { - Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed()) - Expect(KamelRunWithID(operatorID, ns, "../files/Java.java").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) diff --git a/e2e/common/cli/describe_test.go b/e2e/common/cli/describe_test.go index 7fd3eb417..c9d4edf28 100644 --- a/e2e/common/cli/describe_test.go +++ b/e2e/common/cli/describe_test.go @@ -23,6 +23,7 @@ limitations under the License. package cli import ( + "fmt" "regexp" "testing" @@ -70,10 +71,9 @@ func TestKamelCliDescribe(t *testing.T) { t.Run("Test kamel describe integration platform", func(t *testing.T) { platform := GetOutputString(Kamel("describe", "platform", operatorID, "-n", ns)) - r, _ := regexp.Compile("(?sm).*Name:\\s+camel-k.*") - Expect(platform).To(MatchRegexp(r.String())) + Expect(platform).To(ContainSubstring(fmt.Sprintf("Name: %s", operatorID))) - r, _ = regexp.Compile("(?sm).*Namespace:\\s+" + ns + ".*") + r, _ := regexp.Compile("(?sm).*Namespace:\\s+" + ns + ".*") Expect(platform).To(MatchRegexp(r.String())) r, _ = regexp.Compile("(?sm).*Runtime Version:\\s+" + defaults.DefaultRuntimeVersion + ".*") diff --git a/e2e/common/cli/dump_test.go b/e2e/common/cli/dump_test.go index 9c0cec270..c37aa3059 100644 --- a/e2e/common/cli/dump_test.go +++ b/e2e/common/cli/dump_test.go @@ -35,16 +35,7 @@ import ( func TestKamelCLIDump(t *testing.T) { RegisterTestingT(t) - t.Run("dump empty namespace", func(t *testing.T) { - dump := GetOutputString(Kamel("dump", "-n", ns)) - - Expect(dump).To(ContainSubstring("Found 0 integrations:")) - Expect(dump).To(ContainSubstring("Found 0 deployments:")) - }) - t.Run("dump non-empty namespace", func(t *testing.T) { - operatorID := "camel-k-cli-dump" - Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) Eventually(IntegrationLogs(ns, "yaml")).Should(ContainSubstring("Magicstring!")) diff --git a/e2e/common/cli/get_test.go b/e2e/common/cli/get_test.go index 1ea9716c1..b5e94a57c 100644 --- a/e2e/common/cli/get_test.go +++ b/e2e/common/cli/get_test.go @@ -37,7 +37,7 @@ func TestKamelCLIGet(t *testing.T) { RegisterTestingT(t) t.Run("get integration", func(t *testing.T) { - Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) // regex is used for the compatibility of tests between OC and vanilla K8 // kamel get may have different output depending og the platform @@ -49,8 +49,8 @@ func TestKamelCLIGet(t *testing.T) { }) t.Run("get several integrations", func(t *testing.T) { - Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed()) - Expect(KamelRunWithID(operatorID, ns, "../files/Java.java").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) diff --git a/e2e/common/cli/kamel-config.yaml b/e2e/common/cli/kamel-config.yaml deleted file mode 100644 index 1be15da78..000000000 --- a/e2e/common/cli/kamel-config.yaml +++ /dev/null @@ -1,3 +0,0 @@ -kamel: - config: - default-namespace: camel-k-test-integration diff --git a/e2e/common/cli/log_test.go b/e2e/common/cli/log_test.go index dc085c467..80a39ccee 100644 --- a/e2e/common/cli/log_test.go +++ b/e2e/common/cli/log_test.go @@ -37,7 +37,7 @@ func TestKamelCLILog(t *testing.T) { RegisterTestingT(t) t.Run("check integration log", func(t *testing.T) { - Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) // first line of the integration logs firstLine := strings.Split(IntegrationLogs(ns, "yaml")(), "\n")[0] diff --git a/e2e/common/config/default.go b/e2e/common/config/default.go index 58a809543..af7a4a5f3 100644 --- a/e2e/common/config/default.go +++ b/e2e/common/config/default.go @@ -20,5 +20,7 @@ limitations under the License. package config -const ns = "camel-k-test-integration" -const operatorID = "camel-k-test-integration" +import "github.com/apache/camel-k/e2e/support" + +var ns = support.GetCIProcessID() +var operatorID = support.GetCIProcessID() diff --git a/e2e/common/languages/default.go b/e2e/common/languages/default.go index b8a53bf59..d9316a1af 100644 --- a/e2e/common/languages/default.go +++ b/e2e/common/languages/default.go @@ -20,5 +20,7 @@ limitations under the License. package languages -const ns = "camel-k-test-integration" -const operatorID = "camel-k-test-integration" +import "github.com/apache/camel-k/e2e/support" + +var ns = support.GetCIProcessID() +var operatorID = support.GetCIProcessID() diff --git a/e2e/common/misc/default.go b/e2e/common/misc/default.go index 0514eb0e7..8909d033f 100644 --- a/e2e/common/misc/default.go +++ b/e2e/common/misc/default.go @@ -20,5 +20,7 @@ limitations under the License. package misc -const ns = "camel-k-test-integration" -const operatorID = "camel-k-test-integration" +import "github.com/apache/camel-k/e2e/support" + +var ns = support.GetCIProcessID() +var operatorID = support.GetCIProcessID() diff --git a/e2e/common/startup_test.go b/e2e/common/startup_test.go index 749f26d4c..546c3b190 100644 --- a/e2e/common/startup_test.go +++ b/e2e/common/startup_test.go @@ -23,7 +23,6 @@ limitations under the License. package common import ( - "os" "testing" . "github.com/onsi/gomega" @@ -36,12 +35,15 @@ import ( func TestDefaultCamelKInstallStartup(t *testing.T) { RegisterTestingT(t) - ns := "camel-k-test-integration" - os.Setenv("CAMEL_K_TEST_NS", ns) - Expect(NewTestNamespace(false)).ShouldNot(BeNil()) - Expect(KamelInstallWithID(ns, ns).Execute()).To(Succeed()) - Eventually(OperatorPod(ns)).ShouldNot(BeNil()) - Eventually(Platform(ns)).ShouldNot(BeNil()) - Eventually(PlatformConditionStatus(ns, v1.IntegrationPlatformConditionReady), TestTimeoutShort). + ns := NewTestNamespace(false) + Expect(ns).ShouldNot(BeNil()) + // the namespace is dynamic if there is some collision + // we store this value as it will be used for cleaning in the teardown process + SaveCIProcessID(ns.GetName()) + + Expect(KamelInstallWithIDAndKameletCatalog(ns.GetName(), ns.GetName()).Execute()).To(Succeed()) + Eventually(OperatorPod(ns.GetName())).ShouldNot(BeNil()) + Eventually(Platform(ns.GetName())).ShouldNot(BeNil()) + Eventually(PlatformConditionStatus(ns.GetName(), v1.IntegrationPlatformConditionReady), TestTimeoutShort). Should(Equal(corev1.ConditionTrue)) } diff --git a/e2e/common/teardown_test.go b/e2e/common/teardown_test.go index 76de53797..682e6ffce 100644 --- a/e2e/common/teardown_test.go +++ b/e2e/common/teardown_test.go @@ -23,7 +23,6 @@ limitations under the License. package common import ( - "os" "testing" . "github.com/onsi/gomega" @@ -34,6 +33,8 @@ import ( func TestDefaultCamelKInstallTeardown(t *testing.T) { RegisterTestingT(t) - ns := os.Getenv("CAMEL_K_TEST_NS") + ns := GetCIProcessID() + Expect(ns).ShouldNot(BeNil()) Expect(DeleteNamespace(t, ns)).To(Succeed()) + DeleteCIProcessID() } diff --git a/e2e/common/traits/default.go b/e2e/common/traits/default.go index 64e0abe67..81eac027c 100644 --- a/e2e/common/traits/default.go +++ b/e2e/common/traits/default.go @@ -20,5 +20,7 @@ limitations under the License. package traits -const ns = "camel-k-test-integration" -const operatorID = "camel-k-test-integration" +import "github.com/apache/camel-k/e2e/support" + +var ns = support.GetCIProcessID() +var operatorID = support.GetCIProcessID() diff --git a/e2e/common/traits/health_test.go b/e2e/common/traits/health_test.go index 5f225b8ae..0e43738c6 100644 --- a/e2e/common/traits/health_test.go +++ b/e2e/common/traits/health_test.go @@ -136,6 +136,10 @@ func TestHealthTrait(t *testing.T) { t.Run("Readiness condition with stopped binding", func(t *testing.T) { name := "stopped-binding" + // Clean up any previous kamelet with same name + Expect(TestClient().Delete(TestContext, Kamelet("my-own-timer-source", ns)())).To(Succeed()) + Expect(TestClient().Delete(TestContext, Kamelet("my-own-log-sink", ns)())).To(Succeed()) + Expect(CreateTimerKamelet(ns, "my-own-timer-source")()).To(Succeed()) Expect(CreateLogKamelet(ns, "my-own-log-sink")()).To(Succeed()) diff --git a/e2e/withnewnamespace/misc/environment_test.go b/e2e/commonwithcustominstall/environment_test.go similarity index 99% rename from e2e/withnewnamespace/misc/environment_test.go rename to e2e/commonwithcustominstall/environment_test.go index c91c066ba..5999485ec 100644 --- a/e2e/withnewnamespace/misc/environment_test.go +++ b/e2e/commonwithcustominstall/environment_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package misc +package commonwithcustominstall import ( "fmt" diff --git a/e2e/withnewnamespace/misc/files/Java.java b/e2e/commonwithcustominstall/files/Java.java similarity index 100% rename from e2e/withnewnamespace/misc/files/Java.java rename to e2e/commonwithcustominstall/files/Java.java diff --git a/e2e/upgrade/files/yaml.yaml b/e2e/commonwithcustominstall/files/yaml.yaml similarity index 100% copy from e2e/upgrade/files/yaml.yaml copy to e2e/commonwithcustominstall/files/yaml.yaml diff --git a/e2e/withnewnamespace/misc/incremental_build_test.go b/e2e/commonwithcustominstall/incremental_build_test.go similarity index 98% rename from e2e/withnewnamespace/misc/incremental_build_test.go rename to e2e/commonwithcustominstall/incremental_build_test.go index 5ddb714c6..bbedf3b27 100644 --- a/e2e/withnewnamespace/misc/incremental_build_test.go +++ b/e2e/commonwithcustominstall/incremental_build_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package misc +package commonwithcustominstall import ( "testing" diff --git a/e2e/withnewnamespace/misc/maven_http_proxy_test.go b/e2e/commonwithcustominstall/maven_http_proxy_test.go similarity index 99% rename from e2e/withnewnamespace/misc/maven_http_proxy_test.go rename to e2e/commonwithcustominstall/maven_http_proxy_test.go index f414cfb67..70b9d0e04 100644 --- a/e2e/withnewnamespace/misc/maven_http_proxy_test.go +++ b/e2e/commonwithcustominstall/maven_http_proxy_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package misc +package commonwithcustominstall import ( "crypto/rand" diff --git a/e2e/withnewnamespace/misc/operator_id_filtering_test.go b/e2e/commonwithcustominstall/operator_id_filtering_test.go similarity index 99% rename from e2e/withnewnamespace/misc/operator_id_filtering_test.go rename to e2e/commonwithcustominstall/operator_id_filtering_test.go index e364b7962..9c3e7dce6 100644 --- a/e2e/withnewnamespace/misc/operator_id_filtering_test.go +++ b/e2e/commonwithcustominstall/operator_id_filtering_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package misc +package commonwithcustominstall import ( "fmt" diff --git a/e2e/withnewnamespace/misc/operator_metrics_test.go b/e2e/commonwithcustominstall/operator_metrics_test.go similarity index 99% rename from e2e/withnewnamespace/misc/operator_metrics_test.go rename to e2e/commonwithcustominstall/operator_metrics_test.go index bcf90536a..9bc20a488 100644 --- a/e2e/withnewnamespace/misc/operator_metrics_test.go +++ b/e2e/commonwithcustominstall/operator_metrics_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package misc +package commonwithcustominstall import ( "bytes" diff --git a/e2e/withnewnamespace/misc/promote_test.go b/e2e/commonwithcustominstall/promote_test.go similarity index 99% rename from e2e/withnewnamespace/misc/promote_test.go rename to e2e/commonwithcustominstall/promote_test.go index f65dafe86..8348e7e64 100644 --- a/e2e/withnewnamespace/misc/promote_test.go +++ b/e2e/commonwithcustominstall/promote_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package misc +package commonwithcustominstall import ( "testing" diff --git a/e2e/withnewnamespace/misc/reset_test.go b/e2e/commonwithcustominstall/reset_test.go similarity index 99% rename from e2e/withnewnamespace/misc/reset_test.go rename to e2e/commonwithcustominstall/reset_test.go index a1f992908..19311a8a5 100644 --- a/e2e/withnewnamespace/misc/reset_test.go +++ b/e2e/commonwithcustominstall/reset_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package misc +package commonwithcustominstall import ( "testing" diff --git a/e2e/withnewnamespace/misc/secondary_platform_test.go b/e2e/commonwithcustominstall/secondary_platform_test.go similarity index 98% rename from e2e/withnewnamespace/misc/secondary_platform_test.go rename to e2e/commonwithcustominstall/secondary_platform_test.go index 2a4aff7b8..ae97080c0 100644 --- a/e2e/withnewnamespace/misc/secondary_platform_test.go +++ b/e2e/commonwithcustominstall/secondary_platform_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package misc +package commonwithcustominstall import ( "testing" diff --git a/e2e/common/misc/tekton_test.go b/e2e/commonwithcustominstall/tekton_test.go similarity index 74% rename from e2e/common/misc/tekton_test.go rename to e2e/commonwithcustominstall/tekton_test.go index 934564777..dd6bb3056 100644 --- a/e2e/common/misc/tekton_test.go +++ b/e2e/commonwithcustominstall/tekton_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package misc +package commonwithcustominstall import ( "testing" @@ -35,14 +35,14 @@ import ( func TestTektonLikeBehavior(t *testing.T) { RegisterTestingT(t) - Expect(CreateOperatorServiceAccount(ns)).To(Succeed()) - Expect(CreateOperatorRole(ns)).To(Succeed()) - Expect(CreateOperatorRoleBinding(ns)).To(Succeed()) + WithNewTestNamespace(t, func(ns string) { + Expect(CreateOperatorServiceAccount(ns)).To(Succeed()) + Expect(CreateOperatorRole(ns)).To(Succeed()) + Expect(CreateOperatorRoleBinding(ns)).To(Succeed()) - Eventually(OperatorPod(ns)).Should(BeNil()) - Expect(CreateKamelPod(ns, "tekton-task", "install", "--skip-cluster-setup", "--force")).To(Succeed()) + Eventually(OperatorPod(ns)).Should(BeNil()) + Expect(CreateKamelPod(ns, "tekton-task", "install", "--skip-cluster-setup", "--force")).To(Succeed()) - Eventually(OperatorPod(ns)).ShouldNot(BeNil()) - - Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) + Eventually(OperatorPod(ns)).ShouldNot(BeNil()) + }) } diff --git a/e2e/withnewnamespace/install/cli/files/Java.java b/e2e/install/cli/files/Java.java similarity index 100% rename from e2e/withnewnamespace/install/cli/files/Java.java rename to e2e/install/cli/files/Java.java diff --git a/e2e/withnewnamespace/install/cli/files/timer-kamelet-usage.groovy b/e2e/install/cli/files/timer-kamelet-usage.groovy similarity index 100% rename from e2e/withnewnamespace/install/cli/files/timer-kamelet-usage.groovy rename to e2e/install/cli/files/timer-kamelet-usage.groovy diff --git a/e2e/withnewnamespace/misc/files/yaml.yaml b/e2e/install/cli/files/yaml.yaml similarity index 100% rename from e2e/withnewnamespace/misc/files/yaml.yaml rename to e2e/install/cli/files/yaml.yaml diff --git a/e2e/withnewnamespace/install/cli/global_kamelet_test.go b/e2e/install/cli/global_kamelet_test.go similarity index 100% rename from e2e/withnewnamespace/install/cli/global_kamelet_test.go rename to e2e/install/cli/global_kamelet_test.go diff --git a/e2e/withnewnamespace/install/cli/global_test.go b/e2e/install/cli/global_test.go similarity index 100% rename from e2e/withnewnamespace/install/cli/global_test.go rename to e2e/install/cli/global_test.go diff --git a/e2e/withnewnamespace/install/cli/install_test.go b/e2e/install/cli/install_test.go similarity index 100% rename from e2e/withnewnamespace/install/cli/install_test.go rename to e2e/install/cli/install_test.go diff --git a/e2e/withnewnamespace/install/cli/maven_ca_secret_test.go b/e2e/install/cli/maven_ca_secret_test.go similarity index 100% rename from e2e/withnewnamespace/install/cli/maven_ca_secret_test.go rename to e2e/install/cli/maven_ca_secret_test.go diff --git a/e2e/withnewnamespace/install/cli/uninstall_test.go b/e2e/install/cli/uninstall_test.go similarity index 100% rename from e2e/withnewnamespace/install/cli/uninstall_test.go rename to e2e/install/cli/uninstall_test.go diff --git a/e2e/withnewnamespace/install/kustomize/common.go b/e2e/install/kustomize/common.go similarity index 100% rename from e2e/withnewnamespace/install/kustomize/common.go rename to e2e/install/kustomize/common.go diff --git a/e2e/withnewnamespace/install/kustomize/operator_test.go b/e2e/install/kustomize/operator_test.go similarity index 100% rename from e2e/withnewnamespace/install/kustomize/operator_test.go rename to e2e/install/kustomize/operator_test.go diff --git a/e2e/withnewnamespace/install/kustomize/setup_test.go b/e2e/install/kustomize/setup_test.go similarity index 100% rename from e2e/withnewnamespace/install/kustomize/setup_test.go rename to e2e/install/kustomize/setup_test.go diff --git a/e2e/withnewnamespace/install/kustomize/uninstall_test.go b/e2e/install/kustomize/uninstall_test.go similarity index 100% rename from e2e/withnewnamespace/install/kustomize/uninstall_test.go rename to e2e/install/kustomize/uninstall_test.go diff --git a/e2e/upgrade/files/yaml.yaml b/e2e/install/olm/files/yaml.yaml similarity index 100% copy from e2e/upgrade/files/yaml.yaml copy to e2e/install/olm/files/yaml.yaml diff --git a/e2e/upgrade/olm_install_test.go b/e2e/install/olm/olm_install_test.go similarity index 92% rename from e2e/upgrade/olm_install_test.go rename to e2e/install/olm/olm_install_test.go index 228d3b053..a082e7afc 100644 --- a/e2e/upgrade/olm_install_test.go +++ b/e2e/install/olm/olm_install_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package upgrade +package olm import ( "fmt" @@ -54,7 +54,7 @@ func TestOLMInstallation(t *testing.T) { } WithNewTestNamespace(t, func(ns string) { - Expect(createOrUpdateCatalogSource(ns, installCatalogSourceName, newIIB)).To(Succeed()) + Expect(CreateOrUpdateCatalogSource(ns, installCatalogSourceName, newIIB)).To(Succeed()) ocp, err := openshift.IsOpenShift(TestClient()) assert.Nil(t, err) @@ -66,8 +66,8 @@ func TestOLMInstallation(t *testing.T) { Eventually(SecretByName(ns, secretPrefix), TestTimeoutLong).Should(Not(BeNil())) } - Eventually(catalogSourcePodRunning(ns, installCatalogSourceName), TestTimeoutMedium).Should(BeNil()) - Eventually(catalogSourcePhase(ns, installCatalogSourceName), TestTimeoutLong).Should(Equal("READY")) + Eventually(CatalogSourcePodRunning(ns, installCatalogSourceName), TestTimeoutMedium).Should(BeNil()) + Eventually(CatalogSourcePhase(ns, installCatalogSourceName), TestTimeoutLong).Should(Equal("READY")) args := []string{"install", "-n", ns, "--olm=true", "--olm-source", installCatalogSourceName, "--olm-source-namespace", ns} @@ -81,12 +81,12 @@ func TestOLMInstallation(t *testing.T) { noAdditionalConditions := func(csv olm.ClusterServiceVersion) bool { return true } - Eventually(clusterServiceVersionPhase(noAdditionalConditions, ns), TestTimeoutMedium).Should(Equal(olm.CSVPhaseSucceeded)) + Eventually(ClusterServiceVersionPhase(noAdditionalConditions, ns), TestTimeoutMedium).Should(Equal(olm.CSVPhaseSucceeded)) // Refresh the test client to account for the newly installed CRDs SyncClient() - csvVersion := clusterServiceVersion(noAdditionalConditions, ns)().Spec.Version + csvVersion := ClusterServiceVersion(noAdditionalConditions, ns)().Spec.Version ipVersionPrefix := fmt.Sprintf("%d.%d", csvVersion.Version.Major, csvVersion.Version.Minor) t.Logf("CSV Version installed: %s", csvVersion.Version.String()) diff --git a/e2e/upgrade/cli_upgrade_test.go b/e2e/install/upgrade/cli_upgrade_test.go similarity index 100% rename from e2e/upgrade/cli_upgrade_test.go rename to e2e/install/upgrade/cli_upgrade_test.go diff --git a/e2e/upgrade/files/yaml.yaml b/e2e/install/upgrade/files/yaml.yaml similarity index 100% rename from e2e/upgrade/files/yaml.yaml rename to e2e/install/upgrade/files/yaml.yaml diff --git a/e2e/upgrade/olm_upgrade_test.go b/e2e/install/upgrade/olm_upgrade_test.go similarity index 92% rename from e2e/upgrade/olm_upgrade_test.go rename to e2e/install/upgrade/olm_upgrade_test.go index 57eea0090..c278b655b 100644 --- a/e2e/upgrade/olm_upgrade_test.go +++ b/e2e/install/upgrade/olm_upgrade_test.go @@ -67,7 +67,7 @@ func TestOLMAutomaticUpgrade(t *testing.T) { } WithNewTestNamespace(t, func(ns string) { - Expect(createOrUpdateCatalogSource(ns, catalogSourceName, prevIIB)).To(Succeed()) + Expect(CreateOrUpdateCatalogSource(ns, catalogSourceName, prevIIB)).To(Succeed()) ocp, err := openshift.IsOpenShift(TestClient()) assert.Nil(t, err) @@ -78,8 +78,8 @@ func TestOLMAutomaticUpgrade(t *testing.T) { Eventually(SecretByName(ns, secretPrefix), TestTimeoutLong).Should(Not(BeNil())) } - Eventually(catalogSourcePodRunning(ns, catalogSourceName), TestTimeoutMedium).Should(BeNil()) - Eventually(catalogSourcePhase(ns, catalogSourceName), TestTimeoutMedium).Should(Equal("READY")) + Eventually(CatalogSourcePodRunning(ns, catalogSourceName), TestTimeoutMedium).Should(BeNil()) + Eventually(CatalogSourcePhase(ns, catalogSourceName), TestTimeoutMedium).Should(Equal("READY")) // Set KAMEL_BIN only for this test - don't override the ENV variable for all tests Expect(os.Setenv("KAMEL_BIN", kamel)).To(Succeed()) @@ -103,7 +103,7 @@ func TestOLMAutomaticUpgrade(t *testing.T) { noAdditionalConditions := func(csv olm.ClusterServiceVersion) bool { return true } - Eventually(clusterServiceVersionPhase(noAdditionalConditions, ns), TestTimeoutMedium). + Eventually(ClusterServiceVersionPhase(noAdditionalConditions, ns), TestTimeoutMedium). Should(Equal(olm.CSVPhaseSucceeded)) // Refresh the test client to account for the newly installed CRDs @@ -117,7 +117,7 @@ func TestOLMAutomaticUpgrade(t *testing.T) { var prevIPVersionPrefix string var newIPVersionPrefix string - prevCSVVersion = clusterServiceVersion(noAdditionalConditions, ns)().Spec.Version + prevCSVVersion = ClusterServiceVersion(noAdditionalConditions, ns)().Spec.Version prevIPVersionPrefix = fmt.Sprintf("%d.%d", prevCSVVersion.Version.Major, prevCSVVersion.Version.Minor) t.Logf("Using Previous CSV Version: %s", prevCSVVersion.Version.String()) @@ -139,11 +139,11 @@ func TestOLMAutomaticUpgrade(t *testing.T) { t.Run("OLM upgrade", func(t *testing.T) { // Trigger Camel K operator upgrade by updating the CatalogSource with the new index image - Expect(createOrUpdateCatalogSource(ns, catalogSourceName, newIIB)).To(Succeed()) + Expect(CreateOrUpdateCatalogSource(ns, catalogSourceName, newIIB)).To(Succeed()) if crossChannelUpgrade { t.Log("Patching Camel K OLM subscription channel.") - subscription, err := getSubscription(ns) + subscription, err := GetSubscription(ns) Expect(err).To(BeNil()) Expect(subscription).NotTo(BeNil()) @@ -157,21 +157,21 @@ func TestOLMAutomaticUpgrade(t *testing.T) { } // Check the previous CSV is being replaced - Eventually(clusterServiceVersionPhase(func(csv olm.ClusterServiceVersion) bool { + Eventually(ClusterServiceVersionPhase(func(csv olm.ClusterServiceVersion) bool { return csv.Spec.Version.Version.String() == prevCSVVersion.Version.String() }, ns), TestTimeoutMedium).Should(Equal(olm.CSVPhaseReplacing)) // The new CSV is installed - Eventually(clusterServiceVersionPhase(func(csv olm.ClusterServiceVersion) bool { + Eventually(ClusterServiceVersionPhase(func(csv olm.ClusterServiceVersion) bool { return csv.Spec.Version.Version.String() != prevCSVVersion.Version.String() }, ns), TestTimeoutMedium).Should(Equal(olm.CSVPhaseSucceeded)) // The old CSV is gone - Eventually(clusterServiceVersion(func(csv olm.ClusterServiceVersion) bool { + Eventually(ClusterServiceVersion(func(csv olm.ClusterServiceVersion) bool { return csv.Spec.Version.Version.String() == prevCSVVersion.Version.String() }, ns), TestTimeoutMedium).Should(BeNil()) - newCSVVersion = clusterServiceVersion(noAdditionalConditions, ns)().Spec.Version + newCSVVersion = ClusterServiceVersion(noAdditionalConditions, ns)().Spec.Version newIPVersionPrefix = fmt.Sprintf("%d.%d", newCSVVersion.Version.Major, newCSVVersion.Version.Minor) Expect(prevCSVVersion.Version.String()).NotTo(Equal(newCSVVersion.Version.String())) diff --git a/e2e/upgrade/util.go b/e2e/support/csv.go similarity index 84% rename from e2e/upgrade/util.go rename to e2e/support/csv.go index 8d4396a82..9be3ca5e9 100644 --- a/e2e/upgrade/util.go +++ b/e2e/support/csv.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package upgrade +package support import ( "fmt" @@ -37,11 +37,10 @@ import ( olm "github.com/operator-framework/api/pkg/operators/v1alpha1" - . "github.com/apache/camel-k/e2e/support" "github.com/apache/camel-k/pkg/util/log" ) -func clusterServiceVersion(conditions func(olm.ClusterServiceVersion) bool, ns string) func() *olm.ClusterServiceVersion { +func ClusterServiceVersion(conditions func(olm.ClusterServiceVersion) bool, ns string) func() *olm.ClusterServiceVersion { return func() *olm.ClusterServiceVersion { lst := olm.ClusterServiceVersionList{} if err := TestClient().List(TestContext, &lst, ctrl.InNamespace(ns)); err != nil { @@ -56,16 +55,16 @@ func clusterServiceVersion(conditions func(olm.ClusterServiceVersion) bool, ns s } } -func clusterServiceVersionPhase(conditions func(olm.ClusterServiceVersion) bool, ns string) func() olm.ClusterServiceVersionPhase { +func ClusterServiceVersionPhase(conditions func(olm.ClusterServiceVersion) bool, ns string) func() olm.ClusterServiceVersionPhase { return func() olm.ClusterServiceVersionPhase { - if csv := clusterServiceVersion(conditions, ns)(); csv != nil && unsafe.Sizeof(csv.Status) > 0 { + if csv := ClusterServiceVersion(conditions, ns)(); csv != nil && unsafe.Sizeof(csv.Status) > 0 { return csv.Status.Phase } return "" } } -func createOrUpdateCatalogSource(ns, name, image string) error { +func CreateOrUpdateCatalogSource(ns, name, image string) error { catalogSource := &olm.CatalogSource{ ObjectMeta: metav1.ObjectMeta{ Namespace: ns, @@ -86,7 +85,7 @@ func createOrUpdateCatalogSource(ns, name, image string) error { return err } -func catalogSource(ns, name string) func() *olm.CatalogSource { +func CatalogSource(ns, name string) func() *olm.CatalogSource { return func() *olm.CatalogSource { cs := &olm.CatalogSource{ TypeMeta: metav1.TypeMeta{ @@ -108,16 +107,16 @@ func catalogSource(ns, name string) func() *olm.CatalogSource { } } -func catalogSourcePhase(ns, name string) func() string { +func CatalogSourcePhase(ns, name string) func() string { return func() string { - if source := catalogSource(ns, name)(); source != nil && source.Status.GRPCConnectionState != nil { - return catalogSource(ns, name)().Status.GRPCConnectionState.LastObservedState + if source := CatalogSource(ns, name)(); source != nil && source.Status.GRPCConnectionState != nil { + return CatalogSource(ns, name)().Status.GRPCConnectionState.LastObservedState } return "" } } -func catalogSourcePod(ns, csName string) func() *corev1.Pod { +func CatalogSourcePod(ns, csName string) func() *corev1.Pod { return func() *corev1.Pod { podList, err := TestClient().CoreV1().Pods(ns).List(TestContext, metav1.ListOptions{}) if err != nil && errors.IsNotFound(err) { @@ -140,8 +139,8 @@ func catalogSourcePod(ns, csName string) func() *corev1.Pod { } } -func catalogSourcePodRunning(ns, csName string) error { - podFunc := catalogSourcePod(ns, csName) +func CatalogSourcePodRunning(ns, csName string) error { + podFunc := CatalogSourcePod(ns, csName) for i := 1; i < 5; i++ { csPod := podFunc() @@ -163,7 +162,7 @@ func catalogSourcePodRunning(ns, csName string) error { return fmt.Errorf("Catalog Source Pod failed to reach a 'running' state") } -func getSubscription(ns string) (*olm.Subscription, error) { +func GetSubscription(ns string) (*olm.Subscription, error) { lst := olm.SubscriptionList{} if err := TestClient().List(TestContext, &lst, ctrl.InNamespace(ns)); err != nil { return nil, err diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go index 7812d8e36..365d918fe 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -90,6 +90,7 @@ import ( ) const kubeConfigEnvVar = "KUBECONFIG" +const ciPID = "/tmp/ci-k8s-pid" var TestTimeoutShort = 1 * time.Minute var TestTimeoutMedium = 5 * time.Minute @@ -2362,6 +2363,7 @@ func testNamespaceExists(ns string) (bool, error) { return true, nil } + func DeleteNamespace(t *testing.T, ns string) error { nsObj, err := TestClient().CoreV1().Namespaces().Get(TestContext, ns, metav1.GetOptions{}) if err != nil { @@ -2502,3 +2504,25 @@ func CreateLogKamelet(ns string, name string) func() error { return CreateKamelet(ns, name, flow, props, nil) } + +func GetCIProcessID() string { + id, err := os.ReadFile(ciPID) + if err != nil { + return "" + } + return string(id) +} + +func SaveCIProcessID(id string) { + err := os.WriteFile(ciPID, []byte(id), 0644) + if err != nil { + panic(err) + } +} + +func DeleteCIProcessID() { + err := os.Remove(ciPID) + if err != nil { + panic(err) + } +} diff --git a/script/Makefile b/script/Makefile index 4f330754d..496846ad7 100644 --- a/script/Makefile +++ b/script/Makefile @@ -250,8 +250,8 @@ test-fmt: do-build cd pkg/kamelet/repository && go test -v ./... -json 2>&1 | gotestfmt # -# Note -# This should execute all tests and not exit if one of the suites fail +# Common tests that do not require any customized operator setting. They can leverage a unique namespaced operator installation to reduce +# the time to complete (they are used also as smoke test for nightly release) # test-common: do-build FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ @@ -264,36 +264,68 @@ test-common: do-build go test -timeout 30m -v ./e2e/common/teardown_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \ exit $${FAILED} +# +# Common tests that require some particular operator setting or need to be installed in multiple namespaces +# +test-common-with-custom-install: do-build + FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ + go test -timeout 60m -v ./e2e/commonwithcustominstall -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \ + exit $${FAILED} + +# +# Installation procedure test using different methodologies +# +test-install: do-build + STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ + FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ + go test -timeout 60m -v ./e2e/install/cli -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \ + go test -timeout 60m -v ./e2e/install/olm -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \ + go test -timeout 60m -v ./e2e/install/kustomize -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \ + exit $${FAILED} + +# +# Upgrade procedure test (require a previous version of Kamel CLI) +# +test-install-upgrade: do-build + STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ + FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ + go test -timeout 60m -v ./e2e/install/upgrade -tags=integration $(TEST_UPGRADE_RUN) $(GOTESTFMT) || FAILED=1; \ + exit $${FAILED} + +# +# Knative tests that require the presence of KNative configuration +# test-knative: do-build - #STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ - go test -timeout 60m -v ./e2e/knative -tags=integration $(TEST_KNATIVE_RUN) -json 2>&1 | gotestfmt + STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ + go test -timeout 60m -v ./e2e/knative -tags=integration $(TEST_KNATIVE_RUN) $(GOTESTFMT) +# +# Builder tests that require a custom build strategy +# test-builder: do-build - #STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ - go test -timeout 30m -v ./e2e/builder -tags=integration $(TEST_BUILDER_RUN) -json 2>&1 | gotestfmt + STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ + go test -timeout 30m -v ./e2e/builder -tags=integration $(TEST_BUILDER_RUN) $(GOTESTFMT) +# +# Telemetry tests that require the configuration of telemtry endpoints +# test-telemetry: do-build - #STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ - go test -timeout 30m -v ./e2e/telemetry -tags=integration $(TEST_TELEMETRY_RUN) -json 2>&1 | gotestfmt - -test-with-new-namespace: do-build - #FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ - go test -timeout 60m -v ./e2e/withnewnamespace/install/cli -tags=integration $(TEST_INSTALL_RUN) -json 2>&1 | gotestfmt || FAILED=1; \ - go test -timeout 60m -v ./e2e/withnewnamespace/install/kustomize -tags=integration $(TEST_INSTALL_RUN) -json 2>&1 | gotestfmt || FAILED=1; \ - go test -timeout 60m -v ./e2e/withnewnamespace/misc -tags=integration $(TEST_INSTALL_RUN) -json 2>&1 | gotestfmt || FAILED=1; \ - exit $${FAILED} + STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ + go test -timeout 30m -v ./e2e/telemetry -tags=integration $(TEST_TELEMETRY_RUN) $(GOTESTFMT) +# +# Quarkus native test which require a lower memory resources +# test-quarkus-native: do-build - #STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ - go test -timeout 180m -v ./e2e/namespace/native -tags=integration $(TEST_QUARKUS_RUN) -json 2>&1 | gotestfmt + STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ + go test -timeout 180m -v ./e2e/native -tags=integration $(TEST_QUARKUS_RUN) $(GOTESTFMT) +# +# Quarkus native test which require a higher memory resources +# test-quarkus-native-high-memory: do-build - #STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ - go test -timeout 180m -v ./e2e/namespace/native -tags=integration,high_memory $(TEST_QUARKUS_RUN) -json 2>&1 | gotestfmt - -test-upgrade: do-build - #STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ - go test -timeout 60m -v ./e2e/namespace/upgrade -tags=integration $(TEST_UPGRADE_RUN) -json 2>&1 | gotestfmt + STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ + go test -timeout 180m -v ./e2e/namespace/native -tags=integration,high_memory $(TEST_QUARKUS_RUN) $(GOTESTFMT) build-kamel: @echo "####### Building kamel CLI..."
