You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/06/02 09:49:39 UTC

[camel-k] branch main updated: chore(ci): split upgrade from install

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


The following commit(s) were added to refs/heads/main by this push:
     new 289cacfca chore(ci): split upgrade from install
289cacfca is described below

commit 289cacfcab1cf701e257ea39c3d21833cd0ceddf
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Jun 2 10:25:46 2023 +0200

    chore(ci): split upgrade from install
---
 .github/actions/e2e-install-upgrade/action.yml     | 125 ++++++++++++++++++++
 .github/actions/e2e-install-upgrade/exec-tests.sh  | 131 +++++++++++++++++++++
 .github/workflows/install.yml                      |  26 +++-
 .../cli_upgrade_test.go}                           |   4 +-
 e2e/install/upgrade/files/yaml.yaml                |  28 +++++
 e2e/install/{olm => upgrade}/olm_upgrade_test.go   |   4 +-
 script/Makefile                                    |  21 ++--
 7 files changed, 327 insertions(+), 12 deletions(-)

diff --git a/.github/actions/e2e-install-upgrade/action.yml b/.github/actions/e2e-install-upgrade/action.yml
new file mode 100644
index 000000000..b80959e38
--- /dev/null
+++ b/.github/actions/e2e-install-upgrade/action.yml
@@ -0,0 +1,125 @@
+# ---------------------------------------------------------------------------
+# 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
+
+  #
+  # Try and ensure the cluster is in a vanilla state before
+  # starting in on an installation
+  #
+  - id: pre-clean-cluster
+    name: Pre Clean Cluster
+    uses: ./.github/actions/kamel-cleanup
+    if: ${{ always() }}
+    with:
+      catalog-source-name: ${{ steps.config-cluster.outputs.cluster-catalog-source-name }}
+      catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }}
+      image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }}
+      global-operator-namespace: ${{ steps.config-cluster.outputs.cluster-global-operator-namespace }}
+
+  - 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-64bit.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 }}
+
+  - id: report-problematic
+    name: List Tests Marked As Problematic
+    uses: ./.github/actions/kamel-report-problematic
+    with:
+      test-suite: namespace/upgrade
+
+  - 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 }}"
+
+  - name: Cleanup
+    uses: ./.github/actions/kamel-cleanup
+    if: ${{ always() }}
+    with:
+      catalog-source-name: ${{ steps.config-cluster.outputs.cluster-catalog-source-name }}
+      catalog-source-namespace: ${{ steps.config-cluster.outputs.cluster-catalog-source-namespace }}
+      image-namespace: ${{ steps.config-cluster.outputs.cluster-image-namespace }}
+      global-operator-namespace: ${{ steps.config-cluster.outputs.cluster-global-operator-namespace }}
diff --git a/.github/actions/e2e-install-upgrade/exec-tests.sh b/.github/actions/e2e-install-upgrade/exec-tests.sh
new file mode 100755
index 000000000..a3cd9414e
--- /dev/null
+++ b/.github/actions/e2e-install-upgrade/exec-tests.sh
@@ -0,0 +1,131 @@
+#!/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/workflows/install.yml b/.github/workflows/install.yml
index 1cc259020..26670160d 100644
--- a/.github/workflows/install.yml
+++ b/.github/workflows/install.yml
@@ -111,8 +111,32 @@ jobs:
           -q "${{ github.event.inputs.log-level }}" \
           -t "${{ github.event.inputs.test-filters }}"
 
