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 2022/04/18 09:18:10 UTC
[camel-k] 07/12: Fixes preflight e2e test by adding new build to stable channel
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 e2542ea3c4b7152e3f65fc54f82628a8064f70d3
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Mon Mar 14 15:08:50 2022 +0000
Fixes preflight e2e test by adding new build to stable channel
* build-index-image.sh
* Instead of adding new build to its own channel (not default), add it to
the stable channel by updating the catalog entries for camel-k in the
downloaded bundles.yaml (needs some sed magic to correctly identify the
correct section)
* Uses CSV name which is retrieved from the Makefile
* Requires extra parameters for csv name and last-released image reference
* Makefile
* Expose csv name to make available for e2e scripts
---
.github/actions/kamel-build-bundle/action.yaml | 5 +-
.../kamel-build-bundle/build-index-image.sh | 60 +++++++++++++++++++++-
.../actions/kamel-preflight-test/preflight-test.sh | 11 +++-
script/Makefile | 6 ++-
4 files changed, 78 insertions(+), 4 deletions(-)
diff --git a/.github/actions/kamel-build-bundle/action.yaml b/.github/actions/kamel-build-bundle/action.yaml
index b61da1231..5f25efe2d 100644
--- a/.github/actions/kamel-build-bundle/action.yaml
+++ b/.github/actions/kamel-build-bundle/action.yaml
@@ -74,7 +74,10 @@ runs:
-l "${{ inputs.image-registry-pull-host }}" \
-n "${{ inputs.local-image-name }}" \
-s "${{ inputs.image-registry-push-host }}" \
- -v "${{ inputs.local-image-version }}"
+ -v "${{ inputs.local-image-version }}" \
+ -x "$(make get-csv-name)" \
+ -y "$(make get-last-released-img-name)" \
+ -z "$(make get-last-released-version)"
- id: build-image-catalog
name: Create a new catalog to host the index image
diff --git a/.github/actions/kamel-build-bundle/build-index-image.sh b/.github/actions/kamel-build-bundle/build-index-image.sh
index 1fdd22f95..bfad918f0 100755
--- a/.github/actions/kamel-build-bundle/build-index-image.sh
+++ b/.github/actions/kamel-build-bundle/build-index-image.sh
@@ -25,7 +25,7 @@
set -e
-while getopts ":b:i:l:n:s:v:" opt; do
+while getopts ":b:i:l:n:s:v:x:y:z:" opt; do
case "${opt}" in
b)
BUNDLE_IMAGE=${OPTARG}
@@ -45,6 +45,15 @@ while getopts ":b:i:l:n:s:v:" opt; do
v)
IMAGE_VERSION=${OPTARG}
;;
+ x)
+ CSV_NAME=${OPTARG}
+ ;;
+ y)
+ IMAGE_LAST_NAME=${OPTARG}
+ ;;
+ z)
+ IMAGE_LAST_VERSION=${OPTARG}
+ ;;
:)
echo "ERROR: Option -$OPTARG requires an argument"
exit 1
@@ -67,11 +76,21 @@ if [ -z "${IMAGE_NAME}" ]; then
exit 1
fi
+if [ -z "${IMAGE_LAST_NAME}" ]; then
+ echo "Error: local-image-last-name not defined"
+ exit 1
+fi
+
if [ -z "${IMAGE_VERSION}" ]; then
echo "Error: local-image-version not defined"
exit 1
fi
+if [ -z "${IMAGE_LAST_VERSION}" ]; then
+ echo "Error: local-image-last-version not defined"
+ exit 1
+fi
+
if [ -z "${IMAGE_NAMESPACE}" ]; then
echo "Error: image-namespace not defined"
exit 1
@@ -87,6 +106,11 @@ if [ -z "${REGISTRY_PULL_HOST}" ]; then
exit 1
fi
+if [ -z "${CSV_NAME}" ]; then
+ echo "Error: csv-name not defined"
+ exit 1
+fi
+
export LOCAL_IIB=${REGISTRY_PUSH_HOST}/${IMAGE_NAMESPACE}/camel-k-iib:${IMAGE_VERSION}
if ! command -v opm &> /dev/null
then
@@ -179,6 +203,10 @@ fi
mkdir ${CATALOG_DIR}
opm render quay.io/operatorhubio/catalog:latest -o yaml > ${CATALOG_DIR}/bundles.yaml
opm render --use-http -o yaml ${BUNDLE_IMAGE} > ${CATALOG_DIR}/camel-k.yaml
+
+#
+# Add the dedicated stable-dev branch (needed for upgrade tests)
+#
cat << EOF >> ${CATALOG_DIR}/camel-k.yaml
---
schema: olm.channel
@@ -188,6 +216,36 @@ entries:
- name: camel-k.v$(make get-version | grep -Po "\d.\d.\d")
replaces: $(make get-last-released-img-name).v$(make get-last-released-version | grep -Po "\d.\d.\d")
EOF
+
+#
+# Update the existing stable channel (needed for preflight and tests on OCP)
+#
+sedtemp=$(mktemp sed-template-XXX.sed)
+cat << EOF > ${sedtemp}
+/- name: ${IMAGE_LAST_NAME}.v${IMAGE_LAST_VERSION}/ {
+ p;
+ n;
+ / replaces:/ {
+ p;
+ n;
+ /name: stable$/ {
+ i- name: ${CSV_NAME}
+ i\ \ replaces: ${IMAGE_LAST_NAME}.v${IMAGE_LAST_VERSION}
+ p;
+ d;
+ }
+ }
+}
+p;
+EOF
+
+sed -i -n -f ${sedtemp} ${CATALOG_DIR}/bundles.yaml
+
+rm -f ${sedtemp}
+
+#
+# Validate the modified catalog
+#
opm validate ${CATALOG_DIR}
opm generate dockerfile ${CATALOG_DIR}
if [ ! -f catalog.Dockerfile ]; then
diff --git a/.github/actions/kamel-preflight-test/preflight-test.sh b/.github/actions/kamel-preflight-test/preflight-test.sh
index d210e46da..f85e41ef7 100755
--- a/.github/actions/kamel-preflight-test/preflight-test.sh
+++ b/.github/actions/kamel-preflight-test/preflight-test.sh
@@ -110,6 +110,15 @@ export CUSTOM_VERSION=${IMAGE_VERSION}
#
has_olm="false"
if [ -n "${BUILD_CATALOG_SOURCE}" ]; then
+ #
+ # Check catalog source is actually available
+ #
+ STATE=$(kubectl get catalogsource ${BUILD_CATALOG_SOURCE} -n ${IMAGE_NAMESPACE} -o=jsonpath='{.status.connectionState.lastObservedState}')
+ if [ "${STATE}" != "READY" ]; then
+ echo "Error: catalog source status is not ready."
+ exit 1
+ fi
+
export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${IMAGE_NAMESPACE}
export KAMEL_INSTALL_OLM_SOURCE=${BUILD_CATALOG_SOURCE}
has_olm="true"
@@ -166,7 +175,7 @@ src_commit=$(git rev-parse HEAD)
# Test whether the versions are the same
#
if [ "${camel_op_version}" != "${IMAGE_VERSION}" ]; then
- echo "Preflight Test: Failure - Installed operator version (${camel_op_version} does not match expected version (${IMAGE_VERSION})"
+ echo "Preflight Test: Failure - Installed operator version ${camel_op_version} does not match expected version (${IMAGE_VERSION})"
exit 1
fi
diff --git a/script/Makefile b/script/Makefile
index 58681eaa0..76c6b425c 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -53,6 +53,7 @@ CHANNELS ?= $(OPERATOR_VERSION),candidate,stable,latest
DEFAULT_CHANNEL ?= $(OPERATOR_VERSION)
PACKAGE := camel-k
CSV_VERSION := $(CUSTOM_VERSION:-SNAPSHOT=)
+CSV_NAME := $(PACKAGE).v$(CSV_VERSION)
CSV_DISPLAY_NAME := Camel K Operator
CSV_SUPPORT := Camel
CSV_REPLACES := $(LAST_RELEASED_IMAGE_NAME).v$(LAST_RELEASED_VERSION)
@@ -336,6 +337,9 @@ get-last-released-img-name:
get-last-released-version:
@echo $(LAST_RELEASED_VERSION)
+get-csv-name:
+ @echo $(CSV_NAME)
+
set-version:
./script/set_version.sh $(CUSTOM_VERSION) $(CUSTOM_IMAGE)
@@ -491,7 +495,7 @@ pre-bundle:
@sed -i 's/projectName: .*/projectName: $(PACKAGE)/' PROJECT
@sed -i 's~^ containerImage: .*~ containerImage: $(CUSTOM_IMAGE):$(CUSTOM_VERSION)~' $(CSV_PATH)
@sed -i 's/^ support: .*/ support: $(CSV_SUPPORT)/' $(CSV_PATH)
- @sed -i 's/^ name: .*.\(v.*\)/ name: $(PACKAGE).v$(CSV_VERSION)/' $(CSV_PATH)
+ @sed -i 's/^ name: .*.\(v.*\)/ name: $(CSV_NAME)/' $(CSV_PATH)
@sed -i 's/^ displayName: .*/ displayName: $(CSV_DISPLAY_NAME)/' $(CSV_PATH)
@sed -i 's/^ replaces: .*/ replaces: $(CSV_REPLACES)/' $(CSV_PATH)
@sed -i 's/^ version: .*/ version: $(CSV_VERSION)/' $(CSV_PATH)