From 53c2b7790626950620ffa38070059913af62b0c2 Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Mon, 5 Feb 2024 22:38:26 +0100 Subject: [PATCH] chore(e2e-tests): Improve E2E tests - Rename E2E tests commonwithcustominstall to advanced - Install global Camel K operator when running tests on Kind cluster (operator namespace = default) - E2E tests are still able to install custom Camel K operators with different operator ID - Gain test execution speed by copying the CamelCatalog from default namespace instead of recreating it every time a new operator is installed into a temp test namespace --- .github/actions/e2e-builder/exec-tests.sh | 4 +- .github/actions/e2e-common/exec-tests.sh | 6 +- .github/actions/e2e-knative/exec-tests.sh | 4 +- .github/actions/e2e-telemetry/exec-tests.sh | 4 +- .../kamel-config-cluster-custom/action.yml | 2 +- .../kamel-config-cluster-kind/action.yml | 3 + .../extract-config.sh | 2 + .../actions/kamel-config-cluster/action.yaml | 1 + .github/workflows/common.yml | 4 +- docs/modules/ROOT/pages/contributing/e2e.adoc | 8 +- e2e/README.md | 4 +- .../build_order_strategy_test.go | 4 +- .../builder_test.go | 3 +- .../catalog_builder_test.go | 3 +- .../debug_test.go | 3 +- .../deployment_test.go | 9 ++- .../dump_test.go | 3 +- .../environment_test.go | 3 +- .../files/Java.java | 0 .../files/TimerCustomKameletIntegration.java | 0 .../files/deploy.yaml | 0 .../files/promote-route-edited.groovy | 0 .../files/promote-route.groovy | 0 .../files/timer-kamelet-usage.groovy | 0 .../files/timer-source.groovy | 0 .../files/yaml.yaml | 0 .../incremental_build_test.go | 6 +- .../kamelet_repo_test.go | 3 +- .../local_platform_test.go | 3 +- .../maven_http_proxy_test.go | 3 +- .../operator_id_filtering_test.go | 26 ++---- .../operator_metrics_test.go | 3 +- .../platform_traits_test.go | 3 +- .../promote_test.go | 4 +- .../reset_test.go | 3 +- .../secondary_platform_test.go | 3 +- .../synthetic_test.go | 4 +- .../tekton_test.go | 2 +- e2e/common/cli/dev_mode_test.go | 21 +---- e2e/common/misc/platformless_run_test.go | 64 --------------- e2e/install/cli/global_kamelet_test.go | 14 ---- e2e/install/cli/global_test.go | 14 ---- e2e/support/test_support.go | 81 +++++++------------ e2e/support/util/dump.go | 15 +--- script/Makefile | 4 +- 45 files changed, 109 insertions(+), 237 deletions(-) rename e2e/{commonwithcustominstall => advanced}/build_order_strategy_test.go (98%) rename e2e/{commonwithcustominstall => advanced}/builder_test.go (97%) rename e2e/{commonwithcustominstall => advanced}/catalog_builder_test.go (98%) rename e2e/{commonwithcustominstall => advanced}/debug_test.go (98%) rename e2e/{commonwithcustominstall => advanced}/deployment_test.go (88%) rename e2e/{commonwithcustominstall => advanced}/dump_test.go (96%) rename e2e/{commonwithcustominstall => advanced}/environment_test.go (98%) rename e2e/{commonwithcustominstall => advanced}/files/Java.java (100%) rename e2e/{commonwithcustominstall => advanced}/files/TimerCustomKameletIntegration.java (100%) rename e2e/{commonwithcustominstall => advanced}/files/deploy.yaml (100%) rename e2e/{commonwithcustominstall => advanced}/files/promote-route-edited.groovy (100%) rename e2e/{commonwithcustominstall => advanced}/files/promote-route.groovy (100%) rename e2e/{commonwithcustominstall => advanced}/files/timer-kamelet-usage.groovy (100%) rename e2e/{commonwithcustominstall => advanced}/files/timer-source.groovy (100%) rename e2e/{commonwithcustominstall => advanced}/files/yaml.yaml (100%) rename e2e/{commonwithcustominstall => advanced}/incremental_build_test.go (98%) rename e2e/{commonwithcustominstall => advanced}/kamelet_repo_test.go (97%) rename e2e/{commonwithcustominstall => advanced}/local_platform_test.go (98%) rename e2e/{commonwithcustominstall => advanced}/maven_http_proxy_test.go (99%) rename e2e/{commonwithcustominstall => advanced}/operator_id_filtering_test.go (88%) rename e2e/{commonwithcustominstall => advanced}/operator_metrics_test.go (99%) rename e2e/{commonwithcustominstall => advanced}/platform_traits_test.go (97%) rename e2e/{commonwithcustominstall => advanced}/promote_test.go (98%) rename e2e/{commonwithcustominstall => advanced}/reset_test.go (97%) rename e2e/{commonwithcustominstall => advanced}/secondary_platform_test.go (97%) rename e2e/{commonwithcustominstall => advanced}/synthetic_test.go (98%) rename e2e/{commonwithcustominstall => advanced}/tekton_test.go (98%) delete mode 100644 e2e/common/misc/platformless_run_test.go diff --git a/.github/actions/e2e-builder/exec-tests.sh b/.github/actions/e2e-builder/exec-tests.sh index f429fe405c..f995ef77a0 100755 --- a/.github/actions/e2e-builder/exec-tests.sh +++ b/.github/actions/e2e-builder/exec-tests.sh @@ -126,9 +126,9 @@ export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} if [ -n "${GLOBAL_OPERATOR_NAMESPACE}" ]; then - echo "Info: Tests being run using global operator" - export CAMEL_K_FORCE_GLOBAL_TEST=true export CAMEL_K_GLOBAL_OPERATOR_NS="${GLOBAL_OPERATOR_NAMESPACE}" +else + export CAMEL_K_GLOBAL_OPERATOR_NS="default" fi # Then run integration tests diff --git a/.github/actions/e2e-common/exec-tests.sh b/.github/actions/e2e-common/exec-tests.sh index 9f02c731fd..3a412782cd 100755 --- a/.github/actions/e2e-common/exec-tests.sh +++ b/.github/actions/e2e-common/exec-tests.sh @@ -132,9 +132,9 @@ export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} if [ -n "${GLOBAL_OPERATOR_NAMESPACE}" ]; then - echo "Info: Tests being run using global operator" - export CAMEL_K_FORCE_GLOBAL_TEST=true export CAMEL_K_GLOBAL_OPERATOR_NS="${GLOBAL_OPERATOR_NAMESPACE}" +else + export CAMEL_K_GLOBAL_OPERATOR_NS="default" fi # Then run all integration tests rather than ending on first failure @@ -143,7 +143,7 @@ exit_code=0 if [ "${SMOKE_TEST_ONLY}" == "true" ]; then DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-smoke || exit_code=1 elif [ "${CUSTOM_INSTALL_TEST}" == "true" ]; then - DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-common-with-custom-install || exit_code=1 + DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-advanced || exit_code=1 else DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-common || exit_code=1 fi diff --git a/.github/actions/e2e-knative/exec-tests.sh b/.github/actions/e2e-knative/exec-tests.sh index 615b67b917..9390d5fa4c 100755 --- a/.github/actions/e2e-knative/exec-tests.sh +++ b/.github/actions/e2e-knative/exec-tests.sh @@ -129,9 +129,9 @@ export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} export KAMEL_INSTALL_OPERATOR_ENV_VARS=KAMEL_INSTALL_DEFAULT_KAMELETS=false if [ -n "${GLOBAL_OPERATOR_NAMESPACE}" ]; then - echo "Info: Tests being run using global operator" - export CAMEL_K_FORCE_GLOBAL_TEST=true export CAMEL_K_GLOBAL_OPERATOR_NS="${GLOBAL_OPERATOR_NAMESPACE}" +else + export CAMEL_K_GLOBAL_OPERATOR_NS="default" fi # Then run integration tests diff --git a/.github/actions/e2e-telemetry/exec-tests.sh b/.github/actions/e2e-telemetry/exec-tests.sh index bcfcad5f5c..d5567a04f2 100755 --- a/.github/actions/e2e-telemetry/exec-tests.sh +++ b/.github/actions/e2e-telemetry/exec-tests.sh @@ -126,9 +126,9 @@ export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} if [ -n "${GLOBAL_OPERATOR_NAMESPACE}" ]; then - echo "Info: Tests being run using global operator" - export CAMEL_K_FORCE_GLOBAL_TEST=true export CAMEL_K_GLOBAL_OPERATOR_NS="${GLOBAL_OPERATOR_NAMESPACE}" +else + export CAMEL_K_GLOBAL_OPERATOR_NS="default" fi # Then run all integration telemetry test rather than ending on first failure diff --git a/.github/actions/kamel-config-cluster-custom/action.yml b/.github/actions/kamel-config-cluster-custom/action.yml index 80950b0424..43ced78e63 100644 --- a/.github/actions/kamel-config-cluster-custom/action.yml +++ b/.github/actions/kamel-config-cluster-custom/action.yml @@ -16,7 +16,7 @@ # --------------------------------------------------------------------------- name: kamel-config-cluster-custom -description: 'Provides configuration for acessing a custom kubernetes cluster' +description: 'Provides configuration for accessing a custom kubernetes cluster' inputs: cluster-config-data: diff --git a/.github/actions/kamel-config-cluster-kind/action.yml b/.github/actions/kamel-config-cluster-kind/action.yml index 590ad4c99d..96648d8dee 100644 --- a/.github/actions/kamel-config-cluster-kind/action.yml +++ b/.github/actions/kamel-config-cluster-kind/action.yml @@ -70,3 +70,6 @@ outputs: cluster-has-olm: description: "Does the cluster have OLM" value: ${{ steps.extract-config.outputs.cluster-has-olm }} + cluster-global-operator-namespace: + description: "Namespace to install a global operator" + value: ${{ steps.extract-config.outputs.cluster-global-operator-namespace}} diff --git a/.github/actions/kamel-config-cluster-kind/extract-config.sh b/.github/actions/kamel-config-cluster-kind/extract-config.sh index 73be1f9da7..5b7e8dd782 100755 --- a/.github/actions/kamel-config-cluster-kind/extract-config.sh +++ b/.github/actions/kamel-config-cluster-kind/extract-config.sh @@ -30,6 +30,8 @@ echo "cluster-image-registry-push-host=${KIND_REGISTRY}" >> $GITHUB_OUTPUT echo "cluster-image-registry-pull-host=${KIND_REGISTRY}" >> $GITHUB_OUTPUT echo "cluster-image-registry-insecure=$(echo true)" >> $GITHUB_OUTPUT +echo "cluster-global-operator-namespace=$(echo default)" >> $GITHUB_OUTPUT + # # Export the context used for admin and user # Since kind has no rbac switched on then these can be the same diff --git a/.github/actions/kamel-config-cluster/action.yaml b/.github/actions/kamel-config-cluster/action.yaml index 64e5c377a8..37d3dd0b16 100644 --- a/.github/actions/kamel-config-cluster/action.yaml +++ b/.github/actions/kamel-config-cluster/action.yaml @@ -86,6 +86,7 @@ runs: # Does not require global operator name or namespace ... yet ./.github/actions/kamel-config-cluster/output-config.sh \ -a "${{ steps.execute-kind.outputs.cluster-kube-admin-user-ctx }}" \ + -g "${{ steps.execute-kind.outputs.cluster-global-operator-namespace }}" \ -n "${{ steps.execute-kind.outputs.cluster-image-namespace }}" \ -o "${{ steps.execute-kind.outputs.cluster-has-olm }}" \ -p "${{ steps.execute-kind.outputs.cluster-image-registry-push-host }}" \ diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index e4ab884269..fde4cafa0a 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -73,7 +73,7 @@ concurrency: cancel-in-progress: true jobs: - common-it-single-operator-installation: + common-it: runs-on: ubuntu-latest steps: @@ -96,7 +96,7 @@ jobs: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} - common-it-custom-operator-installation: + common-it-advanced: runs-on: ubuntu-latest steps: diff --git a/docs/modules/ROOT/pages/contributing/e2e.adoc b/docs/modules/ROOT/pages/contributing/e2e.adoc index bc538d959c..ffb0bded92 100644 --- a/docs/modules/ROOT/pages/contributing/e2e.adoc +++ b/docs/modules/ROOT/pages/contributing/e2e.adoc @@ -22,21 +22,21 @@ make test-smoke The test script will install the operators needed in a random namespace, execute all expected tests and clean themselves. Cleaning may not be performed if the execution of tests fails or the test process is interrupted. In that case you can look for any namespace similar to `test-29ed8147-c9fc-4c04-9c29-744eaf4750c6` and remove it manually. [[testing-e2e-structure]] -== End To End tests structure +== End-To-End tests structure -We have several kind of end to end tests. Most of them will only require the installation of Camel K operator, but, others need some particular configuration. This is the reason why they may not work out of the box on your cluster. The main goal of the test is to run in a CI environment, so, all requirements are scripted accordingly. If you want to run a test in your cluster, make sure to provide the configuration as expected by the test suite. +We have several kind of end-to-end tests. Most of them will only require the installation of Camel K operator, but, others need some particular configuration. This is the reason why they may not work out of the box on your cluster. The main goal of the test is to run in a CI environment, so, all requirements are scripted accordingly. If you want to run a test in your cluster, make sure to provide the configuration as expected by the test suite. This is the list of the groups we are using (please, notice that they can slightly change in the future): * builder (`make test-builder`) * common (`make test-common`) - * commonwithcustominstall (`make test-common-with-custom-install`) + * advanced (`make test-advanced`) * install (`make test-install`, `make test-install-olm` and `make test-install-upgrade`) * knative (`make test-knative`) * native (`make test-quarkus-native` and `make test-quarkus-native-high-memory`) * telemetry (`make test-telemetry`) -Each group tests a specific feature of Camel K. Typically any new test should be falling under the `common` group, unless it belongs to any other category or it requires some particular customization. As an example, `telemetry` requires the configuration of an OTLP Collector, reason why it requires its own group. If the test still is a common one but needs to perform customization on the Camel K Operator, then, it should be developed under `commonwithcustominstall`: as an example, we have there tests which requires the configuration of a Maven proxy. +Each group tests a specific feature of Camel K. Typically any new test should be falling under the `common` group, unless it belongs to any other category or it requires some particular customization. As an example, `telemetry` requires the configuration of an OTLP Collector, reason why it requires its own group. If the test still is a common one but needs to perform customization on the Camel K Operator, then, it should be developed under `advanced`: as an example, we have there tests which requires the configuration of a Maven proxy. It's important to know that a subset of `common` named `test-smoke` is used as smoke test in the nightly release process. We want to keep this group of test as fast as possible. diff --git a/e2e/README.md b/e2e/README.md index c38203b7c0..a4ddf63d31 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -8,7 +8,7 @@ NOTE: dear contributor, please, keep this organization as clean as you can, upda * builder * common -* commonwithcustominstall +* advanced * install * knative * native @@ -23,7 +23,7 @@ Contains a basic set of tests required to validate each builder strategy we offe Full set of test to validate the main project feature. This test will assume the presence of a namespaced operator (installation provided by the same test execution suite). Insert here any test that has to validate any new feature required. -### Commonwithcustominstall +### Advanced Additional set of test that cover the main common features but that requires some particular operator configuration. In this test suite you must take care of installing the operator as well. diff --git a/e2e/commonwithcustominstall/build_order_strategy_test.go b/e2e/advanced/build_order_strategy_test.go similarity index 98% rename from e2e/commonwithcustominstall/build_order_strategy_test.go rename to e2e/advanced/build_order_strategy_test.go index 6b4ec38445..4a6308f885 100644 --- a/e2e/commonwithcustominstall/build_order_strategy_test.go +++ b/e2e/advanced/build_order_strategy_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "testing" @@ -37,6 +37,7 @@ import ( func TestRunBuildOrderStrategyMatchingDependencies(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := "camel-k-build-order-deps" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns, "--build-order-strategy", string(v1.BuildOrderStrategyDependencies)).Execute()).To(Succeed()) Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) @@ -119,6 +120,7 @@ func TestRunBuildOrderStrategyMatchingDependencies(t *testing.T) { func TestRunBuildOrderStrategyFIFO(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := "camel-k-build-order-fifo" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns, "--build-order-strategy", string(v1.BuildOrderStrategyFIFO)).Execute()).To(Succeed()) Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) diff --git a/e2e/commonwithcustominstall/builder_test.go b/e2e/advanced/builder_test.go similarity index 97% rename from e2e/commonwithcustominstall/builder_test.go rename to e2e/advanced/builder_test.go index a2068e98f5..b79651cfde 100644 --- a/e2e/commonwithcustominstall/builder_test.go +++ b/e2e/advanced/builder_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "fmt" @@ -38,6 +38,7 @@ import ( func TestBuilderTimeout(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := fmt.Sprintf("camel-k-%s", ns) + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) Eventually(OperatorPod(ns)).ShouldNot(BeNil()) Eventually(Platform(ns)).ShouldNot(BeNil()) diff --git a/e2e/commonwithcustominstall/catalog_builder_test.go b/e2e/advanced/catalog_builder_test.go similarity index 98% rename from e2e/commonwithcustominstall/catalog_builder_test.go rename to e2e/advanced/catalog_builder_test.go index 29ff7312a9..2917b10304 100644 --- a/e2e/commonwithcustominstall/catalog_builder_test.go +++ b/e2e/advanced/catalog_builder_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "fmt" @@ -39,6 +39,7 @@ func TestCamelCatalogBuilder(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := fmt.Sprintf("camel-k-%s", ns) + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) Eventually(OperatorPod(ns)).ShouldNot(BeNil()) Eventually(Platform(ns)).ShouldNot(BeNil()) diff --git a/e2e/commonwithcustominstall/debug_test.go b/e2e/advanced/debug_test.go similarity index 98% rename from e2e/commonwithcustominstall/debug_test.go rename to e2e/advanced/debug_test.go index ae1a8cd251..2cb03288a8 100644 --- a/e2e/commonwithcustominstall/debug_test.go +++ b/e2e/advanced/debug_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "context" @@ -39,6 +39,7 @@ func TestKamelCLIDebug(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := fmt.Sprintf("camel-k-%s", ns) + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) t.Run("debug local default port check", func(t *testing.T) { diff --git a/e2e/commonwithcustominstall/deployment_test.go b/e2e/advanced/deployment_test.go similarity index 88% rename from e2e/commonwithcustominstall/deployment_test.go rename to e2e/advanced/deployment_test.go index ddd19f9dcc..cd8acc44d3 100644 --- a/e2e/commonwithcustominstall/deployment_test.go +++ b/e2e/advanced/deployment_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "testing" @@ -35,9 +35,10 @@ import ( func TestDeploymentFailureShouldReportIntegrationCondition(t *testing.T) { WithNewTestNamespace(t, func(ns string) { - op := "camel-k-failing-deploy" + operatorID := "camel-k-failing-deploy" nsRestr := "restr" - Expect(KamelInstallWithID(op, ns, "--global", "--force").Execute()).To(Succeed()) + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) + Expect(KamelInstallWithID(operatorID, ns, "--global", "--force").Execute()).To(Succeed()) // Create restricted namespace ExpectExecSucceed(t, exec.Command( @@ -64,7 +65,7 @@ func TestDeploymentFailureShouldReportIntegrationCondition(t *testing.T) { ) // Create an Integration into a restricted namespace name := RandomizedSuffixName("java-fail") - Expect(KamelRunWithID(op, ns, "files/Java.java", "--name", name, "-n", nsRestr).Execute()).To(Succeed()) + Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name, "-n", nsRestr).Execute()).To(Succeed()) // Check the error is reported into the Integration Eventually(IntegrationPhase(nsRestr, name), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseError)) Eventually(IntegrationCondition(nsRestr, name, v1.IntegrationConditionReady)().Status). diff --git a/e2e/commonwithcustominstall/dump_test.go b/e2e/advanced/dump_test.go similarity index 96% rename from e2e/commonwithcustominstall/dump_test.go rename to e2e/advanced/dump_test.go index 06e176eec4..95e6fe6291 100644 --- a/e2e/commonwithcustominstall/dump_test.go +++ b/e2e/advanced/dump_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "fmt" @@ -46,6 +46,7 @@ func TestKamelCLIDump(t *testing.T) { t.Run("dump non-empty namespace", func(t *testing.T) { operatorID := fmt.Sprintf("camel-k-%s", ns) + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) 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)) diff --git a/e2e/commonwithcustominstall/environment_test.go b/e2e/advanced/environment_test.go similarity index 98% rename from e2e/commonwithcustominstall/environment_test.go rename to e2e/advanced/environment_test.go index 3b8f13c5d7..6ecfb717a9 100644 --- a/e2e/commonwithcustominstall/environment_test.go +++ b/e2e/advanced/environment_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "fmt" @@ -65,6 +65,7 @@ func TestEnvironmentTrait(t *testing.T) { // Install Camel K with the HTTP proxy environment variable operatorID := "camel-k-trait-environment" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns, "--operator-env-vars", fmt.Sprintf("HTTP_PROXY=%s", httpProxy), "--operator-env-vars", "NO_PROXY="+strings.Join(noProxy, ","), diff --git a/e2e/commonwithcustominstall/files/Java.java b/e2e/advanced/files/Java.java similarity index 100% rename from e2e/commonwithcustominstall/files/Java.java rename to e2e/advanced/files/Java.java diff --git a/e2e/commonwithcustominstall/files/TimerCustomKameletIntegration.java b/e2e/advanced/files/TimerCustomKameletIntegration.java similarity index 100% rename from e2e/commonwithcustominstall/files/TimerCustomKameletIntegration.java rename to e2e/advanced/files/TimerCustomKameletIntegration.java diff --git a/e2e/commonwithcustominstall/files/deploy.yaml b/e2e/advanced/files/deploy.yaml similarity index 100% rename from e2e/commonwithcustominstall/files/deploy.yaml rename to e2e/advanced/files/deploy.yaml diff --git a/e2e/commonwithcustominstall/files/promote-route-edited.groovy b/e2e/advanced/files/promote-route-edited.groovy similarity index 100% rename from e2e/commonwithcustominstall/files/promote-route-edited.groovy rename to e2e/advanced/files/promote-route-edited.groovy diff --git a/e2e/commonwithcustominstall/files/promote-route.groovy b/e2e/advanced/files/promote-route.groovy similarity index 100% rename from e2e/commonwithcustominstall/files/promote-route.groovy rename to e2e/advanced/files/promote-route.groovy diff --git a/e2e/commonwithcustominstall/files/timer-kamelet-usage.groovy b/e2e/advanced/files/timer-kamelet-usage.groovy similarity index 100% rename from e2e/commonwithcustominstall/files/timer-kamelet-usage.groovy rename to e2e/advanced/files/timer-kamelet-usage.groovy diff --git a/e2e/commonwithcustominstall/files/timer-source.groovy b/e2e/advanced/files/timer-source.groovy similarity index 100% rename from e2e/commonwithcustominstall/files/timer-source.groovy rename to e2e/advanced/files/timer-source.groovy diff --git a/e2e/commonwithcustominstall/files/yaml.yaml b/e2e/advanced/files/yaml.yaml similarity index 100% rename from e2e/commonwithcustominstall/files/yaml.yaml rename to e2e/advanced/files/yaml.yaml diff --git a/e2e/commonwithcustominstall/incremental_build_test.go b/e2e/advanced/incremental_build_test.go similarity index 98% rename from e2e/commonwithcustominstall/incremental_build_test.go rename to e2e/advanced/incremental_build_test.go index 32f74ee90a..81c23f0d47 100644 --- a/e2e/commonwithcustominstall/incremental_build_test.go +++ b/e2e/advanced/incremental_build_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "fmt" @@ -38,6 +38,7 @@ import ( func TestRunIncrementalBuildRoutine(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := "camel-k-incremental-build" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) name := RandomizedSuffixName("java") @@ -89,6 +90,7 @@ func TestRunIncrementalBuildRoutine(t *testing.T) { func TestRunIncrementalBuildPod(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := "camel-k-incremental-build" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) name := RandomizedSuffixName("java") @@ -146,6 +148,7 @@ func TestRunIncrementalBuildPod(t *testing.T) { func TestRunIncrementalBuildOff(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := "camel-k-standard-build" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) name := RandomizedSuffixName("java") @@ -194,6 +197,7 @@ func TestRunIncrementalBuildOff(t *testing.T) { func TestRunIncrementalBuildWithDifferentBaseImages(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := "camel-k-standard-build" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) name := RandomizedSuffixName("java") diff --git a/e2e/commonwithcustominstall/kamelet_repo_test.go b/e2e/advanced/kamelet_repo_test.go similarity index 97% rename from e2e/commonwithcustominstall/kamelet_repo_test.go rename to e2e/advanced/kamelet_repo_test.go index f9856f342d..04ee0be25e 100644 --- a/e2e/commonwithcustominstall/kamelet_repo_test.go +++ b/e2e/advanced/kamelet_repo_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "fmt" @@ -38,6 +38,7 @@ func TestKameletFromCustomRepository(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := fmt.Sprintf("camel-k-%s", ns) + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) diff --git a/e2e/commonwithcustominstall/local_platform_test.go b/e2e/advanced/local_platform_test.go similarity index 98% rename from e2e/commonwithcustominstall/local_platform_test.go rename to e2e/advanced/local_platform_test.go index 2f924ac20c..e896dcaaad 100644 --- a/e2e/commonwithcustominstall/local_platform_test.go +++ b/e2e/advanced/local_platform_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "testing" @@ -36,6 +36,7 @@ import ( func TestLocalPlatform(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := "camel-k-platform-local" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns, "--global", "--force").Execute()).To(Succeed()) Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) diff --git a/e2e/commonwithcustominstall/maven_http_proxy_test.go b/e2e/advanced/maven_http_proxy_test.go similarity index 99% rename from e2e/commonwithcustominstall/maven_http_proxy_test.go rename to e2e/advanced/maven_http_proxy_test.go index 9638e4939a..ef092942d6 100644 --- a/e2e/commonwithcustominstall/maven_http_proxy_test.go +++ b/e2e/advanced/maven_http_proxy_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "crypto/rand" @@ -148,6 +148,7 @@ func TestMavenProxy(t *testing.T) { // Install Camel K with the HTTP proxy operatorID := "camel-k-maven-proxy" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) olm, olmErr := olm.IsAPIAvailable(TestContext, TestClient(), ns) installed, inErr := kubernetes.IsAPIResourceInstalled(TestClient(), configv1.GroupVersion.String(), reflect.TypeOf(configv1.Proxy{}).Name()) permission, pErr := kubernetes.CheckPermission(TestContext, TestClient(), configv1.GroupName, reflect.TypeOf(configv1.Proxy{}).Name(), "", "cluster", "edit") diff --git a/e2e/commonwithcustominstall/operator_id_filtering_test.go b/e2e/advanced/operator_id_filtering_test.go similarity index 88% rename from e2e/commonwithcustominstall/operator_id_filtering_test.go rename to e2e/advanced/operator_id_filtering_test.go index 719fcb0d8f..f639a94880 100644 --- a/e2e/commonwithcustominstall/operator_id_filtering_test.go +++ b/e2e/advanced/operator_id_filtering_test.go @@ -20,27 +20,24 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "fmt" - "os" "testing" "time" . "github.com/onsi/gomega" - "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" . "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/openshift" ) func TestOperatorIDCamelCatalogReconciliation(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operator1 := "operator-1" + Expect(CopyCamelCatalog(ns, operator1)).To(Succeed()) Expect(KamelInstallWithID(operator1, ns, "--global", "--force").Execute()).To(Succeed()) Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) Eventually(DefaultCamelCatalogPhase(ns), TestTimeoutMedium).Should(Equal(v1.CamelCatalogPhaseReady)) @@ -50,20 +47,11 @@ func TestOperatorIDCamelCatalogReconciliation(t *testing.T) { func TestOperatorIDFiltering(t *testing.T) { RegisterTestingT(t) - forceGlobalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - if !forceGlobalTest { - ocp, err := openshift.IsOpenShift(TestClient()) - assert.Nil(t, err) - if ocp { - t.Skip("Prefer not to run on OpenShift to avoid giving more permissions to the user running tests") - return - } - } - WithNewTestNamespace(t, func(ns string) { WithNewTestNamespace(t, func(nsop1 string) { WithNewTestNamespace(t, func(nsop2 string) { operator1 := "operator-1" + Expect(CopyCamelCatalog(ns, operator1)).To(Succeed()) Expect(KamelInstallWithIDAndKameletCatalog(operator1, nsop1, "--global", "--force").Execute()).To(Succeed()) Eventually(PlatformPhase(nsop1), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) @@ -72,12 +60,12 @@ func TestOperatorIDFiltering(t *testing.T) { Eventually(PlatformPhase(nsop2), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) t.Run("Operators ignore non-scoped integrations", func(t *testing.T) { - Expect(KamelRun(ns, "files/yaml.yaml", "--name", "untouched", "--force").Execute()).To(Succeed()) + Expect(KamelRunWithID("operator-x", ns, "files/yaml.yaml", "--name", "untouched", "--force").Execute()).To(Succeed()) Consistently(IntegrationPhase(ns, "untouched"), 10*time.Second).Should(BeEmpty()) }) t.Run("Operators run scoped integrations", func(t *testing.T) { - Expect(KamelRun(ns, "files/yaml.yaml", "--name", "moving", "--force").Execute()).To(Succeed()) + Expect(KamelRunWithID("operator-x", ns, "files/yaml.yaml", "--name", "moving", "--force").Execute()).To(Succeed()) Expect(AssignIntegrationToOperator(ns, "moving", operator1)).To(Succeed()) Eventually(IntegrationPhase(ns, "moving"), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseRunning)) Eventually(IntegrationPodPhase(ns, "moving"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) @@ -107,7 +95,7 @@ func TestOperatorIDFiltering(t *testing.T) { // Save resources by deleting "moving" integration Expect(Kamel("delete", "moving", "-n", ns).Execute()).To(Succeed()) - Expect(KamelRun(ns, "files/yaml.yaml", "--name", "pre-built", "--force", + Expect(KamelRunWithID("operator-x", ns, "files/yaml.yaml", "--name", "pre-built", "--force", "-t", fmt.Sprintf("container.image=%s", image), "-t", "jvm.enabled=true").Execute()).To(Succeed()) Consistently(IntegrationPhase(ns, "pre-built"), 10*time.Second).Should(BeEmpty()) Expect(AssignIntegrationToOperator(ns, "pre-built", operator2)).To(Succeed()) @@ -118,7 +106,7 @@ func TestOperatorIDFiltering(t *testing.T) { }) t.Run("Operators can run scoped Pipes", func(t *testing.T) { - Expect(KamelBind(ns, "timer-source?message=Hello", "log-sink", + Expect(KamelBindWithID("operator-x", ns, "timer-source?message=Hello", "log-sink", "--name", "klb", "--force").Execute()).To(Succeed()) Consistently(Integration(ns, "klb"), 10*time.Second).Should(BeNil()) diff --git a/e2e/commonwithcustominstall/operator_metrics_test.go b/e2e/advanced/operator_metrics_test.go similarity index 99% rename from e2e/commonwithcustominstall/operator_metrics_test.go rename to e2e/advanced/operator_metrics_test.go index 8129d96c39..8dfade9b0a 100644 --- a/e2e/commonwithcustominstall/operator_metrics_test.go +++ b/e2e/advanced/operator_metrics_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "bytes" @@ -61,6 +61,7 @@ func TestMetrics(t *testing.T) { WithNewTestNamespace(t, func(ns string) { name := RandomizedSuffixName("java") operatorID := "camel-k-metrics" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns, "--log-level", "debug").Execute()).To(Succeed()) Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name, diff --git a/e2e/commonwithcustominstall/platform_traits_test.go b/e2e/advanced/platform_traits_test.go similarity index 97% rename from e2e/commonwithcustominstall/platform_traits_test.go rename to e2e/advanced/platform_traits_test.go index 839cf5a964..ca5d1a9206 100644 --- a/e2e/commonwithcustominstall/platform_traits_test.go +++ b/e2e/advanced/platform_traits_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "testing" @@ -38,6 +38,7 @@ import ( func TestTraitOnIntegrationPlatform(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := "camel-k-platform-trait-test" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) containerTestName := "testname" diff --git a/e2e/commonwithcustominstall/promote_test.go b/e2e/advanced/promote_test.go similarity index 98% rename from e2e/commonwithcustominstall/promote_test.go rename to e2e/advanced/promote_test.go index 33d36de8d9..d52db9118f 100644 --- a/e2e/commonwithcustominstall/promote_test.go +++ b/e2e/advanced/promote_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "testing" @@ -39,6 +39,7 @@ func TestKamelCLIPromote(t *testing.T) { // Dev environment namespace WithNewTestNamespace(t, func(nsDev string) { operatorDevID := "camel-k-cli-promote-dev" + Expect(CopyCamelCatalog(nsDev, operatorDevID)).To(Succeed()) Expect(KamelInstallWithID(operatorDevID, nsDev).Execute()).To(Succeed()) // Dev content configmap @@ -79,6 +80,7 @@ func TestKamelCLIPromote(t *testing.T) { // Prod environment namespace WithNewTestNamespace(t, func(nsProd string) { operatorProdID := "camel-k-cli-promote-prod" + Expect(CopyCamelCatalog(nsProd, operatorProdID)).To(Succeed()) Expect(KamelInstallWithID(operatorProdID, nsProd).Execute()).To(Succeed()) Eventually(PlatformPhase(nsProd), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) diff --git a/e2e/commonwithcustominstall/reset_test.go b/e2e/advanced/reset_test.go similarity index 97% rename from e2e/commonwithcustominstall/reset_test.go rename to e2e/advanced/reset_test.go index 5112e86265..2e4dd1d481 100644 --- a/e2e/commonwithcustominstall/reset_test.go +++ b/e2e/advanced/reset_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "testing" @@ -34,6 +34,7 @@ import ( func TestKamelReset(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := "camel-k-cli-reset" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) t.Run("Reset the whole platform", func(t *testing.T) { diff --git a/e2e/commonwithcustominstall/secondary_platform_test.go b/e2e/advanced/secondary_platform_test.go similarity index 97% rename from e2e/commonwithcustominstall/secondary_platform_test.go rename to e2e/advanced/secondary_platform_test.go index 6cabfb3053..11388b490b 100644 --- a/e2e/commonwithcustominstall/secondary_platform_test.go +++ b/e2e/advanced/secondary_platform_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "testing" @@ -37,6 +37,7 @@ import ( func TestSecondaryPlatform(t *testing.T) { WithNewTestNamespace(t, func(ns string) { operatorID := "camel-k-platform-secondary" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) diff --git a/e2e/commonwithcustominstall/synthetic_test.go b/e2e/advanced/synthetic_test.go similarity index 98% rename from e2e/commonwithcustominstall/synthetic_test.go rename to e2e/advanced/synthetic_test.go index 2979d0b398..cec7fdeb7c 100644 --- a/e2e/commonwithcustominstall/synthetic_test.go +++ b/e2e/advanced/synthetic_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "testing" @@ -39,6 +39,7 @@ func TestSyntheticIntegrationOff(t *testing.T) { WithNewTestNamespace(t, func(ns string) { // Install Camel K without synthetic Integration feature variable (default) operatorID := "camel-k-synthetic-env-off" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) // Run the external deployment @@ -59,6 +60,7 @@ func TestSyntheticIntegrationFromDeployment(t *testing.T) { WithNewTestNamespace(t, func(ns string) { // Install Camel K with the synthetic Integration feature variable operatorID := "camel-k-synthetic-env" + Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed()) Expect(KamelInstallWithID(operatorID, ns, "--operator-env-vars", "CAMEL_K_SYNTHETIC_INTEGRATIONS=true", ).Execute()).To(Succeed()) diff --git a/e2e/commonwithcustominstall/tekton_test.go b/e2e/advanced/tekton_test.go similarity index 98% rename from e2e/commonwithcustominstall/tekton_test.go rename to e2e/advanced/tekton_test.go index 59a724fbc3..f9e84e2999 100644 --- a/e2e/commonwithcustominstall/tekton_test.go +++ b/e2e/advanced/tekton_test.go @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package commonwithcustominstall +package advanced import ( "testing" diff --git a/e2e/common/cli/dev_mode_test.go b/e2e/common/cli/dev_mode_test.go index d2c3a2fbe4..f617bf7a53 100644 --- a/e2e/common/cli/dev_mode_test.go +++ b/e2e/common/cli/dev_mode_test.go @@ -69,12 +69,7 @@ func TestRunDevMode(t *testing.T) { args := os.Args defer func() { os.Args = args }() - globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - if globalTest { - os.Args = []string{"kamel", "run", "-n", ns, file, "--name", name, "--dev"} - } else { - os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--name", name, "--dev"} - } + os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--name", name, "--dev"} go kamelRun.Execute() Eventually(logScanner.IsFound(`integration "`+name+`" in phase Running`), TestTimeoutMedium).Should(BeTrue()) @@ -103,12 +98,7 @@ func TestRunDevMode(t *testing.T) { args := os.Args defer func() { os.Args = args }() - globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - if globalTest { - os.Args = []string{"kamel", "run", "-n", ns, remoteFile, "--name", name, "--dev"} - } else { - os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, remoteFile, "--name", name, "--dev"} - } + os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, remoteFile, "--name", name, "--dev"} go kamelRun.Execute() @@ -152,12 +142,7 @@ func TestRunDevMode(t *testing.T) { args := os.Args defer func() { os.Args = args }() - globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - if globalTest { - os.Args = []string{"kamel", "run", "-n", ns, file, "--name", name, "--dev"} - } else { - os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--name", name, "--dev"} - } + os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--name", name, "--dev"} go kamelRun.Execute() diff --git a/e2e/common/misc/platformless_run_test.go b/e2e/common/misc/platformless_run_test.go deleted file mode 100644 index d4b0d0bd69..0000000000 --- a/e2e/common/misc/platformless_run_test.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build integration -// +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 misc - -import ( - "os" - "testing" - - . "github.com/onsi/gomega" - "github.com/stretchr/testify/assert" - - corev1 "k8s.io/api/core/v1" - - . "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/openshift" -) - -func TestPlatformlessRun(t *testing.T) { - RegisterTestingT(t) - - needsExternalRepo := os.Getenv("STAGING_RUNTIME_REPO") != "" || os.Getenv("KAMEL_INSTALL_MAVEN_REPOSITORIES") != "" - ocp, err := openshift.IsOpenShift(TestClient()) - assert.Nil(t, err) - if needsExternalRepo || !ocp { - t.Skip("This test is for OpenShift only and cannot work when a custom platform configuration is needed") - return - } - if os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" { - t.Skip("This test can't work with the global operator installation since the integration platform can be inherited.") - return - } - - // Delete the platform from the namespace before running the integration - Eventually(DeletePlatform(ns)).Should(BeTrue()) - Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) - Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) - // Platform should be recreated - Eventually(Platform(ns)).ShouldNot(BeNil()) - Eventually(PlatformProfile(ns)).Should(Equal(v1.TraitProfile(""))) - - Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) -} diff --git a/e2e/install/cli/global_kamelet_test.go b/e2e/install/cli/global_kamelet_test.go index 092935b9e6..62fe111341 100644 --- a/e2e/install/cli/global_kamelet_test.go +++ b/e2e/install/cli/global_kamelet_test.go @@ -23,29 +23,15 @@ limitations under the License. package cli import ( - "os" "testing" . "github.com/onsi/gomega" - "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" . "github.com/apache/camel-k/v2/e2e/support" - "github.com/apache/camel-k/v2/pkg/util/openshift" ) func TestRunGlobalKamelet(t *testing.T) { - forceGlobalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - if !forceGlobalTest { - ocp, err := openshift.IsOpenShift(TestClient()) - assert.Nil(t, err) - if ocp { - t.Skip("Prefer not to run on OpenShift to avoid giving more permissions to the user running tests") - return - } - } - WithGlobalOperatorNamespace(t, func(operatorNamespace string) { operatorID := "camel-k-global-kamelet" Expect(KamelInstallWithID(operatorID, operatorNamespace, "--global", "--force").Execute()).To(Succeed()) diff --git a/e2e/install/cli/global_test.go b/e2e/install/cli/global_test.go index 4b5afe3ad8..8ec5e60e27 100644 --- a/e2e/install/cli/global_test.go +++ b/e2e/install/cli/global_test.go @@ -24,15 +24,12 @@ package cli import ( "fmt" - "os" "strings" "testing" ctrl "sigs.k8s.io/controller-runtime/pkg/client" . "github.com/onsi/gomega" - "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -40,20 +37,9 @@ import ( v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" "github.com/apache/camel-k/v2/pkg/platform" "github.com/apache/camel-k/v2/pkg/util/defaults" - "github.com/apache/camel-k/v2/pkg/util/openshift" ) func TestRunGlobalInstall(t *testing.T) { - forceGlobalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - if !forceGlobalTest { - ocp, err := openshift.IsOpenShift(TestClient()) - assert.Nil(t, err) - if ocp { - t.Skip("Prefer not to run on OpenShift to avoid giving more permissions to the user running tests") - return - } - } - RegisterTestingT(t) WithGlobalOperatorNamespace(t, func(operatorNamespace string) { diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go index c91e5d6064..c58862afe6 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -270,21 +270,7 @@ func KamelInstallWithIDAndKameletCatalog(operatorID string, namespace string, ar func kamelInstallWithContext(ctx context.Context, operatorID string, namespace string, skipKameletCatalog bool, args ...string) *cobra.Command { var installArgs []string - globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - if globalTest { - fmt.Printf("Executing as global test\n") - - if err := verifyGlobalOperator(); err != nil { - failTest(err) - } - - // Have a global operator pod watching all namespaces - // so ensure an integration platform is installed in target namespace - installArgs = []string{"install", "--skip-operator-setup", "-n", namespace} - } else { - // NOT global so proceed with local namespaced kamel install using the operator id - installArgs = []string{"install", "-n", namespace, "--operator-id", operatorID} - } + installArgs = []string{"install", "-n", namespace, "--operator-id", operatorID} if skipKameletCatalog { installArgs = append(installArgs, "--operator-env-vars", "KAMEL_INSTALL_DEFAULT_KAMELETS=false") @@ -355,20 +341,7 @@ func KamelCommandWithContext(ctx context.Context, command string, operatorID str logf.SetLogger(zap.New(zap.UseDevMode(true))) var cmdArgs []string - globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - if globalTest { - fmt.Printf("Running as globally managed resource\n") - - if err := verifyGlobalOperator(); err != nil { - failTest(err) - } - - // Have a global operator reconciling the integration - cmdArgs = []string{command, "-n", namespace} - } else { - // NOT global so proceed with local namespaced operator reconciling the integration - cmdArgs = []string{command, "-n", namespace, "--operator-id", operatorID} - } + cmdArgs = []string{command, "-n", namespace, "--operator-id", operatorID} cmdArgs = append(cmdArgs, args...) return KamelWithContext(ctx, cmdArgs...) @@ -377,7 +350,7 @@ func KamelCommandWithContext(ctx context.Context, command string, operatorID str func verifyGlobalOperator() error { opns := os.Getenv("CAMEL_K_GLOBAL_OPERATOR_NS") if opns == "" { - return errors.New("No operator namespace defined in CAMEL_K_GLOBAL_OPERATOR_NS") + return errors.New("no operator namespace defined in CAMEL_K_GLOBAL_OPERATOR_NS") } oppod := OperatorPod(opns)() @@ -1969,6 +1942,24 @@ func PlatformByName(ns string, name string) func() *v1.IntegrationPlatform { } } +func CopyCamelCatalog(ns, operatorID string) error { + catalogName := fmt.Sprintf("camel-catalog-%s", strings.ToLower(defaults.DefaultRuntimeVersion)) + defaultCatalog := CamelCatalog("default", catalogName)() + if defaultCatalog != nil { + catalog := v1.CamelCatalog{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns, + Name: catalogName, + }, + Spec: *defaultCatalog.Spec.DeepCopy(), + } + v1.SetAnnotation(&catalog.ObjectMeta, v1.OperatorIDAnnotation, operatorID) + return CreateCamelCatalog(&catalog)() + } + + return nil +} + func CamelCatalog(ns, name string) func() *v1.CamelCatalog { return func() *v1.CamelCatalog { cat := v1.CamelCatalog{} @@ -2237,15 +2228,6 @@ func ConsoleCLIDownload(name string) func() *consoleV1.ConsoleCLIDownload { } func OperatorPod(ns string) func() *corev1.Pod { - namespace := ns - - globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - opns := os.Getenv("CAMEL_K_GLOBAL_OPERATOR_NS") - if globalTest && len(opns) > 0 { - // Use the global operator pod instead of given namespace - namespace = opns - } - return func() *corev1.Pod { lst := corev1.PodList{ TypeMeta: metav1.TypeMeta{ @@ -2254,7 +2236,7 @@ func OperatorPod(ns string) func() *corev1.Pod { }, } if err := TestClient().List(TestContext, &lst, - ctrl.InNamespace(namespace), + ctrl.InNamespace(ns), ctrl.MatchingLabels{ "camel.apache.org/component": "operator", }); err != nil { @@ -2709,13 +2691,13 @@ func userCleanup(t *testing.T) { } func invokeUserTestCode(t *testing.T, ns string, doRun func(string)) { - globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - - defer func(isGlobal bool) { + defer func() { DumpNamespace(t, ns) + osns := os.Getenv("CAMEL_K_GLOBAL_OPERATOR_NS") + // Try to clean up namespace - if !isGlobal && HasPlatform(ns)() { + if ns != osns && HasPlatform(ns)() { t.Logf("Clean up test namespace: %s", ns) if err := Kamel("uninstall", "-n", ns, "--skip-crd", "--skip-cluster-roles").Execute(); err != nil { @@ -2724,7 +2706,7 @@ func invokeUserTestCode(t *testing.T, ns string, doRun func(string)) { t.Logf("Successfully cleaned up test namespace: %s", ns) } - }(globalTest) + }() gomega.RegisterTestingT(t) doRun(ns) @@ -2998,15 +2980,6 @@ func DeleteCIProcessID() { } } -func GetOperatorNamespace(testNamespace string) string { - globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - if globalTest { - return os.Getenv("CAMEL_K_GLOBAL_OPERATOR_NS") - } else { - return testNamespace - } -} - func RandomizedSuffixName(name string) string { return name + strings.ToLower(v2util.RandomString(5)) } diff --git a/e2e/support/util/dump.go b/e2e/support/util/dump.go index 1b7a0d6c25..c0a8661142 100644 --- a/e2e/support/util/dump.go +++ b/e2e/support/util/dump.go @@ -23,7 +23,6 @@ package util import ( "bufio" "context" - "errors" "fmt" "os" "strings" @@ -258,18 +257,8 @@ func Dump(ctx context.Context, c client.Client, ns string, t *testing.T) error { } // Some log from running pods - - // - // Get logs for global operator if it is being used - // - globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" - if globalTest { - opns := os.Getenv("CAMEL_K_GLOBAL_OPERATOR_NS") - if opns == "" { - err := errors.New("No operator namespace defined in CAMEL_K_GLOBAL_OPERATOR_NS") - t.Logf("ERROR cannot find global operator namespace: %v\n", err) - } - + opns := os.Getenv("CAMEL_K_GLOBAL_OPERATOR_NS") + if opns != "" { lst, err := c.CoreV1().Pods(opns).List(ctx, metav1.ListOptions{}) if err != nil { return err diff --git a/script/Makefile b/script/Makefile index e6b06e27a6..4de49d6891 100644 --- a/script/Makefile +++ b/script/Makefile @@ -283,9 +283,9 @@ test-smoke: do-build # # Common tests that require some particular operator setting or need to be installed in multiple namespaces # -test-common-with-custom-install: do-build +test-advanced: do-build FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ - go test -timeout 90m -v ./e2e/commonwithcustominstall -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \ + go test -timeout 90m -v ./e2e/advanced -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \ exit $${FAILED} #