-    - name: Install and upgrade test (OLM)
+    - 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@v2
+      with:
+        persist-credentials: false
+        submodules: recursive
+    - name: Convert input parameters to env vars
+      shell: bash
+      run: |
+        ./.github/workflows/manual-exec-process-inputs.sh \
+          -i "${{ github.event.inputs.pre-built-kamel-image }}" \
+          -p "${{ github.event.inputs.skip-problematic }}" \
+          -q "${{ github.event.inputs.log-level }}" \
+          -t "${{ github.event.inputs.test-filters }}"
+
+    - name: Upgrade
+      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/e2e/install/olm/upgrade_test.go b/e2e/install/upgrade/cli_upgrade_test.go
similarity index 98%
rename from e2e/install/olm/upgrade_test.go
rename to e2e/install/upgrade/cli_upgrade_test.go
index 3e73b377e..c7279d976 100644
--- a/e2e/install/olm/upgrade_test.go
+++ b/e2e/install/upgrade/cli_upgrade_test.go
@@ -20,7 +20,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-package olm
+package upgrade
 
 import (
 	"os"
@@ -37,7 +37,7 @@ import (
 )
 
 // WARNING: this test is not OLM specific but needs certain setting we provide in OLM installation scenario
-func TestOperatorUpgrade(t *testing.T) {
+func TestCLIOperatorUpgrade(t *testing.T) {
 	WithNewTestNamespace(t, func(ns string) {
 		version, ok := os.LookupEnv("KAMEL_K_TEST_RELEASE_VERSION")
 		Expect(ok).To(BeTrue())
diff --git a/e2e/install/upgrade/files/yaml.yaml b/e2e/install/upgrade/files/yaml.yaml
new file mode 100644
index 000000000..9ccf65273
--- /dev/null
+++ b/e2e/install/upgrade/files/yaml.yaml
@@ -0,0 +1,28 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+- from:
+    uri: "timer:yaml"
+    parameters:
+      period: "5000"
+    steps:
+      - set-header:
+          name: "m"
+          constant: "string!"
+      - set-body:
+          simple: "Magic${header.m}"
+      - to: "log:info"
diff --git a/e2e/install/olm/olm_upgrade_test.go b/e2e/install/upgrade/olm_upgrade_test.go
similarity index 99%
rename from e2e/install/olm/olm_upgrade_test.go
rename to e2e/install/upgrade/olm_upgrade_test.go
index 8b0a4fe5d..29276ae96 100644
--- a/e2e/install/olm/olm_upgrade_test.go
+++ b/e2e/install/upgrade/olm_upgrade_test.go
@@ -20,7 +20,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-package olm
+package upgrade
 
 import (
 	"fmt"
@@ -47,7 +47,7 @@ import (
 
 const catalogSourceName = "test-camel-k-source"
 
-func TestOLMAutomaticUpgrade(t *testing.T) {
+func TestOLMOperatorUpgrade(t *testing.T) {
 	prevIIB := os.Getenv("CAMEL_K_PREV_IIB")
 	newIIB := os.Getenv("CAMEL_K_NEW_IIB")
 	kamel := os.Getenv("RELEASED_KAMEL_BIN")
diff --git a/script/Makefile b/script/Makefile
index 51c3834d2..83e747163 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -262,13 +262,13 @@ test-fmt: do-build
 #
 test-common: do-build
 	FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \
-	go test -timeout 30m -v ./e2e/common/support/startup_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
+	go test -timeout 10m -v ./e2e/common/support/startup_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
 	go test -timeout 30m -v ./e2e/common/languages -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
 	go test -timeout 30m -v ./e2e/common/cli -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
 	go test -timeout 30m -v ./e2e/common/config -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
 	go test -timeout 30m -v ./e2e/common/misc -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
 	go test -timeout 30m -v ./e2e/common/traits -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
-	go test -timeout 30m -v ./e2e/common/support/teardown_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
+	go test -timeout 10m -v ./e2e/common/support/teardown_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
 	exit $${FAILED}
 
 #
@@ -284,8 +284,8 @@ test-common-with-custom-install: do-build
 #
 test-install: do-build
 	FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \
-	go test -timeout 60m -v ./e2e/install/cli -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \
-	go test -timeout 60m -v ./e2e/install/kustomize -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \
+	go test -timeout 40m -v ./e2e/install/cli -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \
+	go test -timeout 40m -v ./e2e/install/kustomize -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || FAILED=1; \
 	exit $${FAILED}
 
 #
@@ -293,16 +293,23 @@ test-install: do-build
 #
 test-install-olm: do-build
 	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \
-	go test -timeout 60m -v ./e2e/install/olm -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT)
+	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: do-build
+	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: do-build
 	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \
-	go test -timeout 30m -v ./e2e/knative/support/startup_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
+	go test -timeout 10m -v ./e2e/knative/support/startup_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
 	go test -timeout 60m -v ./e2e/knative -tags=integration $(TEST_KNATIVE_RUN) $(GOTESTFMT) || FAILED=1; \
-	go test -timeout 30m -v ./e2e/knative/support/teardown_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
+	go test -timeout 10m -v ./e2e/knative/support/teardown_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || FAILED=1; \
 	exit $${FAILED}
 
 #