This is an automated email from the ASF dual-hosted git repository. pcongiusti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit f02f4c5f7b766ccc47196fac7fad7d85e79f5a08 Author: Pasquale Congiusti <[email protected]> AuthorDate: Wed Jun 26 18:07:07 2024 +0200 chore(e2e): install namespaced operator --- .github/actions/e2e-common/exec-tests.sh | 10 ++ .github/actions/e2e-install-olm/action.yml | 96 --------------- .github/actions/e2e-install-olm/exec-tests.sh | 131 --------------------- .github/actions/e2e-install-upgrade/action.yml | 96 --------------- .github/actions/e2e-install-upgrade/exec-tests.sh | 131 --------------------- .github/actions/e2e-install/action.yml | 46 ++++++-- .github/actions/e2e-install/exec-tests.sh | 52 ++++---- .github/actions/e2e-knative/exec-tests.sh | 2 + .github/actions/e2e-native/exec-tests.sh | 2 + .github/actions/e2e-telemetry/exec-tests.sh | 2 + .github/workflows/install.yml | 36 +----- docs/charts/camel-k-2.4.0-SNAPSHOT.tgz | Bin 289158 -> 0 bytes docs/charts/index.yaml | 27 ----- docs/modules/ROOT/pages/contributing/e2e.adoc | 52 +------- e2e/advanced/build_max_pipelines_test.go | 4 +- e2e/advanced/build_order_strategy_test.go | 4 +- e2e/advanced/builder_test.go | 9 +- e2e/advanced/catalog_builder_test.go | 2 +- e2e/advanced/debug_test.go | 2 +- e2e/advanced/dump_test.go | 2 +- e2e/advanced/environment_test.go | 2 +- e2e/advanced/incremental_build_test.go | 8 +- .../misc => advanced}/integration_profile_test.go | 31 +++-- e2e/advanced/kamelet_repo_test.go | 2 +- e2e/advanced/maven_http_proxy_test.go | 4 +- e2e/advanced/operator_id_filtering_test.go | 4 +- e2e/advanced/operator_metrics_test.go | 2 +- e2e/advanced/platform_traits_test.go | 2 +- e2e/advanced/promote_test.go | 4 +- e2e/advanced/reset_test.go | 2 +- e2e/advanced/synthetic_test.go | 4 +- e2e/advanced/tekton_test.go | 2 +- e2e/knative/knative_pipes_test.go | 10 +- e2e/support/test_support.go | 17 +-- e2e/support/test_util.go | 97 +++------------ .../kubernetes/namespaced/kustomization.yaml | 7 +- .../{kustomization.yaml => patch-operator-id.yaml} | 20 +--- script/Makefile | 114 +++++++----------- 38 files changed, 219 insertions(+), 819 deletions(-) diff --git a/.github/actions/e2e-common/exec-tests.sh b/.github/actions/e2e-common/exec-tests.sh index 61f7e0786..2d1591a4a 100755 --- a/.github/actions/e2e-common/exec-tests.sh +++ b/.github/actions/e2e-common/exec-tests.sh @@ -143,12 +143,22 @@ export CAMEL_K_E2E_FAST_SETUP="true" set -e exit_code=0 if [ "${SMOKE_TEST_ONLY}" == "true" ]; then + kubectl create ns camel-k + REGISTRY="${KAMEL_INSTALL_REGISTRY}" make install-k8s-global + # Let's wait for the IntegrationPlatform to be ready before starting any operation + kubectl wait --for=jsonpath='{.status.phase}'=Ready itp camel-k -n camel-k --timeout=45s + DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-smoke || exit_code=1 elif [ "${CUSTOM_INSTALL_TEST}" == "true" ]; then + make install-crds + DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-advanced || exit_code=1 else kubectl create ns camel-k REGISTRY="${KAMEL_INSTALL_REGISTRY}" make install-k8s-global + # Let's wait for the IntegrationPlatform to be ready before starting any operation + kubectl wait --for=jsonpath='{.status.phase}'=Ready itp camel-k -n camel-k --timeout=45s + DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-common || exit_code=1 fi set +e diff --git a/.github/actions/e2e-install-olm/action.yml b/.github/actions/e2e-install-olm/action.yml deleted file mode 100644 index 40b0b199c..000000000 --- a/.github/actions/e2e-install-olm/action.yml +++ /dev/null @@ -1,96 +0,0 @@ -# --------------------------------------------------------------------------- -# 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. -# --------------------------------------------------------------------------- - -name: e2e-install-olm -description: 'End-to-End tests for OLM installation and upgrade procedure' - -inputs: - cluster-config-data: - description: 'The configuration of the underlying cluster (if cluster-type is custom)' - required: false - cluster-kube-config-data: - description: 'Base16 encoded kube config - required for custom cluster type only' - required: false - -runs: - using: "composite" - - steps: - - id: prepare-env - name: Prepare Test Environment - uses: ./.github/actions/kamel-prepare-env - - - id: config-cluster - name: Configure Cluster - uses: ./.github/actions/kamel-config-cluster - with: - cluster-config-data: ${{ inputs.cluster-config-data }} - cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }} - require-olm: true - - - id: released-kamel-cli - name: Get Released Kamel CLI - shell: bash - run: | - export KAMEL_VERSION=$(make get-last-released-version) - curl -L https://github.com/apache/camel-k/releases/download/v${KAMEL_VERSION}/camel-k-client-${KAMEL_VERSION}-linux-amd64.tar.gz -o /tmp/kamel.tar.gz - pushd /tmp && tar -zxf kamel.tar.gz && popd > /dev/null - if [ ! -x /tmp/kamel ]; then - echo "Error: No ${KAMEL_VERSION} downloaded correctly" - exit 1 - fi - - # - # Note: cannot use GITHUB_ENV vars in same script as it was defined - # - export RELEASED_KAMEL_BINARY=/tmp/kamel-${KAMEL_VERSION} - mv /tmp/kamel ${RELEASED_KAMEL_BINARY} - if [ $? == 0 ]; then - echo "Info: Kamel version installed: $(${RELEASED_KAMEL_BINARY} version)" - echo "released-kamel-binary=${RELEASED_KAMEL_BINARY}" >> $GITHUB_OUTPUT - else - echo "Error: Failed to install kamel binary ${KAMEL_VERSION}" - exit 1 - fi - - - id: build-kamel - name: Build Kamel - uses: ./.github/actions/kamel-build - with: - image-registry-push-host: ${{ steps.config-cluster.outputs.cluster-image-registry-push-host }} - image-registry-pull-host: ${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} - image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} - # Builds the bundle if an OLM is available. - # Since configure-cluster requires OLM then this should be true - build-bundle: ${{ steps.config-cluster.outputs.cluster-has-olm }} - # Both can be empty and so catalog source will not be created - catalog-source-name: ${{ steps.config-cluster.outputs.cluster-catalog-source-name }} - catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }} - - - name: Run IT - shell: bash - run: | - # Note different parameters due to alternative installation - ./.github/actions/e2e-install-olm/exec-tests.sh \ - -b "${{ steps.released-kamel-cli.outputs.released-kamel-binary }}" \ - -d "${{ steps.build-kamel.outputs.build-bundle-image-bundle-index }}" \ - -l "${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }}" \ - -n "${{ steps.build-kamel.outputs.build-binary-local-image-name }}" \ - -q "${{ env.CAMEL_K_LOG_LEVEL }}" \ - -s "${{ steps.config-cluster.outputs.cluster-image-registry-insecure }}" \ - -v "${{ steps.build-kamel.outputs.build-binary-local-image-version }}" \ - -x "${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }}" diff --git a/.github/actions/e2e-install-olm/exec-tests.sh b/.github/actions/e2e-install-olm/exec-tests.sh deleted file mode 100755 index 505afae32..000000000 --- a/.github/actions/e2e-install-olm/exec-tests.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash - -# --------------------------------------------------------------------------- -# 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. -# --------------------------------------------------------------------------- - -#### -# -# Execute the upgrade tests -# -#### - -set -e - -while getopts ":b:d:l:n:q:s:v:x:" opt; do - case "${opt}" in - b) - KAMEL_BINARY=${OPTARG} - ;; - d) - BUNDLE_INDEX_IMAGE=${OPTARG} - ;; - l) - REGISTRY_PULL_HOST=${OPTARG} - ;; - n) - IMAGE_NAME=${OPTARG} - ;; - q) - LOG_LEVEL=${OPTARG} - ;; - s) - REGISTRY_INSECURE=${OPTARG} - ;; - v) - IMAGE_VERSION=${OPTARG} - ;; - x) - SAVE_FAILED_TEST_NS=${OPTARG} - ;; - :) - echo "ERROR: Option -$OPTARG requires an argument" - exit 1 - ;; - \?) - echo "ERROR: Invalid option -$OPTARG" - exit 1 - ;; - esac -done -shift $((OPTIND-1)) - -if [ -z "${IMAGE_NAME}" ]; then - echo "Error: local-image-name not defined" - exit 1 -fi - -if [ -z "${IMAGE_VERSION}" ]; then - echo "Error: local-image-version not defined" - exit 1 -fi - -if [ -z "${KAMEL_BINARY}" ]; then - echo "Error: kamel-binary not defined" - exit 1 -fi - -if [ -z "${BUNDLE_INDEX_IMAGE}" ]; then - echo "Error: bundle-index-image not defined" - exit 1 -fi - -if [ -z "${REGISTRY_PULL_HOST}" ]; then - echo "Error: image-registry-pull-host not defined" - exit 1 -fi - -if [ -z "${REGISTRY_INSECURE}" ]; then - echo "Error: image-registry-insecure not defined" - exit 1 -fi - -# Use the last released Kamel CLI -export RELEASED_KAMEL_BIN=${KAMEL_BINARY} - -echo "Kamel version: $(${RELEASED_KAMEL_BIN} version)" - -# Cluster environment -export CUSTOM_IMAGE=${IMAGE_NAME} -export CUSTOM_VERSION=${IMAGE_VERSION} - -# Configure install options -export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) -export KAMEL_INSTALL_REGISTRY=${REGISTRY_PULL_HOST} -export KAMEL_INSTALL_REGISTRY_INSECURE=${REGISTRY_INSECURE} - -# Will only have an effect if olm=false -# since, for OLM, the csv determines the policy -# (see kamel-build-bundle/build-bundle-image.sh) -export KAMEL_INSTALL_OPERATOR_IMAGE_PULL_POLICY="Always" - -# Despite building a bundle we don't want it installed immediately so no OLM_INDEX_BUNDLE var - -# Configure test options -export CAMEL_K_TEST_LOG_LEVEL="${LOG_LEVEL}" -if [ "${LOG_LEVEL}" == "debug" ]; then - export CAMEL_K_TEST_MAVEN_CLI_OPTIONS="-X ${CAMEL_K_TEST_MAVEN_CLI_OPTIONS}" -fi -export CAMEL_K_PREV_IIB=quay.io/operatorhubio/catalog:latest -export CAMEL_K_NEW_IIB=${BUNDLE_INDEX_IMAGE} -export CAMEL_K_PREV_UPGRADE_CHANNEL=${PREV_XY_CHANNEL} -export CAMEL_K_NEW_UPGRADE_CHANNEL=${NEW_XY_CHANNEL} -export KAMEL_K_TEST_RELEASE_VERSION=$(make get-last-released-version) -export KAMEL_K_TEST_OPERATOR_CURRENT_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} -export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} - -# Then run integration tests -DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-install-olm diff --git a/.github/actions/e2e-install-upgrade/action.yml b/.github/actions/e2e-install-upgrade/action.yml deleted file mode 100644 index 760986d20..000000000 --- a/.github/actions/e2e-install-upgrade/action.yml +++ /dev/null @@ -1,96 +0,0 @@ -# --------------------------------------------------------------------------- -# 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. -# --------------------------------------------------------------------------- - -name: e2e-install-olm -description: 'End-to-End tests for OLM installation and upgrade procedure' - -inputs: - cluster-config-data: - description: 'The configuration of the underlying cluster (if cluster-type is custom)' - required: false - cluster-kube-config-data: - description: 'Base16 encoded kube config - required for custom cluster type only' - required: false - -runs: - using: "composite" - - steps: - - id: prepare-env - name: Prepare Test Environment - uses: ./.github/actions/kamel-prepare-env - - - id: config-cluster - name: Configure Cluster - uses: ./.github/actions/kamel-config-cluster - with: - cluster-config-data: ${{ inputs.cluster-config-data }} - cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }} - require-olm: true - - - id: released-kamel-cli - name: Get Released Kamel CLI - shell: bash - run: | - export KAMEL_VERSION=$(make get-last-released-version) - curl -L https://github.com/apache/camel-k/releases/download/v${KAMEL_VERSION}/camel-k-client-${KAMEL_VERSION}-linux-amd64.tar.gz -o /tmp/kamel.tar.gz - pushd /tmp && tar -zxf kamel.tar.gz && popd > /dev/null - if [ ! -x /tmp/kamel ]; then - echo "Error: No ${KAMEL_VERSION} downloaded correctly" - exit 1 - fi - - # - # Note: cannot use GITHUB_ENV vars in same script as it was defined - # - export RELEASED_KAMEL_BINARY=/tmp/kamel-${KAMEL_VERSION} - mv /tmp/kamel ${RELEASED_KAMEL_BINARY} - if [ $? == 0 ]; then - echo "Info: Kamel version installed: $(${RELEASED_KAMEL_BINARY} version)" - echo "released-kamel-binary=${RELEASED_KAMEL_BINARY}" >> $GITHUB_OUTPUT - else - echo "Error: Failed to install kamel binary ${KAMEL_VERSION}" - exit 1 - fi - - - id: build-kamel - name: Build Kamel - uses: ./.github/actions/kamel-build - with: - image-registry-push-host: ${{ steps.config-cluster.outputs.cluster-image-registry-push-host }} - image-registry-pull-host: ${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} - image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} - # Builds the bundle if an OLM is available. - # Since configure-cluster requires OLM then this should be true - build-bundle: ${{ steps.config-cluster.outputs.cluster-has-olm }} - # Both can be empty and so catalog source will not be created - catalog-source-name: ${{ steps.config-cluster.outputs.cluster-catalog-source-name }} - catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }} - - - name: Run IT - shell: bash - run: | - # Note different parameters due to alternative installation - ./.github/actions/e2e-install-upgrade/exec-tests.sh \ - -b "${{ steps.released-kamel-cli.outputs.released-kamel-binary }}" \ - -d "${{ steps.build-kamel.outputs.build-bundle-image-bundle-index }}" \ - -l "${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }}" \ - -n "${{ steps.build-kamel.outputs.build-binary-local-image-name }}" \ - -q "${{ env.CAMEL_K_LOG_LEVEL }}" \ - -s "${{ steps.config-cluster.outputs.cluster-image-registry-insecure }}" \ - -v "${{ steps.build-kamel.outputs.build-binary-local-image-version }}" \ - -x "${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }}" diff --git a/.github/actions/e2e-install-upgrade/exec-tests.sh b/.github/actions/e2e-install-upgrade/exec-tests.sh deleted file mode 100755 index 856ed1f60..000000000 --- a/.github/actions/e2e-install-upgrade/exec-tests.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash - -# --------------------------------------------------------------------------- -# 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. -# --------------------------------------------------------------------------- - -#### -# -# Execute the upgrade tests -# -#### - -set -e - -while getopts ":b:d:l:n:q:s:v:x:" opt; do - case "${opt}" in - b) - KAMEL_BINARY=${OPTARG} - ;; - d) - BUNDLE_INDEX_IMAGE=${OPTARG} - ;; - l) - REGISTRY_PULL_HOST=${OPTARG} - ;; - n) - IMAGE_NAME=${OPTARG} - ;; - q) - LOG_LEVEL=${OPTARG} - ;; - s) - REGISTRY_INSECURE=${OPTARG} - ;; - v) - IMAGE_VERSION=${OPTARG} - ;; - x) - SAVE_FAILED_TEST_NS=${OPTARG} - ;; - :) - echo "ERROR: Option -$OPTARG requires an argument" - exit 1 - ;; - \?) - echo "ERROR: Invalid option -$OPTARG" - exit 1 - ;; - esac -done -shift $((OPTIND-1)) - -if [ -z "${IMAGE_NAME}" ]; then - echo "Error: local-image-name not defined" - exit 1 -fi - -if [ -z "${IMAGE_VERSION}" ]; then - echo "Error: local-image-version not defined" - exit 1 -fi - -if [ -z "${KAMEL_BINARY}" ]; then - echo "Error: kamel-binary not defined" - exit 1 -fi - -if [ -z "${BUNDLE_INDEX_IMAGE}" ]; then - echo "Error: bundle-index-image not defined" - exit 1 -fi - -if [ -z "${REGISTRY_PULL_HOST}" ]; then - echo "Error: image-registry-pull-host not defined" - exit 1 -fi - -if [ -z "${REGISTRY_INSECURE}" ]; then - echo "Error: image-registry-insecure not defined" - exit 1 -fi - -# Use the last released Kamel CLI -export RELEASED_KAMEL_BIN=${KAMEL_BINARY} - -echo "Kamel version: $(${RELEASED_KAMEL_BIN} version)" - -# Cluster environment -export CUSTOM_IMAGE=${IMAGE_NAME} -export CUSTOM_VERSION=${IMAGE_VERSION} - -# Configure install options -export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) -export KAMEL_INSTALL_REGISTRY=${REGISTRY_PULL_HOST} -export KAMEL_INSTALL_REGISTRY_INSECURE=${REGISTRY_INSECURE} - -# Will only have an effect if olm=false -# since, for OLM, the csv determines the policy -# (see kamel-build-bundle/build-bundle-image.sh) -export KAMEL_INSTALL_OPERATOR_IMAGE_PULL_POLICY="Always" - -# Despite building a bundle we don't want it installed immediately so no OLM_INDEX_BUNDLE var - -# Configure test options -export CAMEL_K_TEST_LOG_LEVEL="${LOG_LEVEL}" -if [ "${LOG_LEVEL}" == "debug" ]; then - export CAMEL_K_TEST_MAVEN_CLI_OPTIONS="-X ${CAMEL_K_TEST_MAVEN_CLI_OPTIONS}" -fi -export CAMEL_K_PREV_IIB=quay.io/operatorhubio/catalog:latest -export CAMEL_K_NEW_IIB=${BUNDLE_INDEX_IMAGE} -export CAMEL_K_PREV_UPGRADE_CHANNEL=${PREV_XY_CHANNEL} -export CAMEL_K_NEW_UPGRADE_CHANNEL=${NEW_XY_CHANNEL} -export KAMEL_K_TEST_RELEASE_VERSION=$(make get-last-released-version) -export KAMEL_K_TEST_OPERATOR_CURRENT_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} -export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} - -# Then run integration tests -DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-install-upgrade diff --git a/.github/actions/e2e-install/action.yml b/.github/actions/e2e-install/action.yml index 35ab77210..f739ea69a 100644 --- a/.github/actions/e2e-install/action.yml +++ b/.github/actions/e2e-install/action.yml @@ -15,8 +15,8 @@ # limitations under the License. # --------------------------------------------------------------------------- -name: e2e-install -description: 'End-to-End tests for install use-cases (namespaced rather than global operator so no global operator install)' +name: e2e-install-olm +description: 'End-to-End tests for OLM installation and upgrade procedure' inputs: cluster-config-data: @@ -35,11 +35,37 @@ runs: uses: ./.github/actions/kamel-prepare-env - id: config-cluster - name: Configure Platform + name: Configure Cluster uses: ./.github/actions/kamel-config-cluster with: cluster-config-data: ${{ inputs.cluster-config-data }} cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }} + require-olm: true + + - id: released-kamel-cli + name: Get Released Kamel CLI + shell: bash + run: | + export KAMEL_VERSION=$(make get-last-released-version) + curl -L https://github.com/apache/camel-k/releases/download/v${KAMEL_VERSION}/camel-k-client-${KAMEL_VERSION}-linux-amd64.tar.gz -o /tmp/kamel.tar.gz + pushd /tmp && tar -zxf kamel.tar.gz && popd > /dev/null + if [ ! -x /tmp/kamel ]; then + echo "Error: No ${KAMEL_VERSION} downloaded correctly" + exit 1 + fi + + # + # Note: cannot use GITHUB_ENV vars in same script as it was defined + # + export RELEASED_KAMEL_BINARY=/tmp/kamel-${KAMEL_VERSION} + mv /tmp/kamel ${RELEASED_KAMEL_BINARY} + if [ $? == 0 ]; then + echo "Info: Kamel version installed: $(${RELEASED_KAMEL_BINARY} version)" + echo "released-kamel-binary=${RELEASED_KAMEL_BINARY}" >> $GITHUB_OUTPUT + else + echo "Error: Failed to install kamel binary ${KAMEL_VERSION}" + exit 1 + fi - id: build-kamel name: Build Kamel @@ -48,23 +74,23 @@ runs: image-registry-push-host: ${{ steps.config-cluster.outputs.cluster-image-registry-push-host }} image-registry-pull-host: ${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} - # Builds the bundle if an OLM is available - depends on cluster being tested + # Builds the bundle if an OLM is available. + # Since configure-cluster requires OLM then this should be true build-bundle: ${{ steps.config-cluster.outputs.cluster-has-olm }} # Both can be empty and so catalog source will not be created catalog-source-name: ${{ steps.config-cluster.outputs.cluster-catalog-source-name }} catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }} - - id: run-it - name: Run IT + - name: Run IT shell: bash run: | + # Note different parameters due to alternative installation ./.github/actions/e2e-install/exec-tests.sh \ - -b "${{ steps.config-cluster.outputs.cluster-catalog-source-name }}" \ - -c "${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }}" \ - -i "${{ steps.config-cluster.outputs.cluster-image-namespace }}" \ + -b "${{ steps.released-kamel-cli.outputs.released-kamel-binary }}" \ + -d "${{ steps.build-kamel.outputs.build-bundle-image-bundle-index }}" \ -l "${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }}" \ -n "${{ steps.build-kamel.outputs.build-binary-local-image-name }}" \ -q "${{ env.CAMEL_K_LOG_LEVEL }}" \ - -s "${{steps.config-cluster.outputs.cluster-image-registry-insecure }}" \ + -s "${{ steps.config-cluster.outputs.cluster-image-registry-insecure }}" \ -v "${{ steps.build-kamel.outputs.build-binary-local-image-version }}" \ -x "${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }}" diff --git a/.github/actions/e2e-install/exec-tests.sh b/.github/actions/e2e-install/exec-tests.sh index e12e3dc50..d34501028 100755 --- a/.github/actions/e2e-install/exec-tests.sh +++ b/.github/actions/e2e-install/exec-tests.sh @@ -19,22 +19,19 @@ #### # -# Execute the install tests +# Execute the upgrade tests # #### set -e -while getopts ":b:c:i:l:n:q:s:v:x:" opt; do +while getopts ":b:d:l:n:q:s:v:x:" opt; do case "${opt}" in b) - BUILD_CATALOG_SOURCE_NAME=${OPTARG} + KAMEL_BINARY=${OPTARG} ;; - c) - BUILD_CATALOG_SOURCE_NAMESPACE=${OPTARG} - ;; - i) - IMAGE_NAMESPACE=${OPTARG} + d) + BUNDLE_INDEX_IMAGE=${OPTARG} ;; l) REGISTRY_PULL_HOST=${OPTARG} @@ -76,8 +73,13 @@ if [ -z "${IMAGE_VERSION}" ]; then exit 1 fi -if [ -z "${IMAGE_NAMESPACE}" ]; then - echo "Error: image-namespace not defined" +if [ -z "${KAMEL_BINARY}" ]; then + echo "Error: kamel-binary not defined" + exit 1 +fi + +if [ -z "${BUNDLE_INDEX_IMAGE}" ]; then + echo "Error: bundle-index-image not defined" exit 1 fi @@ -91,36 +93,38 @@ if [ -z "${REGISTRY_INSECURE}" ]; then exit 1 fi +# Use the last released Kamel CLI +export RELEASED_KAMEL_BIN=${KAMEL_BINARY} + +echo "Kamel version: $(${RELEASED_KAMEL_BIN} version)" + # Cluster environment export CUSTOM_IMAGE=${IMAGE_NAME} export CUSTOM_VERSION=${IMAGE_VERSION} -# -# If bundle has been built and installed then use it -# -if [ -n "${BUILD_CATALOG_SOURCE_NAMESPACE}" ]; then - export KAMEL_INSTALL_OLM_SOURCE=${BUILD_CATALOG_SOURCE_NAME} - export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${BUILD_CATALOG_SOURCE_NAMESPACE} - export KAMEL_INSTALL_OLM_CHANNEL="${NEW_XY_CHANNEL}" -fi - -KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) -export KAMEL_INSTALL_MAVEN_REPOSITORIES +# Configure install options +export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) export KAMEL_INSTALL_REGISTRY=${REGISTRY_PULL_HOST} export KAMEL_INSTALL_REGISTRY_INSECURE=${REGISTRY_INSECURE} -export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} # Will only have an effect if olm=false # since, for OLM, the csv determines the policy # (see kamel-build-bundle/build-bundle-image.sh) export KAMEL_INSTALL_OPERATOR_IMAGE_PULL_POLICY="Always" +# Despite building a bundle we don't want it installed immediately so no OLM_INDEX_BUNDLE var + +# Configure test options export CAMEL_K_TEST_LOG_LEVEL="${LOG_LEVEL}" if [ "${LOG_LEVEL}" == "debug" ]; then export CAMEL_K_TEST_MAVEN_CLI_OPTIONS="-X ${CAMEL_K_TEST_MAVEN_CLI_OPTIONS}" fi -export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} -export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} +export CAMEL_K_PREV_IIB=quay.io/operatorhubio/catalog:latest +export CAMEL_K_NEW_IIB=${BUNDLE_INDEX_IMAGE} +export CAMEL_K_PREV_UPGRADE_CHANNEL=${PREV_XY_CHANNEL} +export CAMEL_K_NEW_UPGRADE_CHANNEL=${NEW_XY_CHANNEL} +export KAMEL_K_TEST_RELEASE_VERSION=$(make get-last-released-version) +export KAMEL_K_TEST_OPERATOR_CURRENT_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} # Then run integration tests diff --git a/.github/actions/e2e-knative/exec-tests.sh b/.github/actions/e2e-knative/exec-tests.sh index 27d5106d7..bf3296217 100755 --- a/.github/actions/e2e-knative/exec-tests.sh +++ b/.github/actions/e2e-knative/exec-tests.sh @@ -136,6 +136,8 @@ fi kubectl create ns camel-k REGISTRY="${KAMEL_INSTALL_REGISTRY}" make install-k8s-global +# Let's wait for the IntegrationPlatform to be ready before starting any operation +kubectl wait --for=jsonpath='{.status.phase}'=Ready itp camel-k -n camel-k --timeout=45s # Then run integration tests DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-knative diff --git a/.github/actions/e2e-native/exec-tests.sh b/.github/actions/e2e-native/exec-tests.sh index 00d3f1eb4..ec7a7805c 100755 --- a/.github/actions/e2e-native/exec-tests.sh +++ b/.github/actions/e2e-native/exec-tests.sh @@ -129,6 +129,8 @@ fi kubectl create ns camel-k REGISTRY="${KAMEL_INSTALL_REGISTRY}" make install-k8s-global +# Let's wait for the IntegrationPlatform to be ready before starting any operation +kubectl wait --for=jsonpath='{.status.phase}'=Ready itp camel-k -n camel-k --timeout=45s # Then run integration tests DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-quarkus-native diff --git a/.github/actions/e2e-telemetry/exec-tests.sh b/.github/actions/e2e-telemetry/exec-tests.sh index ebe1ed4fb..c70b3e32b 100755 --- a/.github/actions/e2e-telemetry/exec-tests.sh +++ b/.github/actions/e2e-telemetry/exec-tests.sh @@ -133,6 +133,8 @@ fi kubectl create ns camel-k REGISTRY="${KAMEL_INSTALL_REGISTRY}" make install-k8s-global +# Let's wait for the IntegrationPlatform to be ready before starting any operation +kubectl wait --for=jsonpath='{.status.phase}'=Ready itp camel-k -n camel-k --timeout=45s # Then run all integration telemetry test rather than ending on first failure set -e diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 31a80d76c..46f891af4 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -56,7 +56,7 @@ concurrency: cancel-in-progress: true jobs: - non-olm: + install-and-upgrade: runs-on: ubuntu-latest steps: @@ -75,40 +75,8 @@ jobs: sudo apt-get update sudo apt-get install helm - - name: Install (Non OLM) + - name: Install and upgrade uses: ./.github/actions/e2e-install with: cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} - - olm: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - persist-credentials: false - submodules: recursive - - - name: Install (OLM) - uses: ./.github/actions/e2e-install-olm - with: - cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} - cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} - - upgrade: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - persist-credentials: false - submodules: recursive - - - name: Upgrade - uses: ./.github/actions/e2e-install-upgrade - with: - cluster-config-data: ${{ secrets.E2E_CLUSTER_CONFIG }} - cluster-kube-config-data: ${{ secrets.E2E_KUBE_CONFIG }} diff --git a/docs/charts/camel-k-2.4.0-SNAPSHOT.tgz b/docs/charts/camel-k-2.4.0-SNAPSHOT.tgz deleted file mode 100644 index 91b962218..000000000 Binary files a/docs/charts/camel-k-2.4.0-SNAPSHOT.tgz and /dev/null differ diff --git a/docs/charts/index.yaml b/docs/charts/index.yaml index bae2ac516..66dd6d44d 100644 --- a/docs/charts/index.yaml +++ b/docs/charts/index.yaml @@ -1,33 +1,6 @@ apiVersion: v1 entries: camel-k: - - apiVersion: v2 - appVersion: 2.4.0-SNAPSHOT - created: "2024-06-25T14:56:24.863451472+02:00" - description: A lightweight integration platform, born on Kubernetes, with serverless - superpowers - digest: 92898328746f6e40411b1ae8c78611c26bc0dfed74dad14a412793b4b681a4d0 - home: https://camel.apache.org/camel-k/latest/ - icon: https://github.com/apache/camel/raw/main/docs/img/logo64-d.png - keywords: - - serverless - - integration - - patterns - maintainers: - - email: [email protected] - name: pcongiusti - - email: [email protected] - name: acosentino - name: camel-k - sources: - - https://github.com/apache/camel-k - - https://github.com/apache/camel-k-runtime - - https://github.com/apache/camel-quarkus - - https://github.com/apache/camel - type: application - urls: - - https://apache.github.io/camel-k/charts/camel-k-2.4.0-SNAPSHOT.tgz - version: 2.4.0-SNAPSHOT - apiVersion: v2 appVersion: 2.3.3 created: "2024-06-10T15:48:52.865992809+02:00" diff --git a/docs/modules/ROOT/pages/contributing/e2e.adoc b/docs/modules/ROOT/pages/contributing/e2e.adoc index 68a0bc281..9fcbc6f12 100644 --- a/docs/modules/ROOT/pages/contributing/e2e.adoc +++ b/docs/modules/ROOT/pages/contributing/e2e.adoc @@ -12,14 +12,14 @@ Since both unit test and integration test names end with `_test.go`, both would Look into the https://github.com/apache/camel-k/tree/main/e2e[/e2e] directory for examples of integration tests. -Before running an integration test, you need to be connected to a Kubernetes/OpenShift namespace. After you log into your cluster, you can run the following command to execute the suite of smoke tests: +Before running an integration test, you need to be connected to a Kubernetes/OpenShift namespace and have the Camel K operator installed globally into a namespaced named `camel-k`. After you log into your cluster, you can run the following command to execute the suite of smoke tests: [source] ---- 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. +The test script will run the Integrations in random namespaces, 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 @@ -30,10 +30,9 @@ There may be a `files/setup.sh` script in some groups (e.g. knative) that can he 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`) * advanced (`make test-advanced`) - * install (`make test-install`, `make test-install-olm` and `make test-install-upgrade`) + * install (`make test-install`) * knative (`make test-knative`) * native (`make test-quarkus-native`) * telemetry (`make test-telemetry`) @@ -42,17 +41,10 @@ Each group tests a specific feature of Camel K. Typically any new test should be 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. -=== Configure End To End tests runs with env vars -Some e2e test runs parameters can be configured usually with env vars. -Most of them are located at https://github.com/apache/camel-k/tree/main/e2e/support/test_support.go[e2e/support/test_support.go] in `init` and `kamelInstallWithContext` functions. -A list of the most commonly used: - -* `CAMEL_K_TEST_SKIP_PROBLEMATIC`: set it to `true` to skip tests that might fail. - [[testing-operator]] == Testing Operator under development -You probably want to test your changes on camel-k `operator` locally after some development. You will need to make the operator docker image available to your cluster registry before launching the tests. We have a script which will take care of that. +You probably want to test your changes on Camel-K Operator locally after some development. You will need to make the operator docker image available to your cluster registry before launching the tests. We have a script which will take care of that. First, you must connect and point to the `docker daemon`. If you're on a local environment such as `minikube`, it will be as simple as executing @@ -76,39 +68,3 @@ You can also execute the following script, if by any chance you have some change ---- make images [CAMEL_K_RUNTIME_DIR=/path/to/camel-k-runtime-project] ---- - -[[using-remote-cluster]] -== Using remote cluster - -If you don't have enough machine resources to run the test locally (a local Kubernetes cluster may require up to 32 GB of memory and several CPUs), then, you can push your operator image to some remote registry that is also reachable from your Kubernetes cluster. - ----- -make images CUSTOM_IMAGE=docker.io/my-org/my-ck-operator-test ----- - -Then, you need to use a couple of environment variables in order to let the test know the container image to use. - ----- -export CAMEL_K_TEST_OPERATOR_IMAGE=docker.io/my-org/my-ck-operator-test:2.0.0-SNAPSHOT -export CAMEL_K_TEST_OPERATOR_IMAGE_PULL_POLICY=Always // this may not be required, use only if you want to change the policy ----- - -Make sure your local Kubernetes config settings is pointing to the right cluster (ie, `kubectl config current-context`) and run the suite of test you want to run (ie, `make test-common`). - -[[using-nexus]] -== Using Nexus repository mirror with E2E testing - -To speed up integration testing locally, you may use a https://github.com/sonatype/docker-nexus3[Nexus Repository Manager] for Maven repository mirror. - -You can set the environment variable `TEST_ENABLE_NEXUS=true` to enable the usage of Nexus mirror in e2e testing. If `TEST_ENABLE_NEXUS` is set, e2e tests will try to discover a Nexus instance as `nexus` service in `nexus` namespace and if it is found they will use it as the Maven repository mirror for the `camel-k` platform under test. - -[source] ----- -TEST_ENABLE_NEXUS=true make test-integration ----- - -To set up a Nexus instance in your cluster, run the following command: -[source] ----- -kubectl apply -f e2e/support/files/nexus.yaml ----- diff --git a/e2e/advanced/build_max_pipelines_test.go b/e2e/advanced/build_max_pipelines_test.go index d9c666dd1..992e0a7ce 100644 --- a/e2e/advanced/build_max_pipelines_test.go +++ b/e2e/advanced/build_max_pipelines_test.go @@ -43,7 +43,7 @@ type kitOptions struct { func kitMaxBuildLimit(t *testing.T, maxRunningBuilds int32, buildOrderStrategy v1.BuildOrderStrategy) { WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) pl := Platform(t, ctx, ns)() // set maximum number of running builds and order strategy @@ -126,7 +126,7 @@ func TestKitMaxBuildLimitDependencies(t *testing.T) { func TestMaxBuildLimitWaitingBuilds(t *testing.T) { WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) pl := Platform(t, ctx, ns)() // set maximum number of running builds and order strategy diff --git a/e2e/advanced/build_order_strategy_test.go b/e2e/advanced/build_order_strategy_test.go index 1c3dcbf26..c25d14a4a 100644 --- a/e2e/advanced/build_order_strategy_test.go +++ b/e2e/advanced/build_order_strategy_test.go @@ -37,7 +37,7 @@ import ( func TestRunBuildOrderStrategyMatchingDependencies(t *testing.T) { WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) // Update platform with parameters required by this test pl := Platform(t, ctx, ns)() @@ -113,7 +113,7 @@ func TestRunBuildOrderStrategyMatchingDependencies(t *testing.T) { func TestRunBuildOrderStrategyFIFO(t *testing.T) { WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) // Update platform with parameters required by this test pl := Platform(t, ctx, ns)() pl.Spec.Build.BuildConfiguration.OrderStrategy = v1.BuildOrderStrategyFIFO diff --git a/e2e/advanced/builder_test.go b/e2e/advanced/builder_test.go index a97945aab..faf0e6bee 100644 --- a/e2e/advanced/builder_test.go +++ b/e2e/advanced/builder_test.go @@ -40,12 +40,9 @@ func TestBuilderTimeout(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) - g.Eventually(OperatorPod(t, ctx, ns)).ShouldNot(BeNil()) - g.Eventually(Platform(t, ctx, ns)).ShouldNot(BeNil()) - g.Eventually(PlatformConditionStatus(t, ctx, ns, v1.IntegrationPlatformConditionTypeCreated), TestTimeoutShort). - Should(Equal(corev1.ConditionTrue)) + InstallOperator(t, ctx, g, ns) + g.Eventually(Platform(t, ctx, ns)).ShouldNot(BeNil()) pl := Platform(t, ctx, ns)() // set a short timeout to simulate the build timeout pl.Spec.Build.Timeout = &metav1.Duration{ @@ -86,7 +83,7 @@ func TestMavenProfile(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) t.Run("Run maven profile", func(t *testing.T) { name := RandomizedSuffixName("java-maven-profile") diff --git a/e2e/advanced/catalog_builder_test.go b/e2e/advanced/catalog_builder_test.go index 4a100412c..396fecfe8 100644 --- a/e2e/advanced/catalog_builder_test.go +++ b/e2e/advanced/catalog_builder_test.go @@ -40,7 +40,7 @@ func TestCamelCatalogBuilder(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) g.Eventually(OperatorPod(t, ctx, ns)).ShouldNot(BeNil()) g.Eventually(Platform(t, ctx, ns)).ShouldNot(BeNil()) g.Eventually(PlatformConditionStatus(t, ctx, ns, v1.IntegrationPlatformConditionTypeCreated), TestTimeoutShort). diff --git a/e2e/advanced/debug_test.go b/e2e/advanced/debug_test.go index fa084a71e..7b54a63c4 100644 --- a/e2e/advanced/debug_test.go +++ b/e2e/advanced/debug_test.go @@ -38,7 +38,7 @@ func TestKamelCLIDebug(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) t.Run("debug local default port check", func(t *testing.T) { g.Expect(KamelRun(t, ctx, ns, "files/yaml.yaml").Execute()).To(Succeed()) diff --git a/e2e/advanced/dump_test.go b/e2e/advanced/dump_test.go index 11b3c9e23..74dcb008b 100644 --- a/e2e/advanced/dump_test.go +++ b/e2e/advanced/dump_test.go @@ -44,7 +44,7 @@ func TestKamelCLIDump(t *testing.T) { g.Expect(dump).To(ContainSubstring("Found 0 deployments:")) }) - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) t.Run("dump non-empty namespace", func(t *testing.T) { g.Expect(KamelRun(t, ctx, ns, "files/yaml.yaml").Execute()).To(Succeed()) diff --git a/e2e/advanced/environment_test.go b/e2e/advanced/environment_test.go index 980c87f35..0735a094e 100644 --- a/e2e/advanced/environment_test.go +++ b/e2e/advanced/environment_test.go @@ -66,7 +66,7 @@ func TestEnvironmentTrait(t *testing.T) { // Install Camel K with the HTTP proxy environment variable //g.Expect(InstallOperator(t, ctx, operatorID, ns, "--operator-env-vars", fmt.Sprintf("HTTP_PROXY=%s", httpProxy), "--operator-env-vars", "NO_PROXY="+strings.Join(noProxy, ","))).To(Succeed()) - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) t.Run("Run integration with default environment", func(t *testing.T) { name := RandomizedSuffixName("java-default") diff --git a/e2e/advanced/incremental_build_test.go b/e2e/advanced/incremental_build_test.go index aed9771a3..c8e782bde 100644 --- a/e2e/advanced/incremental_build_test.go +++ b/e2e/advanced/incremental_build_test.go @@ -40,7 +40,7 @@ func TestRunIncrementalBuildRoutine(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) name := RandomizedSuffixName("java") g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", name).Execute()).To(Succeed()) @@ -83,7 +83,7 @@ func TestRunIncrementalBuildPod(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) name := RandomizedSuffixName("java") g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", name, "-t", "builder.strategy=pod").Execute()).To(Succeed()) @@ -129,7 +129,7 @@ func TestRunIncrementalBuildOff(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) name := RandomizedSuffixName("java") g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", name).Execute()).To(Succeed()) @@ -167,7 +167,7 @@ func TestRunIncrementalBuildWithDifferentBaseImages(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) name := RandomizedSuffixName("java") g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", name).Execute()).To(Succeed()) diff --git a/e2e/common/misc/integration_profile_test.go b/e2e/advanced/integration_profile_test.go similarity index 89% rename from e2e/common/misc/integration_profile_test.go rename to e2e/advanced/integration_profile_test.go index 7b65fcf0e..55fd47df5 100644 --- a/e2e/common/misc/integration_profile_test.go +++ b/e2e/advanced/integration_profile_test.go @@ -20,13 +20,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package misc +package advanced import ( "context" "testing" - "github.com/apache/camel-k/v2/pkg/platform" "github.com/apache/camel-k/v2/pkg/util/defaults" . "github.com/onsi/gomega" @@ -38,8 +37,12 @@ import ( ) func TestIntegrationProfile(t *testing.T) { - operatorID := platform.DefaultPlatformName + t.Parallel() + WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { + operatorID := "camel-k-integration-profile" + InstallOperatorWithID(t, ctx, g, ns, operatorID) + integrationProfile := v1.NewIntegrationProfile(ns, "ipr-global") integrationProfile.SetOperatorID(operatorID) integrationProfile.Spec.Traits.Container = &traitv1.ContainerTrait{ @@ -60,7 +63,7 @@ func TestIntegrationProfile(t *testing.T) { g.Eventually(SelectedIntegrationProfilePhase(t, ctx, ns1, "ipr-local"), TestTimeoutMedium).Should(Equal(v1.IntegrationProfilePhaseReady)) t.Run("Run integration with global integration profile", func(t *testing.T) { - g.Expect(KamelRun(t, ctx, ns1, "--name", "limited", "--integration-profile", "ipr-global", "files/yaml.yaml").Execute()).To(Succeed()) + g.Expect(KamelRunWithID(t, ctx, operatorID, ns1, "--name", "limited", "--integration-profile", "ipr-global", "files/yaml.yaml").Execute()).To(Succeed()) g.Eventually(IntegrationPod(t, ctx, ns1, "limited"), TestTimeoutMedium).Should(Not(BeNil())) g.Eventually(IntegrationPodHas(t, ctx, ns1, "limited", func(pod *corev1.Pod) bool { @@ -81,7 +84,7 @@ func TestIntegrationProfile(t *testing.T) { }) t.Run("Run integration with namespace local integration profile", func(t *testing.T) { - g.Expect(KamelRun(t, ctx, ns1, "--name", "limited", "--integration-profile", "ipr-local", "files/yaml.yaml").Execute()).To(Succeed()) + g.Expect(KamelRunWithID(t, ctx, operatorID, ns1, "--name", "limited", "--integration-profile", "ipr-local", "files/yaml.yaml").Execute()).To(Succeed()) g.Eventually(IntegrationPod(t, ctx, ns1, "limited"), TestTimeoutMedium).Should(Not(BeNil())) g.Eventually(IntegrationPodHas(t, ctx, ns1, "limited", func(pod *corev1.Pod) bool { @@ -103,7 +106,7 @@ func TestIntegrationProfile(t *testing.T) { }) t.Run("Run integration without integration profile", func(t *testing.T) { - g.Expect(KamelRun(t, ctx, ns1, "--name", "normal", "files/yaml.yaml").Execute()).To(Succeed()) + g.Expect(KamelRunWithID(t, ctx, operatorID, ns1, "--name", "normal", "files/yaml.yaml").Execute()).To(Succeed()) g.Eventually(IntegrationPod(t, ctx, ns1, "normal"), TestTimeoutShort).Should(Not(BeNil())) g.Eventually(IntegrationPodHas(t, ctx, ns1, "normal", func(pod *corev1.Pod) bool { if len(pod.Spec.Containers) != 1 { @@ -118,8 +121,12 @@ func TestIntegrationProfile(t *testing.T) { } func TestIntegrationProfileInfluencesKit(t *testing.T) { - operatorID := platform.DefaultPlatformName + t.Parallel() + WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { + operatorID := "camel-k-ipr-kit" + InstallOperatorWithID(t, ctx, g, ns, operatorID) + integrationProfile := v1.NewIntegrationProfile(ns, "ipr-global") integrationProfile.SetOperatorID(operatorID) integrationProfile.Spec.Traits.Builder = &traitv1.BuilderTrait{ @@ -129,7 +136,7 @@ func TestIntegrationProfileInfluencesKit(t *testing.T) { g.Expect(CreateIntegrationProfile(t, ctx, &integrationProfile)).To(Succeed()) g.Eventually(SelectedIntegrationProfilePhase(t, ctx, ns, "ipr-global"), TestTimeoutMedium).Should(Equal(v1.IntegrationProfilePhaseReady)) - g.Expect(KamelRun(t, ctx, ns, "--name", "normal", "files/yaml.yaml").Execute()).To(Succeed()) + g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "--name", "normal", "files/yaml.yaml").Execute()).To(Succeed()) g.Eventually(IntegrationPod(t, ctx, ns, "normal"), TestTimeoutMedium).Should(Not(BeNil())) g.Eventually(IntegrationPodPhase(t, ctx, ns, "normal"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) g.Eventually(IntegrationConditionStatus(t, ctx, ns, "normal", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) @@ -139,7 +146,7 @@ func TestIntegrationProfileInfluencesKit(t *testing.T) { g.Eventually(Kit(t, ctx, ns, integrationKitName)().Status.BaseImage).Should(Equal(defaults.BaseImage())) g.Eventually(Kit(t, ctx, ns, integrationKitName)().Status.RootImage).Should(Equal(defaults.BaseImage())) - g.Expect(KamelRun(t, ctx, ns, "--name", "simple", "--integration-profile", "ipr-global", "files/yaml.yaml").Execute()).To(Succeed()) + g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "--name", "simple", "--integration-profile", "ipr-global", "files/yaml.yaml").Execute()).To(Succeed()) g.Eventually(IntegrationPod(t, ctx, ns, "simple"), TestTimeoutMedium).Should(Not(BeNil())) g.Eventually(IntegrationPodPhase(t, ctx, ns, "simple"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) @@ -155,8 +162,12 @@ func TestIntegrationProfileInfluencesKit(t *testing.T) { } func TestPropagateIntegrationProfileChanges(t *testing.T) { - operatorID := platform.DefaultPlatformName + t.Parallel() + WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { + operatorID := "camel-k-ipr-changes" + InstallOperatorWithID(t, ctx, g, ns, operatorID) + integrationProfile := v1.NewIntegrationProfile(ns, "debug-profile") integrationProfile.SetOperatorID(operatorID) integrationProfile.Spec.Traits.Container = &traitv1.ContainerTrait{ diff --git a/e2e/advanced/kamelet_repo_test.go b/e2e/advanced/kamelet_repo_test.go index 6ec87fc85..1be44cb15 100644 --- a/e2e/advanced/kamelet_repo_test.go +++ b/e2e/advanced/kamelet_repo_test.go @@ -36,7 +36,7 @@ func TestKameletFromCustomRepository(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) kameletName := "timer-custom-source" removeKamelet(t, ctx, kameletName, ns) diff --git a/e2e/advanced/maven_http_proxy_test.go b/e2e/advanced/maven_http_proxy_test.go index a7467af68..b174ed372 100644 --- a/e2e/advanced/maven_http_proxy_test.go +++ b/e2e/advanced/maven_http_proxy_test.go @@ -141,7 +141,7 @@ func TestMavenProxy(t *testing.T) { } noProxy = append(noProxy, svc.Spec.ClusterIPs...) - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) // Check that operator pod has env_vars g.Eventually(OperatorPodHas(t, ctx, ns, func(op *corev1.Pod) bool { @@ -197,7 +197,7 @@ func TestMavenProxyNotPresent(t *testing.T) { } noProxy = append(noProxy, svc.Spec.ClusterIPs...) - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) //g.Expect(KamelInstallWithID(t, ctx, operatorID, ns, "--operator-env-vars", fmt.Sprintf("HTTP_PROXY=http://%s", hostname), "--operator-env-vars", "NO_PROXY="+strings.Join(noProxy, ","))).To(Succeed()) // Run the Integration diff --git a/e2e/advanced/operator_id_filtering_test.go b/e2e/advanced/operator_id_filtering_test.go index 281b4ef1f..c281390ff 100644 --- a/e2e/advanced/operator_id_filtering_test.go +++ b/e2e/advanced/operator_id_filtering_test.go @@ -41,12 +41,12 @@ func TestOperatorIDFiltering(t *testing.T) { WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { WithNewTestNamespace(t, func(ctx context.Context, g *WithT, nsop1 string) { operator1 := "operator-1" - InstallOperatorWithID(t, g, nsop1, operator1) + InstallOperatorWithID(t, ctx, g, nsop1, operator1) g.Eventually(PlatformPhase(t, ctx, nsop1), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) WithNewTestNamespace(t, func(ctx context.Context, g *WithT, nsop2 string) { operator2 := "operator-2" - InstallOperatorWithID(t, g, nsop2, operator2) + InstallOperatorWithID(t, ctx, g, nsop2, operator2) g.Eventually(PlatformPhase(t, ctx, nsop2), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) t.Run("Operators ignore non-scoped integrations", func(t *testing.T) { diff --git a/e2e/advanced/operator_metrics_test.go b/e2e/advanced/operator_metrics_test.go index 4f8b8fa62..9228bc7b6 100644 --- a/e2e/advanced/operator_metrics_test.go +++ b/e2e/advanced/operator_metrics_test.go @@ -50,7 +50,7 @@ func TestMetrics(t *testing.T) { WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { //g.Expect(InstallOperator(t, ctx, operatorID, ns, "--log-level", "debug")).To(Succeed()) - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) name := RandomizedSuffixName("java") g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", name, "-t", "prometheus.enabled=true", "-t", "prometheus.pod-monitor=false").Execute()).To(Succeed()) diff --git a/e2e/advanced/platform_traits_test.go b/e2e/advanced/platform_traits_test.go index 175f741e6..baf00f4b7 100644 --- a/e2e/advanced/platform_traits_test.go +++ b/e2e/advanced/platform_traits_test.go @@ -40,7 +40,7 @@ func TestTraitOnIntegrationPlatform(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) containerTestName := "testname" diff --git a/e2e/advanced/promote_test.go b/e2e/advanced/promote_test.go index 85504344b..13716f71d 100644 --- a/e2e/advanced/promote_test.go +++ b/e2e/advanced/promote_test.go @@ -42,7 +42,7 @@ func TestKamelCLIPromote(t *testing.T) { // Dev environment namespace WithNewTestNamespace(t, func(ctx context.Context, g *WithT, nsDev string) { operatorDevID := "camel-k-cli-promote-dev" - InstallOperatorWithID(t, g, nsDev, operatorDevID) + InstallOperatorWithID(t, ctx, g, nsDev, operatorDevID) g.Eventually(SelectedPlatformPhase(t, ctx, nsDev, operatorDevID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) // Dev content configmap @@ -88,7 +88,7 @@ func TestKamelCLIPromote(t *testing.T) { // Prod environment namespace WithNewTestNamespace(t, func(ctx context.Context, g *WithT, nsProd string) { operatorProdID := "camel-k-cli-promote-prod" - InstallOperatorWithID(t, g, nsProd, operatorProdID) + InstallOperatorWithID(t, ctx, g, nsProd, operatorProdID) g.Eventually(PlatformPhase(t, ctx, nsProd), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) t.Run("no configmap in destination", func(t *testing.T) { diff --git a/e2e/advanced/reset_test.go b/e2e/advanced/reset_test.go index e6ff6c8ef..c2976c570 100644 --- a/e2e/advanced/reset_test.go +++ b/e2e/advanced/reset_test.go @@ -36,7 +36,7 @@ func TestKamelReset(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) t.Run("Reset the whole platform", func(t *testing.T) { name := RandomizedSuffixName("yaml1") diff --git a/e2e/advanced/synthetic_test.go b/e2e/advanced/synthetic_test.go index bc69f2f78..5c5ec8e33 100644 --- a/e2e/advanced/synthetic_test.go +++ b/e2e/advanced/synthetic_test.go @@ -41,7 +41,7 @@ func TestSyntheticIntegrationOff(t *testing.T) { WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { // Install Camel K without synthetic Integration feature variable (default) - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) // Run the external deployment ExpectExecSucceed(t, g, Kubectl("apply", "-f", "files/deploy.yaml", "-n", ns)) @@ -64,7 +64,7 @@ func TestSyntheticIntegrationFromDeployment(t *testing.T) { // g.Expect(InstallOperator(t, ctx, operatorID, ns, // "--operator-env-vars", "CAMEL_K_SYNTHETIC_INTEGRATIONS=true", // )).To(Succeed()) - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) g.Eventually(OperatorPodHas(t, ctx, ns, func(op *corev1.Pod) bool { if envVar := envvar.Get(op.Spec.Containers[0].Env, "CAMEL_K_SYNTHETIC_INTEGRATIONS"); envVar != nil { return envVar.Value == "true" diff --git a/e2e/advanced/tekton_test.go b/e2e/advanced/tekton_test.go index ccdbd8c86..56e4e2fcc 100644 --- a/e2e/advanced/tekton_test.go +++ b/e2e/advanced/tekton_test.go @@ -41,7 +41,7 @@ func TestTektonLikeBehavior(t *testing.T) { t.Parallel() WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { - InstallOperator(t, g, ns) + InstallOperator(t, ctx, g, ns) // Store a configmap holding an integration source var cmData = make(map[string][]byte) diff --git a/e2e/knative/knative_pipes_test.go b/e2e/knative/knative_pipes_test.go index 88d8f3135..ce88f2bdf 100644 --- a/e2e/knative/knative_pipes_test.go +++ b/e2e/knative/knative_pipes_test.go @@ -24,6 +24,7 @@ package knative import ( "context" + "fmt" "testing" "time" @@ -136,8 +137,13 @@ func TestKnativePipes(t *testing.T) { func TestRunBroker(t *testing.T) { WithNewTestNamespaceWithKnativeBroker(t, func(ctx context.Context, g *WithT, ns string) { - g.Expect(KamelRun(t, ctx, ns, "files/knativeevt1.yaml").Execute()).To(Succeed()) - g.Expect(KamelRun(t, ctx, ns, "files/knativeevt2.yaml").Execute()).To(Succeed()) + // This test require an adhoc operator to run properly + operatorID := fmt.Sprintf("camel-k-%s", ns) + InstallOperatorWithID(t, ctx, g, ns, operatorID) + g.Eventually(SelectedPlatformPhase(t, ctx, ns, operatorID), TestTimeoutMedium).Should(Equal(camelv1.IntegrationPlatformPhaseReady)) + + g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/knativeevt1.yaml").Execute()).To(Succeed()) + g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/knativeevt2.yaml").Execute()).To(Succeed()) g.Eventually(IntegrationPodPhase(t, ctx, ns, "knativeevt1"), TestTimeoutLong).Should(Equal(v1.PodRunning)) g.Eventually(IntegrationPodPhase(t, ctx, ns, "knativeevt2"), TestTimeoutLong).Should(Equal(v1.PodRunning)) g.Eventually(IntegrationLogs(t, ctx, ns, "knativeevt2"), TestTimeoutMedium).Should(ContainSubstring("Received 1: Hello 1")) diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go index e8893d11e..e15a0bdd2 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -37,6 +37,7 @@ import ( "regexp" "runtime/debug" "strings" + "sync" "testing" "time" @@ -136,6 +137,7 @@ var NoOlmOperatorImage string var testContext = context.TODO() var testClient client.Client +var cmdMutex = sync.Mutex{} func init() { // This line prevents controller-runtime from complaining about log.SetLogger never being called @@ -278,7 +280,7 @@ func KamelRunWithID(t *testing.T, ctx context.Context, operatorID string, namesp } func KamelRunWithContext(t *testing.T, ctx context.Context, operatorID string, namespace string, args ...string) *cobra.Command { - return KamelCommandWithContext(t, ctx, "run", operatorID, namespace, args...) + return kamelCommandWithContext(t, ctx, "run", operatorID, namespace, args...) } func KamelBind(t *testing.T, ctx context.Context, namespace string, args ...string) *cobra.Command { @@ -290,14 +292,15 @@ func KamelBindWithID(t *testing.T, ctx context.Context, operatorID string, names } func KamelBindWithContext(t *testing.T, ctx context.Context, operatorID string, namespace string, args ...string) *cobra.Command { - return KamelCommandWithContext(t, ctx, "bind", operatorID, namespace, args...) + return kamelCommandWithContext(t, ctx, "bind", operatorID, namespace, args...) } -func KamelCommandWithContext(t *testing.T, ctx context.Context, command string, operatorID string, namespace string, args ...string) *cobra.Command { - var cmdArgs []string - - cmdArgs = []string{command, "-n", namespace, "--operator-id", operatorID} +func kamelCommandWithContext(t *testing.T, ctx context.Context, command string, operatorID string, namespace string, args ...string) *cobra.Command { + // Avoid concurrent access to the CLI + cmdMutex.Lock() + defer cmdMutex.Unlock() + cmdArgs := []string{command, "-n", namespace, "--operator-id", operatorID} cmdArgs = append(cmdArgs, args...) return KamelWithContext(t, ctx, cmdArgs...) } @@ -1912,7 +1915,7 @@ func Platform(t *testing.T, ctx context.Context, ns string) func() *v1.Integrati return func() *v1.IntegrationPlatform { lst := v1.NewIntegrationPlatformList() if err := TestClient(t).List(ctx, &lst, ctrl.InNamespace(ns)); err != nil { - failTest(t, err) + return nil } if len(lst.Items) == 0 { return nil diff --git a/e2e/support/test_util.go b/e2e/support/test_util.go index d4433540d..933cf1e4a 100644 --- a/e2e/support/test_util.go +++ b/e2e/support/test_util.go @@ -42,7 +42,8 @@ import ( ) var ( - lock sync.Mutex + lock sync.Mutex + lockID sync.Mutex ) func init() { @@ -68,7 +69,7 @@ func GetEnvOrDefault(key string, deflt string) string { // InstallOperator is in charge to install a namespaced operator. The func must be // executed in a critical section as there may be concurrent access to it. -func InstallOperator(t *testing.T, g *WithT, ns string) { +func InstallOperator(t *testing.T, ctx context.Context, g *WithT, ns string) { lock.Lock() defer lock.Unlock() KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY") @@ -80,89 +81,23 @@ func InstallOperator(t *testing.T, g *WithT, ns string) { fmt.Sprintf("REGISTRY=%s", KAMEL_INSTALL_REGISTRY), "install-k8s-ns"), ) + // Let's make sure the operator has been deployed + g.Eventually(OperatorPod(t, ctx, ns)).ShouldNot(BeNil()) } // InstallOperatorWitID is in charge to install a namespaced operator with a given operator ID name. -func InstallOperatorWithID(t *testing.T, g *WithT, ns, operatorID string) { - t.Skip("Not yet supported") -} - -func installOperatorWithContext(t *testing.T, ctx context.Context, operatorID string, namespace string) error { - KAMEL_INSTALL_REGISTRY := os.Getenv("KAMEL_INSTALL_REGISTRY") - // os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../") - err := Make(t, - fmt.Sprintf("NAMESPACE=%s", namespace), - fmt.Sprintf("REGISTRY=%s", KAMEL_INSTALL_REGISTRY), - "install-k8s-ns").Run() - fmt.Println(err) - return err - /* - if !pkgutil.StringSliceExists(args, "--build-timeout") { - // if --build-timeout is not explicitly passed as an argument, try to configure it - buildTimeout := os.Getenv("CAMEL_K_TEST_BUILD_TIMEOUT") - if buildTimeout == "" { - // default Build Timeout for tests - buildTimeout = "10m" - } - fmt.Printf("Setting build timeout to %s\n", buildTimeout) - installArgs = append(installArgs, "--build-timeout", buildTimeout) - } - - if skipKameletCatalog { - installArgs = append(installArgs, "--skip-default-kamelets-setup") - } - - logLevel := os.Getenv("CAMEL_K_TEST_LOG_LEVEL") - if len(logLevel) > 0 { - fmt.Printf("Setting log-level to %s\n", logLevel) - installArgs = append(installArgs, "--log-level", logLevel) - } - - mvnCLIOptions := os.Getenv("CAMEL_K_TEST_MAVEN_CLI_OPTIONS") - if len(mvnCLIOptions) > 0 { - // Split the string by spaces - mvnCLIArr := strings.Split(mvnCLIOptions, " ") - for _, mc := range mvnCLIArr { - mc = strings.Trim(mc, " ") - if len(mc) == 0 { - continue - } - - fmt.Printf("Adding maven cli option %s\n", mc) - installArgs = append(installArgs, "--maven-cli-option", mc) - } - } - - runtimeVersion := os.Getenv("CAMEL_K_TEST_RUNTIME_VERSION") - if runtimeVersion != "" { - fmt.Printf("Setting runtime version to %s\n", runtimeVersion) - installArgs = append(installArgs, "--runtime-version", runtimeVersion) - } - baseImage := os.Getenv("CAMEL_K_TEST_BASE_IMAGE") - if baseImage != "" { - fmt.Printf("Setting base image to %s\n", baseImage) - installArgs = append(installArgs, "--base-image", baseImage) - } - opImage := os.Getenv("CAMEL_K_TEST_OPERATOR_IMAGE") - if opImage != "" { - fmt.Printf("Setting operator image to %s\n", opImage) - installArgs = append(installArgs, "--operator-image", opImage) - } - opImagePullPolicy := os.Getenv("CAMEL_K_TEST_OPERATOR_IMAGE_PULL_POLICY") - if opImagePullPolicy != "" { - fmt.Printf("Setting operator image pull policy to %s\n", opImagePullPolicy) - installArgs = append(installArgs, "--operator-image-pull-policy", opImagePullPolicy) - } - if len(os.Getenv("CAMEL_K_TEST_MAVEN_CA_PEM_PATH")) > 0 { - certName := "myCert" - secretName := "maven-ca-certs" - CreateSecretDecoded(t, ctx, namespace, os.Getenv("CAMEL_K_TEST_MAVEN_CA_PEM_PATH"), secretName, certName) - installArgs = append(installArgs, "--maven-repository", os.Getenv("KAMEL_INSTALL_MAVEN_REPOSITORIES"), - "--maven-ca-secret", secretName+"/"+certName) - } +func InstallOperatorWithID(t *testing.T, ctx context.Context, g *WithT, ns, operatorID string) { + lockID.Lock() + defer lockID.Unlock() + os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../") + fmt.Printf("Setting operator ID property as %s\n", operatorID) + ExpectExecSucceed(t, g, + Make(t, + fmt.Sprintf("OPERATOR_ID=%s", operatorID), + "set-install-k8s-ns-operator-id"), + ) - installArgs = append(installArgs, args...) - */ + InstallOperator(t, ctx, g, ns) } func ExpectExecSucceed(t *testing.T, g *WithT, command *exec.Cmd) { diff --git a/install/overlays/kubernetes/namespaced/kustomization.yaml b/install/overlays/kubernetes/namespaced/kustomization.yaml index c5dbe2095..1e824fa3a 100644 --- a/install/overlays/kubernetes/namespaced/kustomization.yaml +++ b/install/overlays/kubernetes/namespaced/kustomization.yaml @@ -23,7 +23,12 @@ resources: namespace: default -# You can provide any required adjustments here. Take the following as references: +patches: +- path: patch-operator-id.yaml + target: + kind: Deployment + + # You can provide any required adjustments here. Take the following as references: # patchesStrategicMerge: # - patch-toleration.yaml # - patch-node-selector.yaml diff --git a/install/overlays/kubernetes/namespaced/kustomization.yaml b/install/overlays/kubernetes/namespaced/patch-operator-id.yaml similarity index 68% copy from install/overlays/kubernetes/namespaced/kustomization.yaml copy to install/overlays/kubernetes/namespaced/patch-operator-id.yaml index c5dbe2095..25c150420 100644 --- a/install/overlays/kubernetes/namespaced/kustomization.yaml +++ b/install/overlays/kubernetes/namespaced/patch-operator-id.yaml @@ -14,21 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: -- ../../../base -- ../../../base/config/rbac/namespaced - -namespace: default - -# You can provide any required adjustments here. Take the following as references: -# patchesStrategicMerge: -# - patch-toleration.yaml -# - patch-node-selector.yaml -# - patch-resource-requirements.yaml -# patches: -# - path: patch-log-level.yaml -# target: -# kind: Deployment \ No newline at end of file +- op: add + path: /spec/template/spec/containers/0/env/2/value + value: camel-k diff --git a/script/Makefile b/script/Makefile index d8a4ae6ea..c6e684b8c 100644 --- a/script/Makefile +++ b/script/Makefile @@ -105,8 +105,8 @@ KAMELET_CATALOG_REPO_TAG := v4.0.1 DO_TEST_PREBUILD ?= true TEST_PREBUILD = build # Tests may run in parallel to each other. This count sets the amount of tests run in parallel. (default value usually is GOMAXPROCS) -TEST_COMMON_PARALLEL_COUNT ?= 2 -TEST_ADVANCED_PARALLEL_COUNT ?= 4 +TEST_COMMON_PARALLEL_COUNT ?= 1 +TEST_ADVANCED_PARALLEL_COUNT ?= 1 # OLM (Operator Lifecycle Manager and Operator Hub): uncomment to override operator settings at build time #GOLDFLAGS += -X github.com/apache/camel-k/v2/pkg/util/olm.DefaultOperatorName=camel-k-operator @@ -278,47 +278,26 @@ setup-knative: # test-common: FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ - go test -p $(TEST_COMMON_PARALLEL_COUNT) -timeout 90m -v ./e2e/common/... -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \ + go test -p $(TEST_COMMON_PARALLEL_COUNT) -timeout 90m -v ./e2e/common/... -tags=integration $(GOTESTFMT) || ((FAILED++)); \ exit $${FAILED} # # Smoke tests are a subset of common tests used to quickly verify the operator # test-smoke: - TEST_SKIP_AFTER_FAILURE_COUNT="$(TEST_SKIP_AFTER_FAILURE_COUNT)"; \ - if [[ $$TEST_SKIP_AFTER_FAILURE_COUNT = "" ]]; then \ - TEST_SKIP_AFTER_FAILURE_COUNT=0; \ - fi; \ FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ - echo "TEST_COMMON_PARALLEL_COUNT=$$TEST_COMMON_PARALLEL_COUNT"; \ - echo "TEST_SKIP_AFTER_FAILURE_COUNT=$$TEST_SKIP_AFTER_FAILURE_COUNT"; \ - go test -timeout 10m -count=1 -v ./e2e/common/main_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \ - if [ $$FAILED -le $$TEST_SKIP_AFTER_FAILURE_COUNT ]; then \ - go test -p=$(TEST_COMMON_PARALLEL_COUNT) -timeout 30m -count=1 -v ./e2e/common/languages -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \ - fi; \ - if [ $$FAILED -le $$TEST_SKIP_AFTER_FAILURE_COUNT ]; then \ - go test -timeout 30m -count=1 -v \ - ./e2e/common/misc/cron_test.go \ - ./e2e/common/misc/kamelet_test.go \ - ./e2e/common/misc/pipe_test.go \ - -tags=integration -parallel=$(TEST_COMMON_PARALLEL_COUNT) $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \ - fi; \ - if [ $$FAILED -le $$TEST_SKIP_AFTER_FAILURE_COUNT ]; then \ - go test -timeout 30m -count=1 -v \ - ./e2e/common/traits/camel_test.go \ - ./e2e/common/traits/container_test.go \ - ./e2e/common/traits/openapi_test.go \ - ./e2e/common/traits/service_test.go \ - -tags=integration -parallel=$(TEST_COMMON_PARALLEL_COUNT) $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \ - fi; \ - exit $$FAILED + go test -p $(TEST_COMMON_PARALLEL_COUNT) -timeout 30m -v \ + ./e2e/common/languages \ + ./e2e/common/traits \ + -tags=integration $(GOTESTFMT) || ((FAILED++)); \ + exit $${FAILED} # # Common tests that require some particular operator setting or need to be installed in multiple namespaces # test-advanced: FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ - go test -p=$(TEST_ADVANCED_PARALLEL_COUNT) -timeout 90m -v ./e2e/advanced -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || ((FAILED++)); \ + go test -p=$(TEST_ADVANCED_PARALLEL_COUNT) -timeout 90m -v ./e2e/advanced -tags=integration $(GOTESTFMT) || ((FAILED++)); \ exit $${FAILED} # @@ -326,52 +305,33 @@ test-advanced: # test-install: FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ - go test -timeout 40m -v ./e2e/install/kustomize -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || ((FAILED++)); \ - go test -timeout 60m -v ./e2e/install/helm -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || ((FAILED++)); \ + go test -timeout 20m -v ./e2e/install/kustomize -tags=integration $(GOTESTFMT) || ((FAILED++)); \ + go test -timeout 20m -v ./e2e/install/helm -tags=integration $(GOTESTFMT) || ((FAILED++)); \ + go test -timeout 20m -v ./e2e/install/olm -tags=integration $(GOTESTFMT) || ((FAILED++)); \ + go test -timeout 60m -v ./e2e/install/upgrade -tags=integration $(GOTESTFMT) || ((FAILED++)); \ exit $${FAILED} -# -# Installation procedure test using OLM (requires cluster to be setup accordingly) -# -test-install-olm: - STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ - go test -timeout 30m -v ./e2e/install/olm -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) - -# -# Upgrade procedure test (requires cluster to be setup accordingly, ie OLM) -# -test-install-upgrade: - STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ - go test -timeout 30m -v ./e2e/install/upgrade -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) - # # Knative tests that require the presence of Knative configuration # test-knative: STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ - go test -timeout 60m -v ./e2e/knative -tags=integration $(TEST_KNATIVE_RUN) $(GOTESTFMT) || ((FAILED++)); \ + go test -timeout 60m -v ./e2e/knative -tags=integration $(GOTESTFMT) || ((FAILED++)); \ exit $${FAILED} -# -# Builder tests that require a custom build strategy -# -test-builder: - STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \ - go test -timeout 30m -v ./e2e/builder -tags=integration $(TEST_BUILDER_RUN) $(GOTESTFMT) - # # Telemetry tests that require the configuration of telemetry endpoints # test-telemetry: STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ - go test -timeout 30m -v ./e2e/telemetry -tags=integration $(TEST_TELEMETRY_RUN) $(GOTESTFMT) + go test -timeout 30m -v ./e2e/telemetry -tags=integration $(GOTESTFMT) # # Quarkus native test (requires certain CPU and memory conditions) # test-quarkus-native: STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" \ - go test -timeout 180m -v ./e2e/native -tags=integration $(TEST_QUARKUS_RUN) $(GOTESTFMT) + go test -timeout 180m -v ./e2e/native -tags=integration $(GOTESTFMT) build-kamel: @echo "####### Building kamel CLI for linux/$(IMAGE_ARCH) architecture..." @@ -779,51 +739,56 @@ DEFAULT_NS = "camel-k" install-operator: @echo "####### Installing operator..." + $(eval KUST_TMP=$(shell mktemp -d)) + @echo "... cloning installation files to $(KUST_TMP)" + cp -Lr install $(KUST_TMP)/. ifndef NAMESPACE @echo "WARN: no namespace specified, using default namespace $(DEFAULT_NS)" $(eval NAMESPACE=$(DEFAULT_NS)) endif - cd $(KUSTOMIZE_DIR) && kustomize edit set namespace $(NAMESPACE) - cd install/overlays/platform && kustomize edit set namespace $(NAMESPACE) - kubectl apply -k $(KUSTOMIZE_DIR) --server-side --force-conflicts + cd $(KUST_TMP)/$(KUSTOMIZE_DIR) && kustomize edit set namespace $(NAMESPACE) + cd $(KUST_TMP)/install/overlays/platform && kustomize edit set namespace $(NAMESPACE) + kubectl apply -k $(KUST_TMP)/$(KUSTOMIZE_DIR) --server-side --force-conflicts install-registry: @echo "####### Installing container registry..." ifdef REGISTRY @echo "INFO: Setting IntegrationPlatform container registry to $(REGISTRY)" - @sed -i 's/address: .*/address: $(REGISTRY)/' install/overlays/platform/integration-platform.yaml - kubectl apply -k install/overlays/platform --server-side -n $(NAMESPACE) --force-conflicts + @sed -i 's/address: .*/address: $(REGISTRY)/' $(KUST_TMP)/install/overlays/platform/integration-platform.yaml + kubectl apply -k $(KUST_TMP)/install/overlays/platform --server-side -n $(NAMESPACE) --force-conflicts else # verify if a minikube registry is existing by any chance, and set it automatically in such a case ifneq ($(MINIKUBE_REGISTRY), "") @echo "INFO: Looks like you're on Minikube. Setting IntegrationPlatform container registry to $(MINIKUBE_REGISTRY)" - @sed -i 's/address: .*/address: $(MINIKUBE_REGISTRY)/' install/overlays/platform/integration-platform.yaml - kubectl apply -k install/overlays/platform --server-side -n $(NAMESPACE) --force-conflicts + @sed -i 's/address: .*/address: $(MINIKUBE_REGISTRY)/' $(KUST_TMP)/install/overlays/platform/integration-platform.yaml + kubectl apply -k $(KUST_TMP)/install/overlays/platform --server-side -n $(NAMESPACE) --force-conflicts endif endif -install-clean-kustomize: -# we must revert any change done by Kustomize in order to avoid they are committed by mistake in source code repository - @echo "INFO: reverting git changes done by Kustomization" - git checkout -- install/overlays/platform/kustomization.yaml - git checkout -- install/overlays/platform/integration-platform.yaml - git checkout -- $(KUSTOMIZE_DIR)/kustomization.yaml +set-install-k8s-ns-operator-id: +ifdef OPERATOR_ID + @echo "INFO: setting operator ID to $(OPERATOR_ID)" + @sed -i 's/name: .*/name: $(OPERATOR_ID)/' install/overlays/platform/integration-platform.yaml + @sed -i 's/value: .*/value: $(OPERATOR_ID)/' install/overlays/kubernetes/namespaced/patch-operator-id.yaml +else + @echo "INFO: no operator ID variable \"OPERATOR_ID\" provided" +endif install-k8s-global: DEFAULT_NS="camel-k" install-k8s-global: KUSTOMIZE_DIR="install/overlays/kubernetes/descoped" -install-k8s-global: install-operator install-registry install-clean-kustomize +install-k8s-global: install-operator install-registry install-k8s-ns: DEFAULT_NS="default" install-k8s-ns: KUSTOMIZE_DIR="install/overlays/kubernetes/namespaced" -install-k8s-ns: install-operator install-registry install-clean-kustomize +install-k8s-ns: install-operator install-registry install-openshift-global: DEFAULT_NS="camel-k" install-openshift-global: KUSTOMIZE_DIR="install/overlays/openshift/descoped" -install-openshift-global: install-operator install-clean-kustomize +install-openshift-global: install-operator install-openshift-ns: DEFAULT_NS="default" install-openshift-ns: KUSTOMIZE_DIR="install/overlays/openshift/namespaced" -install-openshift-ns: install-operator install-clean-kustomize +install-openshift-ns: install-operator uninstall: ifdef NAMESPACE @@ -834,6 +799,9 @@ else kubectl delete configmap,secret,sa,rolebindings,clusterrolebindings,roles,clusterroles,integrationplatform -l app=camel-k endif +install-crds: + kubectl apply -k install/base/config/crd --server-side --force-conflicts + uninstall-crds: kubectl delete crd -l app=camel-k
