This is an automated email from the ASF dual-hosted git repository. cdeppisch pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 53c2b7790626950620ffa38070059913af62b0c2 Author: Christoph Deppisch <cdeppi...@redhat.com> AuthorDate: Mon Feb 5 22:38:26 2024 +0100 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 +- .../actions/kamel-config-cluster-custom/action.yml | 2 +- .../actions/kamel-config-cluster-kind/action.yml | 3 + .../kamel-config-cluster-kind/extract-config.sh | 2 + .github/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(-) diff --git a/.github/actions/e2e-builder/exec-tests.sh b/.github/actions/e2e-builder/exec-tests.sh index f429fe405..f995ef77a 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 9f02c731f..3a412782c 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 615b67b91..9390d5fa4 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 bcfcad5f5..d5567a04f 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 80950b042..43ced78e6 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 590ad4c99..96648d8de 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 73be1f9da..5b7e8dd78 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 64e5c377a..37d3dd0b1 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 e4ab88426..fde4cafa0 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 bc538d959..ffb0bded9 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 hav [...] +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 w [...] 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 c38203b7c..a4ddf63d3 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 6b4ec3844..4a6308f88 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 a2068e98f..b79651cfd 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 29ff7312a..2917b1030 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 ae1a8cd25..2cb03288a 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 ddd19f9dc..cd8acc44d 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 06e176eec..95e6fe629 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 3b8f13c5d..6ecfb717a 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 32f74ee90..81c23f0d4 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 f9856f342..04ee0be25 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 2f924ac20..e896dcaaa 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 9638e4939..ef092942d 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 719fcb0d8..f639a9488 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 8129d96c3..8dfade9b0 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 839cf5a96..ca5d1a920 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 33d36de8d..d52db9118 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 5112e8626..2e4dd1d48 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 6cabfb305..11388b490 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 2979d0b39..cec7fdeb7 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 59a724fbc..f9e84e299 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 d2c3a2fbe..f617bf7a5 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 d4b0d0bd6..000000000 --- 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 092935b9e..62fe11134 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 4b5afe3ad..8ec5e60e2 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 c91e5d606..c58862afe 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 1b7a0d6c2..c0a866114 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 e6b06e27a..4de49d689 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} #