diff --git a/Makefile b/Makefile index e1b02931c..c6fd985f0 100644 --- a/Makefile +++ b/Makefile @@ -684,42 +684,42 @@ create-operatorgroup: ## Creates operator group create-subscription: SHELL := /bin/bash create-subscription: ## Creates subscription [[ -z "$(NAME)" ]] && { echo [ERROR] NAME not defined; exit 1; } - [[ -z "$(NAMESPACE)" ]] && DEFINED_NAMESPACE="openshift-operators" || DEFINED_NAMESPACE=$(NAMESPACE) + [[ -z "$(NAMESPACE)" ]] && { echo [ERROR] NAMESPACE not defined; exit 1; } [[ -z "$(CHANNEL)" ]] && { echo [ERROR] CHANNEL not defined; exit 1; } [[ -z "$(INSTALL_PLAN_APPROVAL)" ]] && { echo [ERROR] INSTALL_PLAN_APPROVAL not defined; exit 1; } [[ -z "$(PACKAGE_NAME)" ]] && { echo [ERROR] PACKAGE_NAME not defined; exit 1; } [[ -z "$(SOURCE)" ]] && { echo [ERROR] SOURCE not defined; exit 1; } - [[ -z "$(SOURCE_NAMESPACE)" ]] && DEFINED_SOURCE_NAMESPACE="openshift-marketplace" || DEFINED_SOURCE_NAMESPACE=$(SOURCE_NAMESPACE) + [[ -z "$(SOURCE_NAMESPACE)" ]] && { echo [ERROR] SOURCE_NAMESPACE not defined; exit 1; } echo '{ "apiVersion": "operators.coreos.com/v1alpha1", "kind": "Subscription", "metadata": { "name": "$(NAME)", - "namespace": "'$${DEFINED_NAMESPACE}'" + "namespace": "$(NAMESPACE)" }, "spec": { "channel": "$(CHANNEL)", "installPlanApproval": "$(INSTALL_PLAN_APPROVAL)", "name": "$(PACKAGE_NAME)", "source": "$(SOURCE)", - "sourceNamespace": "'$${DEFINED_SOURCE_NAMESPACE}'", + "sourceNamespace": "$(SOURCE_NAMESPACE)", "startingCSV": "$(STARTING_CSV)" } }' | $(K8S_CLI) apply -f - - if [[ ${INSTALL_PLAN_APPROVAL} == "Manual" ]]; then - $(K8S_CLI) wait subscription $(NAME) -n $${DEFINED_NAMESPACE} --for=condition=InstallPlanPending --timeout=60s + if [[ $(INSTALL_PLAN_APPROVAL) == "Manual" ]]; then + $(K8S_CLI) wait subscription $(NAME) -n $(NAMESPACE) --for=condition=InstallPlanPending --timeout=60s fi approve-installplan: SHELL := /bin/bash approve-installplan: ## Approves install plan [[ -z "$(SUBSCRIPTION_NAME)" ]] && { echo [ERROR] SUBSCRIPTION_NAME not defined; exit 1; } - [[ -z "$(NAMESPACE)" ]] && DEFINED_NAMESPACE="openshift-operators" || DEFINED_NAMESPACE=$(NAMESPACE) + [[ -z "$(NAMESPACE)" ]] && { echo [ERROR] NAMESPACE not defined; exit 1; } - INSTALL_PLAN_NAME=$$($(K8S_CLI) get subscription $(SUBSCRIPTION_NAME) -n $${DEFINED_NAMESPACE} -o jsonpath='{.status.installplan.name}') - $(K8S_CLI) patch installplan $${INSTALL_PLAN_NAME} -n $${DEFINED_NAMESPACE} --type=merge -p '{"spec":{"approved":true}}' - $(K8S_CLI) wait installplan $${INSTALL_PLAN_NAME} -n $${DEFINED_NAMESPACE} --for=condition=Installed --timeout=240s + INSTALL_PLAN_NAME=$$($(K8S_CLI) get subscription $(SUBSCRIPTION_NAME) -n $(NAMESPACE) -o jsonpath='{.status.installplan.name}') + $(K8S_CLI) patch installplan $${INSTALL_PLAN_NAME} -n $(NAMESPACE) --type=merge -p '{"spec":{"approved":true}}' + $(K8S_CLI) wait installplan $${INSTALL_PLAN_NAME} -n $(NAMESPACE) --for=condition=Installed --timeout=240s create-namespace: SHELL := /bin/bash create-namespace: ## Creates namespace @@ -754,7 +754,14 @@ install-devworkspace: ## Install Dev Workspace operator, available channels: nex fi $(MAKE) create-catalogsource IMAGE="$${IMAGE}" NAME="devworkspace-operator" - $(MAKE) create-subscription NAME="devworkspace-operator" PACKAGE_NAME="devworkspace-operator" CHANNEL="$(CHANNEL)" SOURCE="devworkspace-operator" INSTALL_PLAN_APPROVAL="Auto" + $(MAKE) create-subscription \ + NAME="devworkspace-operator" \ + NAMESPACE="openshift-operators" \ + PACKAGE_NAME="devworkspace-operator" \ + CHANNEL="$(CHANNEL)" \ + SOURCE="devworkspace-operator" \ + SOURCE_NAMESPACE="openshift-marketplace" \ + INSTALL_PLAN_APPROVAL="Auto" $(MAKE) wait-devworkspace-running NAMESPACE="openshift-operators" wait-devworkspace-running: SHELL := /bin/bash diff --git a/build/scripts/oc-tests/oc-common.sh b/build/scripts/oc-tests/oc-common.sh index 1c1c17c6b..0e1764b22 100644 --- a/build/scripts/oc-tests/oc-common.sh +++ b/build/scripts/oc-tests/oc-common.sh @@ -80,8 +80,7 @@ listCatalogSourceBundles() { --attach=true \ --image=docker.io/fullstorydev/grpcurl:v1.7.0 \ -- -plaintext "${REGISTRY_IP}:${CATALOG_PORT}" api.Registry.ListBundles - -} ) + ) echo "${LIST_BUNDLES}" | head -n -1 } @@ -117,6 +116,6 @@ forcePullingOlmImages() { echo "[INFO] Pulling image '${image}'" yq -r "(.spec.template.spec.containers[0].image) = \"${image}\"" "${OPERATOR_REPO}/build/scripts/olm/force-pulling-images-job.yaml" | oc apply -f - -n ${NAMESPACE} - oc wait --for=condition=complete --timeout=30s job/force-pulling-images-job -n ${NAMESPACE} - oc delete job/force-pulling-images-job -n ${NAMESPACE} + oc wait --for=condition=complete --timeout=30s job/pull-image -n ${NAMESPACE} + oc delete job/pull-image -n ${NAMESPACE} } diff --git a/build/scripts/oc-tests/oc-test-devworkspace-happy-path.sh b/build/scripts/oc-tests/oc-test-devworkspace-happy-path.sh deleted file mode 100755 index 4b917a972..000000000 --- a/build/scripts/oc-tests/oc-test-devworkspace-happy-path.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2019-2021 Red Hat, Inc. -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# Red Hat, Inc. - initial API and implementation -# - -set -ex - -export CHE_REPO_BRANCH="main" -export OPERATOR_REPO=$(dirname "$(dirname "$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")")") -source "${OPERATOR_REPO}/build/scripts/oc-tests/oc-common.sh" -source <(curl -s https://raw.githubusercontent.com/eclipse/che/${CHE_REPO_BRANCH}/tests/devworkspace-happy-path/common.sh) - -#Stop execution on any error -trap "catchFinish" EXIT SIGINT - -runTests() { - # CI_CHE_OPERATOR_IMAGE it is che operator image built in openshift CI job workflow. - # More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates - useCustomOperatorImageInCSV "${CI_CHE_OPERATOR_IMAGE}" - - make create-namespace NAMESPACE="eclipse-che" - getCheClusterCRFromInstalledCSV | oc apply -n "${NAMESPACE}" -f - - make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE} - - bash <(curl -s https://raw.githubusercontent.com/eclipse/che/${CHE_REPO_BRANCH}/tests/devworkspace-happy-path/remote-launch.sh) -} - -runTests diff --git a/build/scripts/oc-tests/oc-test-happy-path.sh b/build/scripts/oc-tests/oc-test-happy-path.sh new file mode 100755 index 000000000..be2291b59 --- /dev/null +++ b/build/scripts/oc-tests/oc-test-happy-path.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Copyright (c) 2019-2021 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + +set -ex + +export OPERATOR_REPO=$(dirname "$(dirname "$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")")") +source <(curl -s ${DEVWORKSPACE_HAPPY_PATH}/common.sh) + +export DEVWORKSPACE_HAPPY_PATH="https://raw.githubusercontent.com/eclipse/che/main/tests/devworkspace-happy-path" +source "${OPERATOR_REPO}/build/scripts/oc-tests/oc-common.sh" + +#Stop execution on any error +trap "catchFinish" EXIT SIGINT + +runTests() { + bash <(curl -s ${DEVWORKSPACE_HAPPY_PATH}/remote-launch.sh) +} + +runTests diff --git a/build/scripts/oc-tests/oc-test-operator.sh b/build/scripts/oc-tests/oc-test-operator.sh index 4c393c737..2a677df4d 100755 --- a/build/scripts/oc-tests/oc-test-operator.sh +++ b/build/scripts/oc-tests/oc-test-operator.sh @@ -22,7 +22,7 @@ trap "catchFinish" EXIT SIGINT [[ -z "${CI_CHE_OPERATOR_IMAGE}" ]] && { echo [ERROR] CI_CHE_OPERATOR_IMAGE not defined; exit 1; } runTests() { - . ${OPERATOR_REPO}/build/scripts/olm/testCatalogFromSources.sh -o ${CI_CHE_OPERATOR_IMAGE} + . ${OPERATOR_REPO}/build/scripts/olm/testCatalogFromSources.sh -o ${CI_CHE_OPERATOR_IMAGE} --verbose } runTests diff --git a/build/scripts/oc-tests/oc-test-upgrade-from-stable-to-next.sh b/build/scripts/oc-tests/oc-test-upgrade-from-stable-to-next.sh index 5ab82c39d..f4cdc6a12 100755 --- a/build/scripts/oc-tests/oc-test-upgrade-from-stable-to-next.sh +++ b/build/scripts/oc-tests/oc-test-upgrade-from-stable-to-next.sh @@ -28,97 +28,24 @@ unset OPERATOR_TEST_NAMESPACE [[ -z "${CI_CHE_OPERATOR_IMAGE}" ]] && { echo [ERROR] CI_CHE_OPERATOR_IMAGE not defined; exit 1; } -# Discover test namespace -# Eclipse Che subscription is pre-created by OpenShift CI -discoverOperatorTestNamespace() { - discoverEclipseCheSubscription - OPERATOR_TEST_NAMESPACE=${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE} -} - -# Delete Eclipse Che next version operator by deleting its subscription -deleteEclipseCheNextVersionSubscription() { - discoverEclipseCheSubscription - - # save .spec to recreate subscription later - ECLIPSE_CHE_NEXT_SUBSCRIPTION_SPEC_SOURCE=$(oc get subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${OPERATOR_TEST_NAMESPACE} -o "jsonpath={.spec.source}") - ECLIPSE_CHE_NEXT_SUBSCRIPTION_SPEC_SOURCE_NAMESPACE=$(oc get subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${OPERATOR_TEST_NAMESPACE} -o "jsonpath={.spec.sourceNamespace}") - - oc delete csv ${ECLIPSE_CHE_INSTALLED_CSV} -n ${OPERATOR_TEST_NAMESPACE} - oc delete subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${OPERATOR_TEST_NAMESPACE} -} - -# Install Eclipse Che next version operator by creating its subscription -createEclipseCheNextVersionSubscription() { - pushd "${OPERATOR_REPO}" || exit 1 - - make create-subscription \ - NAME=${ECLIPSE_CHE_SUBSCRIPTION_NAME} \ - NAMESPACE=${OPERATOR_TEST_NAMESPACE} \ - SOURCE=${ECLIPSE_CHE_NEXT_SUBSCRIPTION_SPEC_SOURCE} \ - SOURCE_NAMESPACE=${ECLIPSE_CHE_NEXT_SUBSCRIPTION_SPEC_SOURCE_NAMESPACE} \ - PACKAGE_NAME=${ECLIPSE_CHE_PREVIEW_PACKAGE_NAME} \ - CHANNEL="next" \ - INSTALL_PLAN_APPROVAL="Auto" - - popd -} - -# Install Eclipse Che stable version operator by creating its subscription -createEclipseCheStableVersionSubscription() { - pushd "${OPERATOR_REPO}" || exit 1 - - make create-subscription \ - NAME=${ECLIPSE_CHE_SUBSCRIPTION_NAME} \ - NAMESPACE=${OPERATOR_TEST_NAMESPACE} \ - SOURCE="community-operators" \ - SOURCE_NAMESPACE="openshift-marketplace" \ - PACKAGE_NAME=${ECLIPSE_CHE_STABLE_PACKAGE_NAME} \ - CHANNEL="stable" \ - INSTALL_PLAN_APPROVAL="Auto" - - popd -} - # Uninstall Eclipse Che stable version operator by deleting its subscription -deleteEclipseCheStableVersionSubscription() { +deleteEclipseCheStableVersionOperator() { discoverEclipseCheSubscription - oc delete csv ${ECLIPSE_CHE_INSTALLED_CSV} -n ${OPERATOR_TEST_NAMESPACE} - oc delete subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${OPERATOR_TEST_NAMESPACE} -} + oc delete csv ${ECLIPSE_CHE_INSTALLED_CSV} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE} + oc delete subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE} -runTests() { - discoverOperatorTestNamespace - - # Uninstall pre-created Eclipse Che next version operator (operands don't exist) - deleteEclipseCheNextVersionSubscription waitForRemovedEclipseCheSubscription - # Deploy stable version - createEclipseCheStableVersionSubscription - waitForInstalledEclipseCheCSV - getCheClusterCRFromInstalledCSV | oc apply -n "${NAMESPACE}" -f - - - pushd ${OPERATOR_REPO} - make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE} - popd - - # Delete Eclipse Che stable version (just operator) - deleteEclipseCheStableVersionSubscription - waitForRemovedEclipseCheSubscription # Hack, since we remove operator pod, webhook won't work. # We have to disable it for a while. oc patch crd checlusters.org.eclipse.che --patch '{"spec": {"conversion": null}}' --type=merge +} - # Install Eclipse Che next version - createEclipseCheNextVersionSubscription - waitForInstalledEclipseCheCSV - # CI_CHE_OPERATOR_IMAGE it is che operator image built in openshift CI job workflow. - # More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates - useCustomOperatorImageInCSV "${CI_CHE_OPERATOR_IMAGE}" - pushd ${OPERATOR_REPO} - make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE} - popd +runTests() { + . ${OPERATOR_REPO}/build/scripts/olm/testCatalog.sh -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:test -c stable --verbose + deleteEclipseCheStableVersionOperator + . ${OPERATOR_REPO}/build/scripts/olm/testCatalogFromSources.sh -o ${CI_CHE_OPERATOR_IMAGE} --verbose } runTests diff --git a/build/scripts/oc-tests/oc-test-upgrade-from-stable-to-stable.sh b/build/scripts/oc-tests/oc-test-upgrade-from-stable-to-stable.sh index fe1951f1e..a8f431aef 100755 --- a/build/scripts/oc-tests/oc-test-upgrade-from-stable-to-stable.sh +++ b/build/scripts/oc-tests/oc-test-upgrade-from-stable-to-stable.sh @@ -20,7 +20,7 @@ source "${OPERATOR_REPO}/build/scripts/oc-tests/oc-common.sh" trap "catchFinish" EXIT SIGINT runTests() { - . "${OPERATOR_REPO}"/build/scripts/olm/testUpdate.sh -c stable -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:test -n ${NAMESPACE} + . ${OPERATOR_REPO}/build/scripts/olm/testUpdate.sh -c stable -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:test -n ${NAMESPACE} --verbose } runTests diff --git a/build/scripts/olm/buildCatalog.sh b/build/scripts/olm/buildCatalog.sh index 5d7821c9c..6d8b86cc5 100755 --- a/build/scripts/olm/buildCatalog.sh +++ b/build/scripts/olm/buildCatalog.sh @@ -133,9 +133,9 @@ buildCatalogImage() { init "$@" -pushd "${ROOT_DIR}" || exit +pushd "${OPERATOR_REPO}" >/dev/null buildBundle buildCatalog -popd || exit +popd >/dev/null echo "[INFO] Done" diff --git a/build/scripts/olm/force-pulling-images-job.yaml b/build/scripts/olm/force-pulling-images-job.yaml index df73e104d..92770e88d 100644 --- a/build/scripts/olm/force-pulling-images-job.yaml +++ b/build/scripts/olm/force-pulling-images-job.yaml @@ -13,22 +13,16 @@ kind: Job apiVersion: batch/v1 metadata: - name: force-pulling-images-job + name: pull-image spec: - parallelism: 1 - completions: 1 - backoffLimit: 6 template: metadata: - name: force-pulling-images-job + name: pull-image spec: - imagePullSecrets: - - name: 'myregistrykey' volumes: - name: util emptyDir: {} initContainers: - - name: util image: >- busybox @@ -40,13 +34,9 @@ spec: volumeMounts: - name: util mountPath: /util - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File imagePullPolicy: IfNotPresent - containers: - - - name: pull-bundle-image + - name: pull-image image: "${BUNDLE_IMAGE_NAME}" command: - /util/echo @@ -54,11 +44,5 @@ spec: volumeMounts: - name: util mountPath: /util - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File imagePullPolicy: Always - restartPolicy: OnFailure - terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst - schedulerName: default-scheduler diff --git a/build/scripts/olm/testCatalog.sh b/build/scripts/olm/testCatalog.sh index b133e73c5..86bfca01e 100755 --- a/build/scripts/olm/testCatalog.sh +++ b/build/scripts/olm/testCatalog.sh @@ -19,6 +19,7 @@ source "${OPERATOR_REPO}/build/scripts/oc-tests/oc-common.sh" init() { NAMESPACE="eclipse-che" CHANNEL="next" + VERBOSE=0 unset CATALOG_IMAGE while [[ "$#" -gt 0 ]]; do @@ -26,12 +27,13 @@ init() { '--channel'|'-c') CHANNEL="$2"; shift 1;; '--namespace'|'-n') NAMESPACE="$2"; shift 1;; '--catalog-image'|'-i') CATALOG_IMAGE="$2"; shift 1;; + '--verbose'|'-v') VERBOSE=1;; '--help'|'-h') usage; exit;; esac shift 1 done - if [[ ! ${CHANNEL} ]] || [[ ! ${CATALOG_IMAGE} ]]; then usage; exit 1; fi + if [[ ! ${CATALOG_IMAGE} ]]; then usage; exit 1; fi } usage () { @@ -44,6 +46,7 @@ usage () { echo -e "\t-i,--catalog-image Catalog image" echo -e "\t-c,--channel=next|stable [default: next] Olm channel to deploy Eclipse Che from" echo -e "\t-n,--namespace [default: eclipse-che] Kubernetes namespace to deploy Eclipse Che into" + echo -e "\t-n,--verbose Verbose mode" echo echo "Example:" echo -e "\t$0 -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:next" @@ -52,41 +55,41 @@ usage () { } run() { - pushd ${OPERATOR_REPO} || exit 1 - if [[ ${CHANNEL} == "next" ]]; then - make install-devworkspace CHANNEL=next - else - make install-devworkspace CHANNEL=fast - fi + if [[ ${CHANNEL} == "next" ]]; then + make install-devworkspace CHANNEL=next VERBOSE=${VERBOSE} + else + make install-devworkspace CHANNEL=fast VERBOSE=${VERBOSE} + fi - make create-namespace NAMESPACE="eclipse-che" - make create-catalogsource NAME="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" IMAGE="${CATALOG_IMAGE}" - popd + make create-namespace NAMESPACE="eclipse-che" VERBOSE=${VERBOSE} + make create-catalogsource NAME="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" IMAGE="${CATALOG_IMAGE}" VERBOSE=${VERBOSE} local bundles=$(listCatalogSourceBundles "${ECLIPSE_CHE_CATALOG_SOURCE_NAME}") fetchLatestCSVInfo "${CHANNEL}" "${bundles}" forcePullingOlmImages "${LATEST_CSV_BUNDLE_IMAGE}" - pushd ${OPERATOR_REPO} || exit 1 - make create-subscription \ - NAME="${ECLIPSE_CHE_SUBSCRIPTION_NAME}" \ - PACKAGE_NAME="${ECLIPSE_CHE_PREVIEW_PACKAGE_NAME}" \ - CHANNEL="${CHANNEL}" \ - SOURCE="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" \ - SOURCE_NAMESPACE="openshift-marketplace" \ - INSTALL_PLAN_APPROVAL="Auto" - popd + make create-subscription \ + NAME="${ECLIPSE_CHE_SUBSCRIPTION_NAME}" \ + NAMESPACE="openshift-operators" \ + PACKAGE_NAME="${ECLIPSE_CHE_PREVIEW_PACKAGE_NAME}" \ + CHANNEL="${CHANNEL}" \ + SOURCE="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" \ + SOURCE_NAMESPACE="openshift-marketplace" \ + INSTALL_PLAN_APPROVAL="Auto" \ + VERBOSE=${VERBOSE} waitForInstalledEclipseCheCSV getCheClusterCRFromInstalledCSV | oc apply -n "${NAMESPACE}" -f - - - pushd ${OPERATOR_REPO} - make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE} - popd + make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE} VERBOSE=${VERBOSE} } + init "$@" +[[ ${VERBOSE} == 1 ]] && set -x + +pushd ${OPERATOR_REPO} >/dev/null run +popd >/dev/null echo "[INFO] Done" diff --git a/build/scripts/olm/testCatalogFromSources.sh b/build/scripts/olm/testCatalogFromSources.sh index d68a92ea3..cf8ec2a30 100755 --- a/build/scripts/olm/testCatalogFromSources.sh +++ b/build/scripts/olm/testCatalogFromSources.sh @@ -17,12 +17,14 @@ OPERATOR_REPO=$(dirname "$(dirname "$(dirname "$(dirname "$(readlink -f "${BASH_ source "${OPERATOR_REPO}/build/scripts/oc-tests/oc-common.sh" init() { + VERBOSE=0 unset OPERATOR_IMAGE while [[ "$#" -gt 0 ]]; do case $1 in '--help'|'-h') usage; exit;; '--operator-image'|'-o') OPERATOR_IMAGE="$2"; shift 1;; + '--verbose'|'-v') VERBOSE=1;; esac shift 1 done @@ -37,7 +39,8 @@ usage () { echo -e "\t$0 -o OPERATOR_IMAGE" echo echo "OPTIONS:" - echo -e "\t-o,--operator-image Operator image to include into bundle" + echo -e "\t-o,--operator-image Operator image to include into a bundle" + echo -e "\t-n,--verbose Verbose mode" echo echo "Example:" echo -e "\t$0 -o quay.io/eclipse/che-operator:next" @@ -67,20 +70,16 @@ createImageRegistryViewerUser() { registry-viewer:{SHA}4xV+Nga1JF5YDx0fB1LdYbyaVvQ= EOF oc create secret generic registry-viewer-htpasswd --from-file=htpasswd=/tmp/htpasswd.conf -n openshift-config - oc apply -f - </dev/null +run +popd >/dev/null diff --git a/build/scripts/olm/testUpdate.sh b/build/scripts/olm/testUpdate.sh index 493761687..8846ca1d2 100755 --- a/build/scripts/olm/testUpdate.sh +++ b/build/scripts/olm/testUpdate.sh @@ -1,4 +1,4 @@ -#!/bin/bash + #!/bin/bash # # Copyright (c) 2019-2021 Red Hat, Inc. # This program and the accompanying materials are made @@ -19,6 +19,7 @@ source "${OPERATOR_REPO}/build/scripts/oc-tests/oc-common.sh" init() { NAMESPACE="eclipse-che" CHANNEL="next" + VERBOSE=0 unset CATALOG_IMAGE while [[ "$#" -gt 0 ]]; do @@ -26,6 +27,7 @@ init() { '--channel'|'-c') CHANNEL="$2"; shift 1;; '--namespace'|'-n') NAMESPACE="$2"; shift 1;; '--catalog-image'|'-i') CATALOG_IMAGE="$2"; shift 1;; + '--verbose'|'-v') VERBOSE=1;; '--help'|'-h') usage; exit;; esac shift 1 @@ -44,6 +46,7 @@ usage () { echo -e "\t-i,--catalog-image Catalog image" echo -e "\t-c,--channel [default: next] Olm channel to deploy Eclipse Che from" echo -e "\t-n,--namespace [default: eclipse-che] Kubernetes namepsace to deploy Eclipse Che into" + echo -e "\t-n,--verbose Verbose mode" echo echo "Example:" echo -e "\t$0 -i quay.io/eclipse/eclipse-che-openshift-opm-catalog:next -c next" @@ -51,22 +54,20 @@ usage () { } run() { - pushd ${OPERATOR_REPO} || exit 1 - if [[ ${CHANNEL} == "next" ]]; then - make install-devworkspace CHANNEL=next - else - make install-devworkspace CHANNEL=fast - fi + if [[ ${CHANNEL} == "next" ]]; then + make install-devworkspace CHANNEL=next VERBOSE=${VERBOSE} + else + make install-devworkspace CHANNEL=fast VERBOSE=${VERBOSE} + fi - make create-namespace NAMESPACE="eclipse-che" - make create-catalogsource NAME="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" IMAGE="${CATALOG_IMAGE}" - popd + make create-namespace NAMESPACE="eclipse-che" VERBOSE=${VERBOSE} + make create-catalogsource NAME="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" IMAGE="${CATALOG_IMAGE}" VERBOSE=${VERBOSE} local bundles=$(listCatalogSourceBundles "${ECLIPSE_CHE_CATALOG_SOURCE_NAME}") fetchPreviousCSVInfo "${CHANNEL}" "${bundles}" fetchLatestCSVInfo "${CHANNEL}" "${bundles}" - if [ "${PREVIOUS_CSV_BUNDLE_IMAGE}" == "${LATEST_CSV_BUNDLE_IMAGE}" ]; then + if [[ "${PREVIOUS_CSV_BUNDLE_IMAGE}" == "${LATEST_CSV_BUNDLE_IMAGE}" ]]; then echo "[ERROR] Nothing to update. OLM channel '${CHANNEL}' contains only one bundle '${LATEST_CSV_BUNDLE_IMAGE}'" exit 1 fi @@ -75,30 +76,32 @@ run() { forcePullingOlmImages "${PREVIOUS_CSV_BUNDLE_IMAGE}" forcePullingOlmImages "${LATEST_CSV_BUNDLE_IMAGE}" - pushd ${OPERATOR_REPO} || exit 1 - make create-subscription \ - NAME="${ECLIPSE_CHE_SUBSCRIPTION_NAME}" \ - PACKAGE_NAME="${ECLIPSE_CHE_PREVIEW_PACKAGE_NAME}" \ - CHANNEL="${CHANNEL}" \ - SOURCE="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" \ - SOURCE_NAMESPACE="openshift-marketplace" \ - INSTALL_PLAN_APPROVAL="Manual" \ - STARTING_CSV="${PREVIOUS_CSV_NAME}" - make approve-installplan SUBSCRIPTION_NAME="${ECLIPSE_CHE_SUBSCRIPTION_NAME}" - popd + make create-subscription \ + NAME="${ECLIPSE_CHE_SUBSCRIPTION_NAME}" \ + NAMESPACE="openshift-operators" \ + PACKAGE_NAME="${ECLIPSE_CHE_PREVIEW_PACKAGE_NAME}" \ + CHANNEL="${CHANNEL}" \ + SOURCE="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" \ + SOURCE_NAMESPACE="openshift-marketplace" \ + INSTALL_PLAN_APPROVAL="Manual" \ + STARTING_CSV="${PREVIOUS_CSV_NAME}" \ + VERBOSE=${VERBOSE} + make approve-installplan SUBSCRIPTION_NAME="${ECLIPSE_CHE_SUBSCRIPTION_NAME}" NAMESPACE="openshift-operators" sleep 10s getCheClusterCRFromInstalledCSV | oc apply -n "${NAMESPACE}" -f - - pushd ${OPERATOR_REPO} || exit 1 - make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE} - make approve-installplan SUBSCRIPTION_NAME="${ECLIPSE_CHE_SUBSCRIPTION_NAME}" - make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE} - popd + make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE} VERBOSE=${VERBOSE} + make approve-installplan SUBSCRIPTION_NAME="${ECLIPSE_CHE_SUBSCRIPTION_NAME}" NAMESPACE="openshift-operators" VERBOSE=${VERBOSE} + make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE} VERBOSE=${VERBOSE} } init "$@" +[[ ${VERBOSE} == 1 ]] && set -x + +pushd ${OPERATOR_REPO} >/dev/null run +popd >/dev/null echo "[INFO] Done"