This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 6bd525a18ef98dc03696e5d66825043f4ed32fee Author: phantomjinx <[email protected]> AuthorDate: Tue Jan 11 18:08:48 2022 +0000 Break out remaining e2e actions into their own bash scripts * Allows for better control and checking of parameters * Better debugging for scripts to be tested locally --- .github/actions/e2e-builder/action.yml | 30 ++--- .github/actions/e2e-builder/exec-tests.sh | 115 ++++++++++++++++++ .github/actions/e2e-knative-yaks/action.yml | 48 ++++---- .github/actions/e2e-knative-yaks/exec-tests.sh | 118 ++++++++++++++++++ .github/actions/e2e-knative/action.yml | 34 ++---- .github/actions/e2e-knative/exec-tests.sh | 117 ++++++++++++++++++ .github/actions/e2e-upgrade/action.yml | 33 ++---- .github/actions/e2e-upgrade/exec-tests.sh | 124 +++++++++++++++++++ .github/actions/kamel-cleanup/action.yaml | 3 +- .github/actions/kamel-cleanup/cleanup-knative.sh | 69 +++++++++++ .github/actions/kamel-cleanup/cleanup.sh | 41 +++++-- .github/actions/kamel-install-knative/action.yml | 39 +----- .../kamel-install-knative/install-knative.sh | 132 +++++++++++++++++++++ 13 files changed, 755 insertions(+), 148 deletions(-) diff --git a/.github/actions/e2e-builder/action.yml b/.github/actions/e2e-builder/action.yml index a4e814b..d46cc71 100644 --- a/.github/actions/e2e-builder/action.yml +++ b/.github/actions/e2e-builder/action.yml @@ -69,30 +69,18 @@ runs: env: KAMEL_INSTALL_BUILD_PUBLISH_STRATEGY: ${{ inputs.publisher }} run: | - # Cluster environment - export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.build-binary-local-image-name }} - export CUSTOM_VERSION=${{ steps.build-kamel.outputs.build-binary-local-image-version }} - - # - # If bundle has been built and installed then use it - # - if [ -n "${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }}" ]; then - export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ steps.config-cluster.outputs.cluster-image-namespace }} - export KAMEL_INSTALL_OLM_SOURCE=${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} - fi - - export KAMEL_INSTALL_REGISTRY=${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} - export KAMEL_INSTALL_REGISTRY_INSECURE=${{steps.config-cluster.outputs.cluster-image-registry-insecure }} - export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} - export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} - export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} - export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }} - - # Then run integration tests - make test-builder + ./.github/actions/e2e-builder/exec-tests.sh \ + -c "${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }}" \ + -i "${{ steps.config-cluster.outputs.cluster-image-namespace }}" \ + -l "${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }}" \ + -n "${{ steps.build-kamel.outputs.build-binary-local-image-name }}" \ + -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 }}" - name: Cleanup uses: ./.github/actions/kamel-cleanup if: ${{ always() }} with: build-bundle-catalog-source: ${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} diff --git a/.github/actions/e2e-builder/exec-tests.sh b/.github/actions/e2e-builder/exec-tests.sh new file mode 100755 index 0000000..2a20c4b --- /dev/null +++ b/.github/actions/e2e-builder/exec-tests.sh @@ -0,0 +1,115 @@ +#!/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 builder tests +# +#### + +set -e + +while getopts ":c:i:l:n:s:v:x:" opt; do + case "${opt}" in + c) + BUILD_CATALOG_SOURCE=${OPTARG} + ;; + i) + IMAGE_NAMESPACE=${OPTARG} + ;; + l) + REGISTRY_PULL_HOST=${OPTARG} + ;; + n) + IMAGE_NAME=${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 "${IMAGE_NAMESPACE}" ]; then + echo "Error: image-namespace 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 + +# 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}" ]; then + export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${IMAGE_NAMESPACE} + export KAMEL_INSTALL_OLM_SOURCE=${BUILD_CATALOG_SOURCE} +fi + +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" + +export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} +export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} +export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} + +# Then run integration tests +make test-builder diff --git a/.github/actions/e2e-knative-yaks/action.yml b/.github/actions/e2e-knative-yaks/action.yml index df367ae..541cd7c 100644 --- a/.github/actions/e2e-knative-yaks/action.yml +++ b/.github/actions/e2e-knative-yaks/action.yml @@ -66,41 +66,33 @@ runs: with: kube-admin-user-ctx: ${{ steps.config-cluster.outputs.cluster-kube-admin-user-ctx }} + - id: preflight-test + name: Preflight Check Test + uses: ./.github/actions/kamel-preflight-test + with: + build-catalog-source: ${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} + image-registry-host: ${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} + image-name: ${{ steps.build-kamel.outputs.build-binary-local-image-name }} + image-registry-insecure: ${{steps.config-cluster.outputs.cluster-image-registry-insecure }} + image-version: ${{ steps.build-kamel.outputs.build-binary-local-image-version }} + - id: run-it name: Run IT shell: bash run: | - # Cluster environment - export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.build-binary-local-image-name }} - export CUSTOM_VERSION=${{ steps.build-kamel.outputs.build-binary-local-image-version }} - - # - # If bundle has been built and installed then use it - # - if [ -n "${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }}" ]; then - export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ steps.config-cluster.outputs.cluster-image-namespace }} - export KAMEL_INSTALL_OLM_SOURCE=${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} - fi - - export KAMEL_INSTALL_REGISTRY=${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} - export KAMEL_INSTALL_REGISTRY_INSECURE=${{steps.config-cluster.outputs.cluster-image-registry-insecure }} - export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} - export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} - export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} - - # Test options - export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) - export KAMEL_INSTALL_OPERATOR_ENV_VARS=KAMEL_INSTALL_DEFAULT_KAMELETS=false - export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }} - - # Install Yaks globally - yaks install - - # Then run integration tests - yaks test e2e/yaks/common + ./.github/actions/e2e-knative-yaks/exec-tests.sh \ + -c "${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }}" \ + -i "${{ steps.config-cluster.outputs.cluster-image-namespace }}" \ + -l "${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }}" \ + -n "${{ steps.build-kamel.outputs.build-binary-local-image-name }}" \ + -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 }}" - name: Cleanup uses: ./.github/actions/kamel-cleanup if: ${{ always() }} with: build-bundle-catalog-source: ${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} diff --git a/.github/actions/e2e-knative-yaks/exec-tests.sh b/.github/actions/e2e-knative-yaks/exec-tests.sh new file mode 100755 index 0000000..428018a --- /dev/null +++ b/.github/actions/e2e-knative-yaks/exec-tests.sh @@ -0,0 +1,118 @@ +#!/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 knative-yaks tests +# +#### + +set -e + +while getopts ":c:i:l:n:s:v:x:" opt; do + case "${opt}" in + c) + BUILD_CATALOG_SOURCE=${OPTARG} + ;; + i) + IMAGE_NAMESPACE=${OPTARG} + ;; + l) + REGISTRY_PULL_HOST=${OPTARG} + ;; + n) + IMAGE_NAME=${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 "${IMAGE_NAMESPACE}" ]; then + echo "Error: image-namespace 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 + +# 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}" ]; then + export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${IMAGE_NAMESPACE} + export KAMEL_INSTALL_OLM_SOURCE=${BUILD_CATALOG_SOURCE} +fi + +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" + +export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} +export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} +export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} + +# Install Yaks globally +yaks install + +# Then run integration tests +yaks test e2e/yaks/common diff --git a/.github/actions/e2e-knative/action.yml b/.github/actions/e2e-knative/action.yml index ce3658a..54f35f0 100644 --- a/.github/actions/e2e-knative/action.yml +++ b/.github/actions/e2e-knative/action.yml @@ -67,34 +67,18 @@ runs: name: Run IT shell: bash run: | - # Cluster environment - export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.build-binary-local-image-name }} - export CUSTOM_VERSION=${{ steps.build-kamel.outputs.build-binary-local-image-version }} - - # - # If bundle has been built and installed then use it - # - if [ -n "${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }}" ]; then - export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ steps.config-cluster.outputs.cluster-image-namespace }} - export KAMEL_INSTALL_OLM_SOURCE=${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} - fi - - export KAMEL_INSTALL_REGISTRY=${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} - export KAMEL_INSTALL_REGISTRY_INSECURE=${{steps.config-cluster.outputs.cluster-image-registry-insecure }} - export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} - export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} - export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} - - # Test options - export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) - export KAMEL_INSTALL_OPERATOR_ENV_VARS=KAMEL_INSTALL_DEFAULT_KAMELETS=false - export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }} - - # Then run integration tests - make test-knative + ./.github/actions/e2e-knative/exec-tests.sh \ + -c "${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }}" \ + -i "${{ steps.config-cluster.outputs.cluster-image-namespace }}" \ + -l "${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }}" \ + -n "${{ steps.build-kamel.outputs.build-binary-local-image-name }}" \ + -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 }}" - name: Cleanup uses: ./.github/actions/kamel-cleanup if: ${{ always() }} with: build-bundle-catalog-source: ${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} diff --git a/.github/actions/e2e-knative/exec-tests.sh b/.github/actions/e2e-knative/exec-tests.sh new file mode 100755 index 0000000..0053807 --- /dev/null +++ b/.github/actions/e2e-knative/exec-tests.sh @@ -0,0 +1,117 @@ +#!/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 knative tests +# +#### + +set -e + +while getopts ":c:i:l:n:s:v:x:" opt; do + case "${opt}" in + c) + BUILD_CATALOG_SOURCE=${OPTARG} + ;; + i) + IMAGE_NAMESPACE=${OPTARG} + ;; + l) + REGISTRY_PULL_HOST=${OPTARG} + ;; + n) + IMAGE_NAME=${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 "${IMAGE_NAMESPACE}" ]; then + echo "Error: image-namespace 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 + +# 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}" ]; then + export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${IMAGE_NAMESPACE} + export KAMEL_INSTALL_OLM_SOURCE=${BUILD_CATALOG_SOURCE} +fi + +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" + +export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} +export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} +export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS} + +export KAMEL_INSTALL_OPERATOR_ENV_VARS=KAMEL_INSTALL_DEFAULT_KAMELETS=false + +# Then run integration tests +make test-knative diff --git a/.github/actions/e2e-upgrade/action.yml b/.github/actions/e2e-upgrade/action.yml index b968392..7b3b2bf 100644 --- a/.github/actions/e2e-upgrade/action.yml +++ b/.github/actions/e2e-upgrade/action.yml @@ -84,32 +84,19 @@ runs: - name: Run IT shell: bash run: | - # Use the last released Kamel CLI - export RELEASED_KAMEL_BIN=${{ steps.released-kamel-cli.outputs.released-kamel-binary }} - - echo "Kamel version: $(${RELEASED_KAMEL_BIN} version)" - - # Configure install options - export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.build-binary-local-image-name }} - export CUSTOM_VERSION=${{ steps.build-kamel.outputs.build-binary-local-image-version }} - export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) - export KAMEL_INSTALL_REGISTRY=${{ steps.config-cluster.outputs.cluster-image-registry-pull-host }} - export KAMEL_INSTALL_REGISTRY_INSECURE=${{steps.config-cluster.outputs.cluster-image-registry-insecure }} - - # Despite building a bundle we don't want it installed immediately so no OLM_INDEX_BUNDLE var - - # Configure test options - export CAMEL_K_PREV_IIB=quay.io/operatorhubio/catalog:latest - export CAMEL_K_NEW_IIB=${{ steps.build-kamel.outputs.build-bundle-image-bundle-index }} - 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=${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }} - - # Then run integration tests - make test-upgrade + # Note different parameters due to alternative installation + ./.github/actions/e2e-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 }}" \ + -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 }}" - name: Cleanup uses: ./.github/actions/kamel-cleanup if: ${{ always() }} with: build-bundle-catalog-source: ${{ steps.build-kamel.outputs.build-bundle-catalog-source-name }} + image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }} diff --git a/.github/actions/e2e-upgrade/exec-tests.sh b/.github/actions/e2e-upgrade/exec-tests.sh new file mode 100755 index 0000000..78835f3 --- /dev/null +++ b/.github/actions/e2e-upgrade/exec-tests.sh @@ -0,0 +1,124 @@ +#!/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: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} + ;; + 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_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 +make test-upgrade diff --git a/.github/actions/kamel-cleanup/action.yaml b/.github/actions/kamel-cleanup/action.yaml index cace15a..0d6d2e1 100644 --- a/.github/actions/kamel-cleanup/action.yaml +++ b/.github/actions/kamel-cleanup/action.yaml @@ -36,4 +36,5 @@ runs: run: | ./.github/actions/kamel-cleanup/cleanup.sh \ -c "${{ inputs.build-bundle-catalog-source }}" \ - -i "${{ inputs.image-namespace }}" + -i "${{ inputs.image-namespace }}" \ + -x "${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }}" diff --git a/.github/actions/kamel-cleanup/cleanup-knative.sh b/.github/actions/kamel-cleanup/cleanup-knative.sh new file mode 100755 index 0000000..9b50296 --- /dev/null +++ b/.github/actions/kamel-cleanup/cleanup-knative.sh @@ -0,0 +1,69 @@ +#!/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. +# --------------------------------------------------------------------------- + +#### +# +# Perform a cleanup of knative installation +# +#### +set +e + +cleanup_resources() { + local kind="${1}" + local needle="${2}" + + # Stops "Resource not found message" and exit code to 0 + local result=$(kubectl --ignore-not-found=true get ${kind} | grep ${needle}) + if [ $? == 0 ]; then + names=$(echo "${result}" | awk '{print $1}') + for r in ${names} + do + # Timeout after 10 minutes + kubectl delete --now --timeout=600s ${kind} ${r} 1> /dev/null + done + fi + + echo "Done" +} + +# Remove any namespaces +echo -n "Removing testing knative namespaces ... " +cleanup_resources ns 'knative-eventing\|knative-serving\|kourier-system' + +# Mutating webhooks +echo -n "Removing testing knative mutating webhooks ... " +cleanup_resources MutatingWebhookConfiguration 'knative.dev' + +# Validating webhooks +echo -n "Removing testing knative validating webhooks ... " +cleanup_resources ValidatingWebhookConfiguration 'knative.dev' + +# Cluster Role Bindings +echo -n "Removing testing knative cluster role bindings ... " +cleanup_resources clusterrolebindings 'kourier\|knative\|imc' + +# Cluster Roles +echo -n "Removing testing knative cluster roles ... " +cleanup_resources clusterroles 'knative\|imc' + +# CRDS +echo -n "Removing testing knative CRDs ... " +cleanup_resources crds 'knative.dev' + +set -e diff --git a/.github/actions/kamel-cleanup/cleanup.sh b/.github/actions/kamel-cleanup/cleanup.sh index 3a5b4aa..47e48e7 100755 --- a/.github/actions/kamel-cleanup/cleanup.sh +++ b/.github/actions/kamel-cleanup/cleanup.sh @@ -25,7 +25,7 @@ set -e -while getopts ":c:i:" opt; do +while getopts ":c:i:x:" opt; do case "${opt}" in c) BUILD_CATALOG_SOURCE=${OPTARG} @@ -33,6 +33,9 @@ while getopts ":c:i:" opt; do i) IMAGE_NAMESPACE=${OPTARG} ;; + x) + SAVE_NAMESPACES=${OPTARG} + ;; :) echo "ERROR: Option -$OPTARG requires an argument" exit 1 @@ -45,6 +48,12 @@ while getopts ":c:i:" opt; do done shift $((OPTIND-1)) + +if [ "${SAVE_NAMESPACES}" == "true" ]; then + echo "Skipping cleanup since SAVE_NAMESPACES has been set to true" + exit 0 +fi + # # Remove installed kamel # @@ -59,6 +68,7 @@ kubectl get crds | grep camel | awk '{print $1}' | xargs kubectl delete crd &> / set -e if [ -n "${IMAGE_NAMESPACE}" ]; then + echo -n "Removing compiled image streams ... " imgstreams="camel-k camel-k-bundle camel-k-iib" set +e for cis in ${imgstreams} @@ -69,21 +79,28 @@ if [ -n "${IMAGE_NAMESPACE}" ]; then fi done set -e + echo "Done" fi # # Remove Catalog Source # -if [ -z "${BUILD_CATALOG_SOURCE}" ]; then - # Catalog source never defined so nothing to do - exit 0 -fi +if [ -n "${BUILD_CATALOG_SOURCE}" ]; then + set +e + echo -n "Removing testing catalogsource ... " + kubectl get catalogsource --all-namespaces | \ + grep ${BUILD_CATALOG_SOURCE} | awk {'print $1'} | \ + xargs kubectl delete CatalogSource &> /dev/null + if [ $? == 0 ]; then + echo "Done" + else + echo + fi + set -e +fi -set +e -CATALOG_NS=$(kubectl get catalogsource --all-namespaces | grep ${BUILD_CATALOG_SOURCE} | awk {'print $1'}) -for ns in ${CATALOG_NS} -do - kubectl delete CatalogSource ${BUILD_CATALOG_SOURCE} -n ${ns} -done -set -e +# +# Remove KNative resources +# +./.github/actions/kamel-cleanup/cleanup-knative.sh diff --git a/.github/actions/kamel-install-knative/action.yml b/.github/actions/kamel-install-knative/action.yml index 4b33123..40f647d 100644 --- a/.github/actions/kamel-install-knative/action.yml +++ b/.github/actions/kamel-install-knative/action.yml @@ -23,41 +23,4 @@ runs: - name: Install Knative shell: bash run: | - # Prerequisites - sudo wget https://github.com/mikefarah/yq/releases/download/v4.9.6/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq - - export SERVING_VERSION=knative-v1.1.0 - export EVENTING_VERSION=knative-v1.1.0 - export KOURIER_VERSION=knative-v1.1.0 - - # Serving - kubectl apply --filename https://github.com/knative/serving/releases/download/$SERVING_VERSION/serving-crds.yaml - curl -L -s https://github.com/knative/serving/releases/download/$SERVING_VERSION/serving-core.yaml | head -n -1 | yq e 'del(.spec.template.spec.containers[].resources)' - | kubectl apply -f - - - # Kourier - kubectl apply --filename https://github.com/knative-sandbox/net-kourier/releases/download/$KOURIER_VERSION/kourier.yaml - kubectl patch configmap/config-network \ - --namespace knative-serving \ - --type merge \ - --patch '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}' - - # Eventing - kubectl apply --filename https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/eventing-crds.yaml - curl -L -s https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/eventing-core.yaml | head -n -1 | yq e 'del(.spec.template.spec.containers[].resources)' - | kubectl apply -f - - - # Eventing channels - curl -L -s https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/in-memory-channel.yaml | head -n -1 | yq e 'del(.spec.template.spec.containers[].resources)' - | kubectl apply -f - - - # Eventing broker - curl -L -s https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/mt-channel-broker.yaml | head -n -1 | yq e 'del(.spec.template.spec.containers[].resources)' - | kubectl apply -f - - - # Eventing sugar controller for injection - kubectl apply -f https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/eventing-sugar-controller.yaml - - # Wait for installation completed - echo "Waiting for all pods to be ready in kourier-system" - kubectl wait --for=condition=Ready pod --all -n kourier-system --timeout=60s - echo "Waiting for all pods to be ready in knative-serving" - kubectl wait --for=condition=Ready pod --all -n knative-serving --timeout=60s - echo "Waiting for all pods to be ready in knative-eventing" - kubectl wait --for=condition=Ready pod --all -n knative-eventing --timeout=60s + ./.github/actions/kamel-install-knative/install-knative.sh diff --git a/.github/actions/kamel-install-knative/install-knative.sh b/.github/actions/kamel-install-knative/install-knative.sh new file mode 100755 index 0000000..8491612 --- /dev/null +++ b/.github/actions/kamel-install-knative/install-knative.sh @@ -0,0 +1,132 @@ +#!/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. +# --------------------------------------------------------------------------- + +#### +# +# Install the knative setup +# +#### + +set -e + +# Prerequisites +sudo wget https://github.com/mikefarah/yq/releases/download/v4.9.6/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq + +set +e + +export SERVING_VERSION=knative-v1.1.0 +export EVENTING_VERSION=knative-v1.1.0 +export KOURIER_VERSION=knative-v1.1.0 + +apply() { + local file="${1:-}" + if [ -z "${file}" ]; then + echo "Error: Cannot apply. No file." + exit 1 + fi + + kubectl apply --filename ${file} + if [ $? != 0 ]; then + sleep 5 + echo "Re-applying ${file} ..." + kubectl apply --filename ${file} + if [ $? != 0 ]; then + echo "Error: Application of resource failed." + exit 1 + fi + fi +} + +SERVING_CRDS="https://github.com/knative/serving/releases/download/${SERVING_VERSION}/serving-crds.yaml" +SERVING_CORE="https://github.com/knative/serving/releases/download/${SERVING_VERSION}/serving-core.yaml" +KOURIER="https://github.com/knative-sandbox/net-kourier/releases/download/${KOURIER_VERSION}/kourier.yaml" +EVENTING_CRDS="https://github.com/knative/eventing/releases/download/${EVENTING_VERSION}/eventing-crds.yaml" +EVENTING_CORE="https://github.com/knative/eventing/releases/download/${EVENTING_VERSION}/eventing-core.yaml" +IN_MEMORY_CHANNEL="https://github.com/knative/eventing/releases/download/${EVENTING_VERSION}/in-memory-channel.yaml" +CHANNEL_BROKER="https://github.com/knative/eventing/releases/download/${EVENTING_VERSION}/mt-channel-broker.yaml" +SUGAR_CONTROLLER="https://github.com/knative/eventing/releases/download/${EVENTING_VERSION}/eventing-sugar-controller.yaml" + +# Serving +apply "${SERVING_CRDS}" + +YAML=$(mktemp serving-core-XXX.yaml) +curl -L -s ${SERVING_CORE} | head -n -1 | yq e 'del(.spec.template.spec.containers[].resources)' - > ${YAML} +if [ -s ${YAML} ]; then + apply ${YAML} + echo "Waiting for pods to be ready in knative-serving (dependency for kourier)" + kubectl wait --for=condition=Ready pod --all -n knative-serving --timeout=60s +else + echo "Error: Failed to correctly download ${SERVING_CORE}" + exit 1 +fi + +# Kourier +apply "${KOURIER}" + +kubectl patch configmap/config-network \ + --namespace knative-serving \ + --type merge \ + --patch '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}' +if [ $? != 0 ]; then + echo "Error: Failed to patch configmap" + exit 1 +fi + +# Eventing +apply "${EVENTING_CRDS}" + +YAML=$(mktemp eventing-XXX.yaml) +curl -L -s ${EVENTING_CORE} | head -n -1 | yq e 'del(.spec.template.spec.containers[].resources)' - > ${YAML} +if [ -s ${YAML} ]; then + apply ${YAML} +else + echo "Error: Failed to correctly download ${SERVING_CORE}" + exit 1 +fi + +# Eventing channels +YAML=$(mktemp in-memory-XXX.yaml) +curl -L -s ${IN_MEMORY_CHANNEL} | head -n -1 | yq e 'del(.spec.template.spec.containers[].resources)' - > ${YAML} +if [ -s ${YAML} ]; then + apply ${YAML} +else + echo "Error: Failed to correctly download ${SERVING_CORE}" + exit 1 +fi + +# Eventing broker +YAML=$(mktemp channel-broker-XXX.yaml) +curl -L -s ${CHANNEL_BROKER} | head -n -1 | yq e 'del(.spec.template.spec.containers[].resources)' - > ${YAML} +if [ -s ${YAML} ]; then + apply ${YAML} +else + echo "Error: Failed to correctly download ${SERVING_CORE}" + exit 1 +fi + +# Eventing sugar controller for injection +apply ${SUGAR_CONTROLLER} + +# Wait for installation completed +echo "Waiting for all pods to be ready in kourier-system" +kubectl wait --for=condition=Ready pod --all -n kourier-system --timeout=60s +echo "Waiting for all pods to be ready in knative-serving" +kubectl wait --for=condition=Ready pod --all -n knative-serving --timeout=60s +echo "Waiting for all pods to be ready in knative-eventing" +kubectl wait --for=condition=Ready pod --all -n knative-eventing --timeout=60s
