Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(e2e): split upgrade from install #4454

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/actions/e2e-install-upgrade/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
131 changes: 131 additions & 0 deletions .github/actions/e2e-install-upgrade/exec-tests.sh
Original file line number Diff line number Diff line change
@@ -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
26 changes: 25 additions & 1 deletion .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package olm
package upgrade

import (
"os"
Expand All @@ -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())
Expand Down
28 changes: 28 additions & 0 deletions e2e/install/upgrade/files/yaml.yaml
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package olm
package upgrade

import (
"fmt"
Expand All @@ -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")
Expand Down
Loading