From 14be2a6abba80d2791cf823c334314e7afe326ad Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 1 Dec 2020 13:26:16 +0200 Subject: [PATCH 01/34] Refactoring test scripts Signed-off-by: Anatolii Bazko --- .ci/cico_minishift.sh | 100 ++++++++++++++++++++++++ .ci/cico_minishift_nightly.sh | 119 ----------------------------- .ci/util/ci_common.sh | 16 ++++ .github/workflows/che-nightly.yaml | 2 +- 4 files changed, 117 insertions(+), 120 deletions(-) create mode 100755 .ci/cico_minishift.sh delete mode 100755 .ci/cico_minishift_nightly.sh diff --git a/.ci/cico_minishift.sh b/.ci/cico_minishift.sh new file mode 100755 index 000000000..f6b7b2193 --- /dev/null +++ b/.ci/cico_minishift.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# +# Copyright (c) 2020 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 + +#Stop execution on any error +trap "catchFinish" EXIT SIGINT + +# Catch_Finish is executed after finish script. +catchFinish() { + result=$? + + collectCheLogWithChectl + if [ "$result" != "0" ]; then + echo "[ERROR] Job failed." + else + echo "[INFO] Job completed successfully." + fi + + echo "[INFO] Please check github actions artifacts." + exit $result +} + +# Define global environments +function init() { + export SCRIPT=$(readlink -f "$0") + export SCRIPT_DIR=$(dirname "$SCRIPT") + export RAM_MEMORY=8192 + export NAMESPACE="che" + export PLATFORM="openshift" + export INSTALLER="operator" + + # OPERATOR_IMAGE In CI is defined in .github/workflows/che-nightly.yaml + export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test" + + # Set operator root directory + if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then + OPERATOR_REPO=${WORKSPACE}; + else + OPERATOR_REPO=$(dirname "$SCRIPT_DIR"); + fi +} + +function prepareTemplates() { + rm -rf ${OPERATOR_REPO}/tmp + + # prepare template folder + mkdir -p "${OPERATOR_REPO}/tmp/che-operator" && chmod 777 "${OPERATOR_REPO}/tmp" + cp -rf ${OPERATOR_REPO}/deploy/* "${OPERATOR_REPO}/tmp/che-operator" + + # prepare CR + yq -riSY '.spec.auth.updateAdminPassword = false' "${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml" + yq -riSY '.spec.auth.openShiftoAuth = false' "${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml" + + # update operator yaml + yq -riSY '.spec.template.spec.containers[0].image = '${OPERATOR_IMAGE} "${OPERATOR_REPO}/tmp/che-operator/operator.yaml" + yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = IfNotPresent' "${OPERATOR_REPO}/tmp/che-operator/operator.yaml" + + cat ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml + cat ${OPERATOR_REPO}/tmp/che-operator/operator.yaml +} + +function deployEclipseChe() { + # Deploy Eclipse Che + chectl server:deploy --platform=${PLATFORM} \ + --installer ${INSTALLER} \ + --chenamespace ${NAMESPACE} \ + --che-operator-image ${OPERATOR_IMAGE} \ + --che-operator-cr-yaml ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml \ + --templates ${OPERATOR_REPO}/tmp +} + +function startWorkspace() { + # Create and start a workspace + chectl auth:login -u admin -p admin + chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml + + # Wait for workspace to be up + waitWorkspaceStart +} + +function runTest() { + deployEclipseChe + startWorkspace +} + +source "${OPERATOR_REPO}"/.ci/util/ci_common.sh + +init +installYq +runTest diff --git a/.ci/cico_minishift_nightly.sh b/.ci/cico_minishift_nightly.sh deleted file mode 100755 index 5eb871f01..000000000 --- a/.ci/cico_minishift_nightly.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2020 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 - -#Stop execution on any error -trap "catchFinish" EXIT SIGINT - -# Catch_Finish is executed after finish script. -catchFinish() { - result=$? - - if [ "$result" != "0" ]; then - echo "[ERROR] Please check the artifacts in github actions" - getOCCheClusterLogs - exit 1 - fi - - echo "[INFO] Job finished Successfully.Please check the artifacts in github actions" - getOCCheClusterLogs - - exit $result -} - -# Define global environments -function init() { - export SCRIPT=$(readlink -f "$0") - export SCRIPT_DIR=$(dirname "$SCRIPT") - export RAM_MEMORY=8192 - export NAMESPACE="che" - export PLATFORM="openshift" - - # Set operator root directory - if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then - OPERATOR_REPO=${WORKSPACE}; - else - OPERATOR_REPO=$(dirname "$SCRIPT_DIR"); - fi -} - -installYq() { - YQ=$(command -v yq) || true - if [[ ! -x "${YQ}" ]]; then - pip3 install wheel - pip3 install yq - fi - echo "[INFO] $(yq --version)" - echo "[INFO] $(jq --version)" -} - -# Utility to get che events and pod logs from openshift cluster -function getOCCheClusterLogs() { - mkdir -p /tmp/artifacts-che - cd /tmp/artifacts-che - - for POD in $(oc get pods -o name -n ${NAMESPACE}); do - for CONTAINER in $(oc get -n ${NAMESPACE} ${POD} -o jsonpath="{.spec.containers[*].name}"); do - echo "" - echo "[INFO] Getting logs from $POD" - echo "" - oc logs ${POD} -c ${CONTAINER} -n ${NAMESPACE} |tee $(echo ${POD}-${CONTAINER}.log | sed 's|pod/||g') - done - done - echo "[INFO] Get events" - oc get events -n ${NAMESPACE}| tee get_events.log - oc get all | tee get_all.log -} - -# Deploy Eclipse Che -function run() { - # OPERATOR_IMAGE In CI is defined in .github/workflows/che-nightly.yaml - export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test" - - rm -rf tmp - # prepare template folder - mkdir -p "${OPERATOR_REPO}/tmp/che-operator" && chmod 777 "${OPERATOR_REPO}/tmp" - cp -rf ${OPERATOR_REPO}/deploy/* "${OPERATOR_REPO}/tmp/che-operator" - - # prepare CR - sed -i'.bak' -e "s|openShiftoAuth: .*|openShiftoAuth: false|" "${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml" - yq -riSY '.spec.auth.updateAdminPassword = false' "${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml" - - # update operator yaml - sed -i'.bak' -e "s|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|" "${OPERATOR_REPO}/tmp/che-operator/operator.yaml" - sed -i'.bak' -e "s|quay.io/eclipse/che-operator:nightly|'${OPERATOR_IMAGE}'|" "${OPERATOR_REPO}/tmp/che-operator/operator.yaml" - - cat ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml - cat ${OPERATOR_REPO}/tmp/che-operator/operator.yaml - - # Deploy Eclipse Che - chectl server:deploy --platform=minishift \ - --installer operator \ - --chenamespace ${NAMESPACE} \ - --che-operator-image ${OPERATOR_IMAGE} \ - --che-operator-cr-yaml ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml \ - --templates ${OPERATOR_REPO}/tmp - - # Create and start a workspace - chectl auth:login -u admin -p admin - chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml - - # Wait for workspace to be up - waitWorkspaceStart # Function from ./util/ci_common.sh - oc get events -n ${NAMESPACE} -} - -init -installYq -source "${OPERATOR_REPO}"/.ci/util/ci_common.sh -run diff --git a/.ci/util/ci_common.sh b/.ci/util/ci_common.sh index ac9da07d5..98afdc598 100644 --- a/.ci/util/ci_common.sh +++ b/.ci/util/ci_common.sh @@ -74,3 +74,19 @@ function getCheClusterLogs() { kubectl get events -n ${NAMESPACE}| tee get_events.log kubectl get all | tee get_all.log } + +function installYq() { + YQ=$(command -v yq) || true + if [[ ! -x "${YQ}" ]]; then + pip3 install wheel + pip3 install yq + fi + echo "[INFO] $(yq --version)" + echo "[INFO] $(jq --version)" +} + +# Graps Eclipse Che logs +function collectCheLogWithChectl() { + mkdir -p ${ARTIFACTS_DIR} + chectl server:logs --directory=${ARTIFACTS_DIR} +} diff --git a/.github/workflows/che-nightly.yaml b/.github/workflows/che-nightly.yaml index e3252ee15..eefa0b7b1 100644 --- a/.github/workflows/che-nightly.yaml +++ b/.github/workflows/che-nightly.yaml @@ -52,7 +52,7 @@ jobs: eval $(minishift oc-env) eval $(minishift docker-env) && docker load -i operator.tar && rm operator.tar - /bin/bash .ci/cico_minishift_nightly.sh + /bin/bash .ci/cico_minishift.sh # Run this step even the previous step fail - uses: actions/upload-artifact@v2 if: ${{ always() }} From 548935a53f963b34d4d009439fba2f7fc71a6379 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 1 Dec 2020 13:28:35 +0200 Subject: [PATCH 02/34] Minishift fixup Signed-off-by: Anatolii Bazko --- .ci/cico_minishift.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/cico_minishift.sh b/.ci/cico_minishift.sh index f6b7b2193..042577c95 100755 --- a/.ci/cico_minishift.sh +++ b/.ci/cico_minishift.sh @@ -97,4 +97,5 @@ source "${OPERATOR_REPO}"/.ci/util/ci_common.sh init installYq +prepareTemplates runTest From e673cde33abe9d951dbe86a11b30702e83c6145d Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 1 Dec 2020 17:50:43 +0200 Subject: [PATCH 03/34] Refactoring Signed-off-by: Anatolii Bazko --- .ci/cico_minishift.sh | 101 ------------------ .ci/util/ci_common.sh | 11 +- .../nightly/minikube/single-host-gateway.sh | 99 ----------------- .../nightly/minikube/single-host-native.sh | 97 ----------------- ...s.yaml => minikube-singlehost-latest.yaml} | 22 ++-- ...che-nightly.yaml => minishift-latest.yaml} | 19 ++-- 6 files changed, 25 insertions(+), 324 deletions(-) delete mode 100755 .ci/cico_minishift.sh delete mode 100644 .github/action_scripts/nightly/minikube/single-host-gateway.sh delete mode 100644 .github/action_scripts/nightly/minikube/single-host-native.sh rename .github/workflows/{single-host-tests.yaml => minikube-singlehost-latest.yaml} (66%) rename .github/workflows/{che-nightly.yaml => minishift-latest.yaml} (77%) diff --git a/.ci/cico_minishift.sh b/.ci/cico_minishift.sh deleted file mode 100755 index 042577c95..000000000 --- a/.ci/cico_minishift.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2020 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 - -#Stop execution on any error -trap "catchFinish" EXIT SIGINT - -# Catch_Finish is executed after finish script. -catchFinish() { - result=$? - - collectCheLogWithChectl - if [ "$result" != "0" ]; then - echo "[ERROR] Job failed." - else - echo "[INFO] Job completed successfully." - fi - - echo "[INFO] Please check github actions artifacts." - exit $result -} - -# Define global environments -function init() { - export SCRIPT=$(readlink -f "$0") - export SCRIPT_DIR=$(dirname "$SCRIPT") - export RAM_MEMORY=8192 - export NAMESPACE="che" - export PLATFORM="openshift" - export INSTALLER="operator" - - # OPERATOR_IMAGE In CI is defined in .github/workflows/che-nightly.yaml - export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test" - - # Set operator root directory - if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then - OPERATOR_REPO=${WORKSPACE}; - else - OPERATOR_REPO=$(dirname "$SCRIPT_DIR"); - fi -} - -function prepareTemplates() { - rm -rf ${OPERATOR_REPO}/tmp - - # prepare template folder - mkdir -p "${OPERATOR_REPO}/tmp/che-operator" && chmod 777 "${OPERATOR_REPO}/tmp" - cp -rf ${OPERATOR_REPO}/deploy/* "${OPERATOR_REPO}/tmp/che-operator" - - # prepare CR - yq -riSY '.spec.auth.updateAdminPassword = false' "${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml" - yq -riSY '.spec.auth.openShiftoAuth = false' "${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml" - - # update operator yaml - yq -riSY '.spec.template.spec.containers[0].image = '${OPERATOR_IMAGE} "${OPERATOR_REPO}/tmp/che-operator/operator.yaml" - yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = IfNotPresent' "${OPERATOR_REPO}/tmp/che-operator/operator.yaml" - - cat ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml - cat ${OPERATOR_REPO}/tmp/che-operator/operator.yaml -} - -function deployEclipseChe() { - # Deploy Eclipse Che - chectl server:deploy --platform=${PLATFORM} \ - --installer ${INSTALLER} \ - --chenamespace ${NAMESPACE} \ - --che-operator-image ${OPERATOR_IMAGE} \ - --che-operator-cr-yaml ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml \ - --templates ${OPERATOR_REPO}/tmp -} - -function startWorkspace() { - # Create and start a workspace - chectl auth:login -u admin -p admin - chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml - - # Wait for workspace to be up - waitWorkspaceStart -} - -function runTest() { - deployEclipseChe - startWorkspace -} - -source "${OPERATOR_REPO}"/.ci/util/ci_common.sh - -init -installYq -prepareTemplates -runTest diff --git a/.ci/util/ci_common.sh b/.ci/util/ci_common.sh index 98afdc598..6b5643019 100644 --- a/.ci/util/ci_common.sh +++ b/.ci/util/ci_common.sh @@ -86,7 +86,16 @@ function installYq() { } # Graps Eclipse Che logs -function collectCheLogWithChectl() { +collectCheLogWithChectl() { mkdir -p ${ARTIFACTS_DIR} chectl server:logs --directory=${ARTIFACTS_DIR} } + +# Build latest operator image +buildCheOperatorImage() { + docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker save "${OPERATOR_IMAGE}" > operator.tar +} + +copyCheOperatorImageToMinikube() { + eval $(minikube docker-env) && docker load -i operator.tar && rm operator.tar +} diff --git a/.github/action_scripts/nightly/minikube/single-host-gateway.sh b/.github/action_scripts/nightly/minikube/single-host-gateway.sh deleted file mode 100644 index 162125f62..000000000 --- a/.github/action_scripts/nightly/minikube/single-host-gateway.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) 2020 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 - -# exit immediately when a command fails -set -e -# only exit with zero if all commands of the pipeline exit successfully -set -o pipefail -# error on unset variables -set -u -# print each command before executing it -set -x - -# Stop execution on any error -trap "catchFinish" EXIT SIGINT - -# Define global environments -export OPERATOR_REPO="${GITHUB_WORKSPACE}" -export RAM_MEMORY=8192 -export NAMESPACE="che" -export PLATFORM="kubernetes" - -# Directory where che artifacts will be stored and uploaded to GH actions artifacts -export ARTIFACTS_DIR="/tmp/artifacts-che" - -# Set operator root directory -export OPERATOR_IMAGE="che-operator:pr-check" - -# Catch_Finish is executed after finish script. -catchFinish() { - result=$? - - if [ "$result" != "0" ]; then - echo "[ERROR] Please check the github actions artifacts" - collectCheLogWithChectl - exit 1 - fi - - echo "[INFO] Job finished Successfully.Please check github actions artifacts" - collectCheLogWithChectl - - exit $result -} - -# Utility to get che events and pod logs from openshift cluster -function collectCheLogWithChectl() { - mkdir -p ${ARTIFACTS_DIR} - chectl server:logs --directory=${ARTIFACTS_DIR} -} - -# Deploy Eclipse Che in single host mode(gateway exposure type) -function runSHostGatewayExposure() { - # Patch file to pass to chectl - cat >/tmp/che-cr-patch.yaml </tmp/che-cr-patch.yaml < operator.tar docker-machine stop - - name: Install and start minishift OCP 3.11 cluster + - name: Provision Minishift cluster run: | brew cask install minishift export MINISHIFT_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} minishift start --memory=5500 --vm-driver=virtualbox - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - - name: Generate minishift certificates + - name: Generate Minishift certificates run: /bin/bash .github/action_scripts/minishift_cert_gen.sh - - name: Update minishift deprecated certificates and run e2e - run: | - set -x - export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test - export NAMESPACE="che" - eval $(minishift oc-env) - eval $(minishift docker-env) && docker load -i operator.tar && rm operator.tar - - /bin/bash .ci/cico_minishift.sh + - name: Run tests + run: /bin/bash .github/bin/minishift/test.sh # Run this step even the previous step fail - uses: actions/upload-artifact@v2 if: ${{ always() }} with: - name: minishift-che-nightly-artifacts + name: minishift-latests-artifacts path: /tmp/artifacts-che From 1eae7d2f18e94a0872cd2db609edd4e413de0804 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 1 Dec 2020 17:52:01 +0200 Subject: [PATCH 04/34] Add scrits Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 153 ++++++++++++++++++ .../operator-single-host-gateway-test.sh | 40 +++++ .../operator-single-host-native-test.sh | 40 +++++ .github/bin/minishift/test.sh | 38 +++++ 4 files changed, 271 insertions(+) create mode 100755 .github/bin/common.sh create mode 100755 .github/bin/minikube/operator-single-host-gateway-test.sh create mode 100755 .github/bin/minikube/operator-single-host-native-test.sh create mode 100755 .github/bin/minishift/test.sh diff --git a/.github/bin/common.sh b/.github/bin/common.sh new file mode 100755 index 000000000..0a10d0de1 --- /dev/null +++ b/.github/bin/common.sh @@ -0,0 +1,153 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2020 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 -e +set -o pipefail +set -u +set -x + +catchFinish() { + result=$? + + collectCheLogWithChectl + if [ "$result" != "0" ]; then + echo "[ERROR] Job failed." + else + echo "[INFO] Job completed successfully." + fi + + echo "[INFO] Please check github actions artifacts." + exit $result +} + +init() { + export SCRIPT=$(readlink -f "$0") + export SCRIPT_DIR=$(dirname "$SCRIPT") + export RAM_MEMORY=8192 + export NAMESPACE="che" + export ARTIFACTS_DIR="/tmp/artifacts-che" + export TEMPLATES=${OPERATOR_REPO}/tmp + export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test" + + # prepare templates directory + rm -rf ${TEMPLATES} + mkdir -p "${TEMPLATES}/che-operator" && chmod 777 "${TEMPLATES}" + cp -rf ${OPERATOR_REPO}/deploy/* "${TEMPLATES}/che-operator" + + installYq +} + +# Utility to wait for a workspace to be started after workspace:create. +waitWorkspaceStart() { + set +e + export x=0 + while [ $x -le 180 ] + do + getCheAcessToken + + chectl workspace:list + workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE}) + workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ') + + if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ] + then + echo "[INFO] Workspace started successfully" + break + fi + sleep 10 + x=$(( x+1 )) + done + + if [ $x -gt 180 ] + then + echo "[ERROR] Workspace didn't start after 3 minutes." + exit 1 + fi +} + +installYq() { + YQ=$(command -v yq) || true + if [[ ! -x "${YQ}" ]]; then + pip3 install wheel + pip3 install yq + fi + echo "[INFO] $(yq --version)" + echo "[INFO] $(jq --version)" +} + +# Graps Eclipse Che logs +collectCheLogWithChectl() { + mkdir -p ${ARTIFACTS_DIR} + chectl server:logs --directory=${ARTIFACTS_DIR} +} + +# Build latest operator image +buildCheOperatorImage() { + docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker save "${OPERATOR_IMAGE}" > operator.tar +} + +copyCheOperatorImageToMinikube() { + eval $(minikube docker-env) && docker load -i operator.tar && rm operator.tar +} + +copyCheOperatorImageToMinishift() { + eval $(minishift docker-env) && docker load -i operator.tar && rm operator.tar +} + +deployEclipseChe() { + local installer=$1 + local platform=$2 + + echo "[INFO] Eclipse Che custom resource" + cat ${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml + + echo "[INFO] Eclipse Che operator deployment" + cat ${TEMPLATES}/che-operator/operator.yaml + + chectl server:deploy \ + --platform=${platform} \ + --installer ${installer} \ + --chenamespace ${NAMESPACE} \ + --che-operator-image ${OPERATOR_IMAGE} \ + --che-operator-cr-yaml ${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml \ + --templates ${TEMPLATES} +} + +startWorkspace() { + # Create and start a workspace + chectl auth:login -u admin -p admin + chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml + + # Wait for workspace to be up + waitWorkspaceStart +} + +disableOpenShiftOAuth() { + yq -riSY '.spec.auth.openShiftoAuth = false' "${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml" +} + +disableUpdateAdminPassword() { + yq -riSY '.spec.auth.updateAdminPassword = false' "${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml" +} + +setServerExposureStrategy() { + yq -riSY '.spec.server.serverExposureStrategy = '$1 "${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml" +} + +setSingleHostExposureType() { + yq -riSY '.spec.k8s.singleHostExposureType = '$1 "${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml" +} + +setCustomOperatorImage() { + yq -riSY '.spec.template.spec.containers[0].image = '${OPERATOR_IMAGE} "${TEMPLATES}/che-operator/operator.yaml" + yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = IfNotPresent' "${TEMPLATES}/che-operator/operator.yaml" +} diff --git a/.github/bin/minikube/operator-single-host-gateway-test.sh b/.github/bin/minikube/operator-single-host-gateway-test.sh new file mode 100755 index 000000000..2f2ed92c7 --- /dev/null +++ b/.github/bin/minikube/operator-single-host-gateway-test.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2020 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 -e +set -x +set -u + +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(readlink -f "$0")))); +source "${OPERATOR_REPO}"/.github/bin/common.sh + +# Stop execution on any error +trap "catchFinish" EXIT SIGINT + +prepareTemplates() { + disableOpenShiftOAuth + disableUpdateAdminPassword + setCustomOperatorImage + setServerExposureStrategy "single-host" + setSingleHostExposureType "gateway" +} + +runTest() { + prepareTemplates + deployEclipseChe "operator" "minikube" + startWorkspace +} + +init +buildCheOperatorImage +copyCheOperatorImageToMinikube +runTest diff --git a/.github/bin/minikube/operator-single-host-native-test.sh b/.github/bin/minikube/operator-single-host-native-test.sh new file mode 100755 index 000000000..95e675f9d --- /dev/null +++ b/.github/bin/minikube/operator-single-host-native-test.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2020 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 -e +set -x +set -u + +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(readlink -f "$0")))); +source "${OPERATOR_REPO}"/.github/bin/common.sh + +# Stop execution on any error +trap "catchFinish" EXIT SIGINT + +prepareTemplates() { + disableOpenShiftOAuth + disableUpdateAdminPassword + setCustomOperatorImage + setServerExposureStrategy "single-host" + setSingleHostExposureType "native" +} + +runTest() { + prepareTemplates + deployEclipseChe "operator" "minikube" + startWorkspace +} + +init +buildCheOperatorImage +copyCheOperatorImageToMinikube +runTest diff --git a/.github/bin/minishift/test.sh b/.github/bin/minishift/test.sh new file mode 100755 index 000000000..cc56081f4 --- /dev/null +++ b/.github/bin/minishift/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Copyright (c) 2020 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 -e +set -x +set -u + +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(readlink -f "$0")))); +source "${OPERATOR_REPO}"/.github/bin/common.sh + +# Stop execution on any error +trap "catchFinish" EXIT SIGINT + +prepareTemplates() { + disableOpenShiftOAuth + disableUpdateAdminPassword + setCustomOperatorImage +} + +runTest() { + prepareTemplates + deployEclipseChe "operator" "minishift" + startWorkspace +} + +init +# build is done on previous github action step +copyCheOperatorImageToMinishift +runTest From 1340814f7e36144802a82072a665c610dfdcad63 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 1 Dec 2020 17:59:46 +0200 Subject: [PATCH 05/34] Refactoring Signed-off-by: Anatolii Bazko --- .../minishift_cert_gen.sh => bin/minishift/certs.sh} | 0 .github/workflows/minishift-latest.yaml | 2 +- .gitignore | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) rename .github/{action_scripts/minishift_cert_gen.sh => bin/minishift/certs.sh} (100%) mode change 100644 => 100755 diff --git a/.github/action_scripts/minishift_cert_gen.sh b/.github/bin/minishift/certs.sh old mode 100644 new mode 100755 similarity index 100% rename from .github/action_scripts/minishift_cert_gen.sh rename to .github/bin/minishift/certs.sh diff --git a/.github/workflows/minishift-latest.yaml b/.github/workflows/minishift-latest.yaml index b45c2ba61..ce1dde747 100644 --- a/.github/workflows/minishift-latest.yaml +++ b/.github/workflows/minishift-latest.yaml @@ -43,7 +43,7 @@ jobs: - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - name: Generate Minishift certificates - run: /bin/bash .github/action_scripts/minishift_cert_gen.sh + run: /bin/bash .github/bin/minishift/certs.sh - name: Run tests run: /bin/bash .github/bin/minishift/test.sh # Run this step even the previous step fail diff --git a/.gitignore b/.gitignore index 83b989f69..aa21b33e4 100644 --- a/.gitignore +++ b/.gitignore @@ -108,7 +108,6 @@ tags .history build/ -bin/ olm/generated deploy/olm-catalog/eclipse-che-preview-kubernetes/generated deploy/olm-catalog/eclipse-che-preview-openshift/generated From 19ab2803591ed9562bc98e447c968a8949a8a67b Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 10:54:12 +0200 Subject: [PATCH 06/34] Fix tests Signed-off-by: Anatolii Bazko --- ...way-test.sh => test-latest-operator-singlehost-gateway.sh} | 0 ...tive-test.sh => test-latest-operator-singlehost-native.sh} | 0 .github/bin/minishift/{test.sh => test-latest-operator.sh} | 0 ...singlehost-latest.yaml => minikube-latest-singlehost.yaml} | 4 ++-- .github/workflows/minishift-latest.yaml | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename .github/bin/minikube/{operator-single-host-gateway-test.sh => test-latest-operator-singlehost-gateway.sh} (100%) rename .github/bin/minikube/{operator-single-host-native-test.sh => test-latest-operator-singlehost-native.sh} (100%) rename .github/bin/minishift/{test.sh => test-latest-operator.sh} (100%) rename .github/workflows/{minikube-singlehost-latest.yaml => minikube-latest-singlehost.yaml} (90%) diff --git a/.github/bin/minikube/operator-single-host-gateway-test.sh b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh similarity index 100% rename from .github/bin/minikube/operator-single-host-gateway-test.sh rename to .github/bin/minikube/test-latest-operator-singlehost-gateway.sh diff --git a/.github/bin/minikube/operator-single-host-native-test.sh b/.github/bin/minikube/test-latest-operator-singlehost-native.sh similarity index 100% rename from .github/bin/minikube/operator-single-host-native-test.sh rename to .github/bin/minikube/test-latest-operator-singlehost-native.sh diff --git a/.github/bin/minishift/test.sh b/.github/bin/minishift/test-latest-operator.sh similarity index 100% rename from .github/bin/minishift/test.sh rename to .github/bin/minishift/test-latest-operator.sh diff --git a/.github/workflows/minikube-singlehost-latest.yaml b/.github/workflows/minikube-latest-singlehost.yaml similarity index 90% rename from .github/workflows/minikube-singlehost-latest.yaml rename to .github/workflows/minikube-latest-singlehost.yaml index 41da5df2b..81568f767 100644 --- a/.github/workflows/minikube-singlehost-latest.yaml +++ b/.github/workflows/minikube-latest-singlehost.yaml @@ -22,7 +22,7 @@ jobs: - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - name: Run tests - run: /bin/bash .github/bin/minikube/single-host-gateway-test.sh + run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-gateway.sh # Run this step even the previous step fail to upload artifacts to GH - uses: actions/upload-artifact@v2 if: ${{ always() }} @@ -39,7 +39,7 @@ jobs: - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - name: Run tests - run: /bin/bash .github/bin/minikube/single-host-native-test.sh + run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-native.sh # Run this step even the previous step fail to upload artifacts to GH - uses: actions/upload-artifact@v2 if: ${{ always() }} diff --git a/.github/workflows/minishift-latest.yaml b/.github/workflows/minishift-latest.yaml index ce1dde747..87521f3a9 100644 --- a/.github/workflows/minishift-latest.yaml +++ b/.github/workflows/minishift-latest.yaml @@ -45,7 +45,7 @@ jobs: - name: Generate Minishift certificates run: /bin/bash .github/bin/minishift/certs.sh - name: Run tests - run: /bin/bash .github/bin/minishift/test.sh + run: /bin/bash .github/bin/minishift/test-latest-operator.sh # Run this step even the previous step fail - uses: actions/upload-artifact@v2 if: ${{ always() }} From f17d4a081ae1c2d85a94a378e12911327354a305 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 11:31:04 +0200 Subject: [PATCH 07/34] Fixes Signed-off-by: Anatolii Bazko --- .ci/cico_updates_minishift.sh | 174 ------------------ .github/bin/common.sh | 71 +++++-- .../bin/minikube/provision-cluster.sh | 0 ...test-latest-operator-singlehost-gateway.sh | 15 +- .../test-latest-operator-singlehost-native.sh | 15 +- .../bin/minikube/test-update-olm.sh | 0 .github/bin/minishift/test-latest-operator.sh | 11 +- .github/bin/minishift/test-update-operator.sh | 100 ++++++++++ .github/workflows/che-update-minikube.yaml | 12 +- .github/workflows/che-update-minishift.yaml | 2 +- .../workflows/minikube-latest-singlehost.yaml | 4 +- .github/workflows/olm_checks_platforms.yaml | 2 +- 12 files changed, 190 insertions(+), 216 deletions(-) delete mode 100755 .ci/cico_updates_minishift.sh rename .ci/start-minikube.sh => .github/bin/minikube/provision-cluster.sh (100%) rename .ci/cico_updates_minikube.sh => .github/bin/minikube/test-update-olm.sh (100%) create mode 100755 .github/bin/minishift/test-update-operator.sh diff --git a/.ci/cico_updates_minishift.sh b/.ci/cico_updates_minishift.sh deleted file mode 100755 index 3e7142ade..000000000 --- a/.ci/cico_updates_minishift.sh +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2020 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 -e - -#Stop execution on any error -trap "catchFinish" EXIT SIGINT - -# Catch_Finish is executed after finish script. -catchFinish() { - result=$? - - if [ "$result" != "0" ]; then - echo "[ERROR] Please check the artifacts in github actions" - getOCCheClusterLogs - exit 1 - fi - - echo "[INFO] Job finished Successfully.Please check the artifacts in github actions" - getOCCheClusterLogs - - exit $result -} - -function init() { - export SCRIPT=$(readlink -f "$0") - export SCRIPT_DIR=$(dirname "$SCRIPT") - export RAM_MEMORY=8192 - export PLATFORM="openshift" - export NAMESPACE="che" - export CHANNEL="stable" - - if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then - OPERATOR_REPO=${WORKSPACE}; - else - OPERATOR_REPO=$(dirname "$SCRIPT_DIR"); - fi - - # Get Stable and new release versions from olm files openshift. - export packageName=eclipse-che-preview-${PLATFORM} - export platformPath=${OPERATOR_REPO}/olm/${packageName} - export packageFolderPath="${platformPath}/deploy/olm-catalog/${packageName}" - export packageFilePath="${packageFolderPath}/${packageName}.package.yaml" - - export lastCSV=$(yq -r ".channels[] | select(.name == \"${CHANNEL}\") | .currentCSV" "${packageFilePath}") - export lastPackageVersion=$(echo "${lastCSV}" | sed -e "s/${packageName}.v//") - export previousCSV=$(sed -n 's|^ *replaces: *\([^ ]*\) *|\1|p' "${packageFolderPath}/${lastPackageVersion}/${packageName}.v${lastPackageVersion}.clusterserviceversion.yaml") - export previousPackageVersion=$(echo "${previousCSV}" | sed -e "s/${packageName}.v//") - - export lastOperatorPath=${OPERATOR_REPO}/tmp/${lastPackageVersion} - export previousOperatorPath=${OPERATOR_REPO}/tmp/${previousPackageVersion} - - export lastOperatorTemplate=${lastOperatorPath}/chectl/templates - export previousOperatorTemplate=${previousOperatorPath}/chectl/templates - - rm -rf tmp - # Create tmp folder to save "operator" installer templates - mkdir -p "${OPERATOR_REPO}/tmp" && chmod 777 "${OPERATOR_REPO}/tmp" - - # clone the exact versions to use their templates - git clone --depth 1 --branch ${previousPackageVersion} https://github.com/eclipse/che-operator/ ${previousOperatorPath} - git clone --depth 1 --branch ${lastPackageVersion} https://github.com/eclipse/che-operator/ ${lastOperatorPath} - - # chectl requires 'che-operator' template folder - mkdir -p "${lastOperatorTemplate}/che-operator" - mkdir -p "${previousOperatorTemplate}/che-operator" - - cp -rf ${previousOperatorPath}/deploy/* "${previousOperatorTemplate}/che-operator" - cp -rf ${lastOperatorPath}/deploy/* "${lastOperatorTemplate}/che-operator" - - # set 'openShiftoAuth: false' - sed -i'.bak' -e "s/openShiftoAuth: .*/openShiftoAuth: false/" "${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" - sed -i'.bak' -e "s/openShiftoAuth: .*/openShiftoAuth: false/" "${lastOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" -} - -function installPreviousStableChe() { - cat "${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" - - # Start last stable version of che - chectl server:deploy --platform=minishift \ - --che-operator-image=quay.io/eclipse/che-operator:${previousPackageVersion} \ - --che-operator-cr-yaml="${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" \ - --templates="${previousOperatorTemplate}" \ - --installer=operator -} - -function waitForNewCheVersion() { - export n=0 - - while [ $n -le 500 ] - do - cheVersion=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheVersion}") - cheIsRunning=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheClusterRunning}" ) - oc get pods -n ${NAMESPACE} - if [ "${cheVersion}" == "${lastPackageVersion}" ] && [ "${cheIsRunning}" == "Available" ] - then - echo -e "\u001b[32m The latest Eclipse Che ${lastCSV} has been deployed \u001b[0m" - break - fi - sleep 6 - n=$(( n+1 )) - done - - if [ $n -gt 360 ] - then - echo "Failed to deploy the latest ${lastCSV} Eclipse Che." - exit 1 - fi -} - -# Utility to get che events and pod logs from openshift -function getOCCheClusterLogs() { - mkdir -p /tmp/artifacts-che - cd /tmp/artifacts-che - - for POD in $(oc get pods -o name -n ${NAMESPACE}); do - for CONTAINER in $(oc get -n ${NAMESPACE} ${POD} -o jsonpath="{.spec.containers[*].name}"); do - echo "" - echo "[INFO] Getting logs from $POD" - echo "" - oc logs ${POD} -c ${CONTAINER} -n ${NAMESPACE} |tee $(echo ${POD}-${CONTAINER}.log | sed 's|pod/||g') - done - done - echo "[INFO] Get events" - oc get events -n ${NAMESPACE}| tee get_events.log - oc get all | tee get_all.log -} - -function minishiftUpdates() { - # Install previous stable version of Eclipse Che - installPreviousStableChe - - # Create an workspace - getCheAcessToken # Function from ./util/ci_common.sh - chectl workspace:create --devfile=${OPERATOR_REPO}/.ci/util/devfile-test.yaml - - # Update the operator to the new release - chectl server:update -y \ - --che-operator-image=quay.io/eclipse/che-operator:${lastPackageVersion} \ - --templates="${lastOperatorTemplate}" - - waitForNewCheVersion - - # Sleep before starting a workspace - sleep 10s - - chectl auth:login -u admin -p admin - chectl workspace:list - workspaceList=$(chectl workspace:list) - - # Grep applied to MacOS - workspaceID=$(echo "$workspaceList" | grep workspace | awk '{ print $1} ') - workspaceID="${workspaceID%'ID'}" - echo "[INFO] Workspace id of created workspace is: ${workspaceID}" - - chectl workspace:start $workspaceID - - # Wait for workspace to be up - waitWorkspaceStart # Function from ./util/ci_common.sh - oc get events -n ${NAMESPACE} -} - -init -source "${OPERATOR_REPO}"/.ci/util/ci_common.sh -minishiftUpdates diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 0a10d0de1..84caeee00 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -41,11 +41,49 @@ init() { # prepare templates directory rm -rf ${TEMPLATES} mkdir -p "${TEMPLATES}/che-operator" && chmod 777 "${TEMPLATES}" - cp -rf ${OPERATOR_REPO}/deploy/* "${TEMPLATES}/che-operator" + # install dependencies installYq } +initLatestTemplates() { + cp -rf ${OPERATOR_REPO}/deploy/* "${TEMPLATES}/che-operator" +} + +initStableTemplates() { + export PLATFORM="openshift" + export NAMESPACE="che" + export CHANNEL="stable" + + # Get Stable and new release versions from olm files openshift. + export packageName=eclipse-che-preview-${PLATFORM} + export platformPath=${OPERATOR_REPO}/olm/${packageName} + export packageFolderPath="${platformPath}/deploy/olm-catalog/${packageName}" + export packageFilePath="${packageFolderPath}/${packageName}.package.yaml" + + export lastCSV=$(yq -r ".channels[] | select(.name == \"${CHANNEL}\") | .currentCSV" "${packageFilePath}") + export lastPackageVersion=$(echo "${lastCSV}" | sed -e "s/${packageName}.v//") + export previousCSV=$(sed -n 's|^ *replaces: *\([^ ]*\) *|\1|p' "${packageFolderPath}/${lastPackageVersion}/${packageName}.v${lastPackageVersion}.clusterserviceversion.yaml") + export previousPackageVersion=$(echo "${previousCSV}" | sed -e "s/${packageName}.v//") + + export lastOperatorPath=${OPERATOR_REPO}/tmp/${lastPackageVersion} + export previousOperatorPath=${OPERATOR_REPO}/tmp/${previousPackageVersion} + + export lastOperatorTemplate=${lastOperatorPath}/chectl/templates + export previousOperatorTemplate=${previousOperatorPath}/chectl/templates + + # clone the exact versions to use their templates + git clone --depth 1 --branch ${previousPackageVersion} https://github.com/eclipse/che-operator/ ${previousOperatorPath} + git clone --depth 1 --branch ${lastPackageVersion} https://github.com/eclipse/che-operator/ ${lastOperatorPath} + + # chectl requires 'che-operator' template folder + mkdir -p "${lastOperatorTemplate}/che-operator" + mkdir -p "${previousOperatorTemplate}/che-operator" + + cp -rf ${previousOperatorPath}/deploy/* "${previousOperatorTemplate}/che-operator" + cp -rf ${lastOperatorPath}/deploy/* "${lastOperatorTemplate}/che-operator" +} + # Utility to wait for a workspace to be started after workspace:create. waitWorkspaceStart() { set +e @@ -106,20 +144,29 @@ copyCheOperatorImageToMinishift() { deployEclipseChe() { local installer=$1 local platform=$2 + local image=$3 + local templates=$4 echo "[INFO] Eclipse Che custom resource" - cat ${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml + cat ${templates}/che-operator/crds/org_v1_che_cr.yaml echo "[INFO] Eclipse Che operator deployment" - cat ${TEMPLATES}/che-operator/operator.yaml + cat ${templates}/che-operator/operator.yaml chectl server:deploy \ --platform=${platform} \ --installer ${installer} \ --chenamespace ${NAMESPACE} \ - --che-operator-image ${OPERATOR_IMAGE} \ - --che-operator-cr-yaml ${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml \ - --templates ${TEMPLATES} + --che-operator-image ${image} \ + --che-operator-cr-yaml ${templates}/che-operator/crds/org_v1_che_cr.yaml \ + --templates ${templates} +} + +updateEclipseChe() { + local image=$1 + local templates=$2 + + chectl server:update -y --che-operator-image=${image} --templates=${templates} } startWorkspace() { @@ -132,22 +179,22 @@ startWorkspace() { } disableOpenShiftOAuth() { - yq -riSY '.spec.auth.openShiftoAuth = false' "${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml" + yq -riSY '.spec.auth.openShiftoAuth = false' "${1}/che-operator/crds/org_v1_che_cr.yaml" } disableUpdateAdminPassword() { - yq -riSY '.spec.auth.updateAdminPassword = false' "${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml" + yq -riSY '.spec.auth.updateAdminPassword = false' "${1}/che-operator/crds/org_v1_che_cr.yaml" } setServerExposureStrategy() { - yq -riSY '.spec.server.serverExposureStrategy = '$1 "${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml" + yq -riSY '.spec.server.serverExposureStrategy = '${2} "${1}/che-operator/crds/org_v1_che_cr.yaml" } setSingleHostExposureType() { - yq -riSY '.spec.k8s.singleHostExposureType = '$1 "${TEMPLATES}/che-operator/crds/org_v1_che_cr.yaml" + yq -riSY '.spec.k8s.singleHostExposureType = '${2} "${1}/che-operator/crds/org_v1_che_cr.yaml" } setCustomOperatorImage() { - yq -riSY '.spec.template.spec.containers[0].image = '${OPERATOR_IMAGE} "${TEMPLATES}/che-operator/operator.yaml" - yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = IfNotPresent' "${TEMPLATES}/che-operator/operator.yaml" + yq -riSY '.spec.template.spec.containers[0].image = '${2} "${1}/che-operator/operator.yaml" + yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = IfNotPresent' "${1}/che-operator/operator.yaml" } diff --git a/.ci/start-minikube.sh b/.github/bin/minikube/provision-cluster.sh similarity index 100% rename from .ci/start-minikube.sh rename to .github/bin/minikube/provision-cluster.sh diff --git a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh index 2f2ed92c7..41cf1b773 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh @@ -14,27 +14,28 @@ set -e set -x set -u -export OPERATOR_REPO=$(dirname $(dirname $(dirname $(readlink -f "$0")))); +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error trap "catchFinish" EXIT SIGINT prepareTemplates() { - disableOpenShiftOAuth - disableUpdateAdminPassword - setCustomOperatorImage - setServerExposureStrategy "single-host" - setSingleHostExposureType "gateway" + disableOpenShiftOAuth ${TEMPLATES} + disableUpdateAdminPassword ${TEMPLATES} + setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE} + setServerExposureStrategy ${TEMPLATES} "single-host" + setSingleHostExposureType ${TEMPLATES}"gateway" } runTest() { prepareTemplates - deployEclipseChe "operator" "minikube" + deployEclipseChe "operator" "minikube" ${OPERATOR_IMAGE} ${TEMPLATES} startWorkspace } init +initLatestTemplates buildCheOperatorImage copyCheOperatorImageToMinikube runTest diff --git a/.github/bin/minikube/test-latest-operator-singlehost-native.sh b/.github/bin/minikube/test-latest-operator-singlehost-native.sh index 95e675f9d..8c0e918bf 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-native.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-native.sh @@ -14,27 +14,28 @@ set -e set -x set -u -export OPERATOR_REPO=$(dirname $(dirname $(dirname $(readlink -f "$0")))); +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error trap "catchFinish" EXIT SIGINT prepareTemplates() { - disableOpenShiftOAuth - disableUpdateAdminPassword - setCustomOperatorImage - setServerExposureStrategy "single-host" - setSingleHostExposureType "native" + disableOpenShiftOAuth ${TEMPLATES} + disableUpdateAdminPassword ${TEMPLATES} + setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE} + setServerExposureStrategy ${TEMPLATES} "single-host" + setSingleHostExposureType ${TEMPLATES} "native" } runTest() { prepareTemplates - deployEclipseChe "operator" "minikube" + deployEclipseChe "operator" "minikube" ${OPERATOR_IMAGE} ${TEMPLATES} startWorkspace } init +initLatestTemplates buildCheOperatorImage copyCheOperatorImageToMinikube runTest diff --git a/.ci/cico_updates_minikube.sh b/.github/bin/minikube/test-update-olm.sh similarity index 100% rename from .ci/cico_updates_minikube.sh rename to .github/bin/minikube/test-update-olm.sh diff --git a/.github/bin/minishift/test-latest-operator.sh b/.github/bin/minishift/test-latest-operator.sh index cc56081f4..3aff70b34 100755 --- a/.github/bin/minishift/test-latest-operator.sh +++ b/.github/bin/minishift/test-latest-operator.sh @@ -14,25 +14,26 @@ set -e set -x set -u -export OPERATOR_REPO=$(dirname $(dirname $(dirname $(readlink -f "$0")))); +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error trap "catchFinish" EXIT SIGINT prepareTemplates() { - disableOpenShiftOAuth - disableUpdateAdminPassword - setCustomOperatorImage + disableOpenShiftOAuth ${TEMPLATES} + disableUpdateAdminPassword ${TEMPLATES} + setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE} } runTest() { prepareTemplates - deployEclipseChe "operator" "minishift" + deployEclipseChe "operator" "minishift" ${OPERATOR_IMAGE} ${TEMPLATES} startWorkspace } init +initLatestTemplates # build is done on previous github action step copyCheOperatorImageToMinishift runTest diff --git a/.github/bin/minishift/test-update-operator.sh b/.github/bin/minishift/test-update-operator.sh new file mode 100755 index 000000000..9b6a88569 --- /dev/null +++ b/.github/bin/minishift/test-update-operator.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# +# Copyright (c) 2020 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 -e +set -x +set -u + +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) +source "${OPERATOR_REPO}"/.github/bin/common.sh + +# Stop execution on any error +trap "catchFinish" EXIT SIGINT + +function installPreviousStableChe() { + cat "${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" + + # Start last stable version of che + chectl server:deploy --platform=minishift \ + --che-operator-image=quay.io/eclipse/che-operator:${previousPackageVersion} \ + --che-operator-cr-yaml="${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" \ + --templates="${previousOperatorTemplate}" \ + --installer=operator +} + +function waitForNewCheVersion() { + export n=0 + + while [ $n -le 500 ] + do + cheVersion=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheVersion}") + cheIsRunning=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheClusterRunning}" ) + oc get pods -n ${NAMESPACE} + if [ "${cheVersion}" == "${lastPackageVersion}" ] && [ "${cheIsRunning}" == "Available" ] + then + echo -e "\u001b[32m The latest Eclipse Che ${lastCSV} has been deployed \u001b[0m" + break + fi + sleep 6 + n=$(( n+1 )) + done + + if [ $n -gt 360 ] + then + echo "Failed to deploy the latest ${lastCSV} Eclipse Che." + exit 1 + fi +} + +prepareTemplates() { + # set 'openShiftoAuth: false' + sed -i'.bak' -e "s/openShiftoAuth: .*/openShiftoAuth: false/" "${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" + sed -i'.bak' -e "s/openShiftoAuth: .*/openShiftoAuth: false/" "${lastOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" +} + +runTest() { + prepareTemplates + + # deployEclipseChe "operator" "minishift" ${OPERATOR_IMAGE} ${TEMPLATES} + + # Create an workspace + chectl auth:login -u admin -p admin + chectl workspace:create --devfile=${OPERATOR_REPO}/.ci/util/devfile-test.yaml + + # Update the operator to the new release + chectl server:update -y \ + --che-operator-image=quay.io/eclipse/che-operator:${lastPackageVersion} \ + --templates="${lastOperatorTemplate}" + + waitForNewCheVersion + + # Sleep before starting a workspace + sleep 10s + + chectl auth:login -u admin -p admin + chectl workspace:list + workspaceList=$(chectl workspace:list) + + # Grep applied to MacOS + workspaceID=$(echo "$workspaceList" | grep workspace | awk '{ print $1} ') + workspaceID="${workspaceID%'ID'}" + echo "[INFO] Workspace id of created workspace is: ${workspaceID}" + + chectl workspace:start $workspaceID + + # Wait for workspace to be up + waitWorkspaceStart # Function from ./util/ci_common.sh +} + +init +initStableTemplates +runTest diff --git a/.github/workflows/che-update-minikube.yaml b/.github/workflows/che-update-minikube.yaml index e373182af..5c66b4fc7 100644 --- a/.github/workflows/che-update-minikube.yaml +++ b/.github/workflows/che-update-minikube.yaml @@ -18,14 +18,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Install minikube kubernetes cluster - run: /bin/bash .ci/start-minikube.sh - - name: Install jq - run: sudo pip install yq + - name: Provision Minikube cluster + run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl - run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - - name: Run che operator updates minikube - run: /bin/bash .ci/cico_updates_minikube.sh + run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=stable + - name: Run tests + run: /bin/bash .github/bin/minikube/test-update-olm.sh # Run this step even the previous step fail - uses: actions/upload-artifact@v2 if: ${{ always() }} diff --git a/.github/workflows/che-update-minishift.yaml b/.github/workflows/che-update-minishift.yaml index ef645f896..118b570e3 100644 --- a/.github/workflows/che-update-minishift.yaml +++ b/.github/workflows/che-update-minishift.yaml @@ -32,7 +32,7 @@ jobs: # Run E2E tests eval $(minishift oc-env) pip install yq - /bin/bash .ci/cico_updates_minishift.sh + /bin/bash .github/bin/minishift/test-update-operator.sh # Run this step even the previous step fail - uses: actions/upload-artifact@v2 if: ${{ always() }} diff --git a/.github/workflows/minikube-latest-singlehost.yaml b/.github/workflows/minikube-latest-singlehost.yaml index 81568f767..7bffa317a 100644 --- a/.github/workflows/minikube-latest-singlehost.yaml +++ b/.github/workflows/minikube-latest-singlehost.yaml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Provision Minikube cluster - run: /bin/bash .ci/start-minikube.sh + run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - name: Run tests @@ -35,7 +35,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Provision Minikube cluster - run: /bin/bash .ci/start-minikube.sh + run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - name: Run tests diff --git a/.github/workflows/olm_checks_platforms.yaml b/.github/workflows/olm_checks_platforms.yaml index 8365a3211..284d81bdc 100644 --- a/.github/workflows/olm_checks_platforms.yaml +++ b/.github/workflows/olm_checks_platforms.yaml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Install minikube kubernetes cluster - run: /bin/bash .ci/start-minikube.sh + run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install jq run: sudo pip install yq - name: Install chectl From 746d836da0f97407ca5a4c61044c8efa6849fb45 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 13:30:06 +0200 Subject: [PATCH 08/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 74 ++++++++++++++---- ...test-latest-operator-singlehost-gateway.sh | 2 +- .../test-latest-operator-singlehost-native.sh | 2 +- .github/bin/minishift/test-latest-operator.sh | 2 +- .github/bin/minishift/test-update-operator.sh | 77 +++---------------- .github/workflows/che-update-minikube.yaml | 2 + .github/workflows/che-update-minishift.yaml | 2 + .../workflows/minikube-latest-singlehost.yaml | 2 + .github/workflows/minishift-latest.yaml | 2 + 9 files changed, 80 insertions(+), 85 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 84caeee00..4b28e80d1 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -41,9 +41,6 @@ init() { # prepare templates directory rm -rf ${TEMPLATES} mkdir -p "${TEMPLATES}/che-operator" && chmod 777 "${TEMPLATES}" - - # install dependencies - installYq } initLatestTemplates() { @@ -51,37 +48,37 @@ initLatestTemplates() { } initStableTemplates() { - export PLATFORM="openshift" - export NAMESPACE="che" - export CHANNEL="stable" + local platform=$1 + local channel=$2 # Get Stable and new release versions from olm files openshift. - export packageName=eclipse-che-preview-${PLATFORM} + export packageName=eclipse-che-preview-${platform} export platformPath=${OPERATOR_REPO}/olm/${packageName} export packageFolderPath="${platformPath}/deploy/olm-catalog/${packageName}" export packageFilePath="${packageFolderPath}/${packageName}.package.yaml" - export lastCSV=$(yq -r ".channels[] | select(.name == \"${CHANNEL}\") | .currentCSV" "${packageFilePath}") - export lastPackageVersion=$(echo "${lastCSV}" | sed -e "s/${packageName}.v//") + export lastCSV=$(yq -r ".channels[] | select(.name == \"${channel}\") | .currentCSV" "${packageFilePath}") + export LAST_PACKAGE_VERSION=$(echo "${lastCSV}" | sed -e "s/${packageName}.v//") + export previousCSV=$(sed -n 's|^ *replaces: *\([^ ]*\) *|\1|p' "${packageFolderPath}/${lastPackageVersion}/${packageName}.v${lastPackageVersion}.clusterserviceversion.yaml") - export previousPackageVersion=$(echo "${previousCSV}" | sed -e "s/${packageName}.v//") + export PREVIOUS_PACKAGE_VERSION=$(echo "${previousCSV}" | sed -e "s/${packageName}.v//") export lastOperatorPath=${OPERATOR_REPO}/tmp/${lastPackageVersion} export previousOperatorPath=${OPERATOR_REPO}/tmp/${previousPackageVersion} - export lastOperatorTemplate=${lastOperatorPath}/chectl/templates - export previousOperatorTemplate=${previousOperatorPath}/chectl/templates + export LAST_OPERATOR_TEMPLATE=${lastOperatorPath}/chectl/templates + export PREVIOUS_OPERATOR_TEMPLATE=${previousOperatorPath}/chectl/templates # clone the exact versions to use their templates git clone --depth 1 --branch ${previousPackageVersion} https://github.com/eclipse/che-operator/ ${previousOperatorPath} git clone --depth 1 --branch ${lastPackageVersion} https://github.com/eclipse/che-operator/ ${lastOperatorPath} # chectl requires 'che-operator' template folder - mkdir -p "${lastOperatorTemplate}/che-operator" - mkdir -p "${previousOperatorTemplate}/che-operator" + mkdir -p "${LAST_OPERATOR_TEMPLATE}/che-operator" + mkdir -p "${PREVIOUS_OPERATOR_TEMPLATE}/che-operator" - cp -rf ${previousOperatorPath}/deploy/* "${previousOperatorTemplate}/che-operator" - cp -rf ${lastOperatorPath}/deploy/* "${lastOperatorTemplate}/che-operator" + cp -rf ${previousOperatorPath}/deploy/* "${PREVIOUS_OPERATOR_TEMPLATE}/che-operator" + cp -rf ${lastOperatorPath}/deploy/* "${LAST_OPERATOR_TEMPLATE}/che-operator" } # Utility to wait for a workspace to be started after workspace:create. @@ -162,6 +159,31 @@ deployEclipseChe() { --templates ${templates} } +waitEclipseCheDeployed() { + local version=$1 + export n=0 + + while [ $n -le 500 ] + do + cheVersion=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheVersion}") + cheIsRunning=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheClusterRunning}" ) + oc get pods -n ${NAMESPACE} + if [ "${cheVersion}" == "${version}" ] && [ "${cheIsRunning}" == "Available" ] + then + echo -e "\u001b[32m Eclipse Che ${version} has been succesfully deployed \u001b[0m" + break + fi + sleep 6 + n=$(( n+1 )) + done + + if [ $n -gt 360 ] + then + echo "Failed to deploy Eclipse Che ${version}" + exit 1 + fi +} + updateEclipseChe() { local image=$1 local templates=$2 @@ -169,7 +191,7 @@ updateEclipseChe() { chectl server:update -y --che-operator-image=${image} --templates=${templates} } -startWorkspace() { +startNewWorkspace() { # Create and start a workspace chectl auth:login -u admin -p admin chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml @@ -178,6 +200,24 @@ startWorkspace() { waitWorkspaceStart } +createWorkspace() { + chectl auth:login -u admin -p admin + chectl workspace:create --devfile=${OPERATOR_REPO}/.ci/util/devfile-test.yaml +} + +startExistedWorkspace() { + chectl auth:login -u admin -p admin + chectl workspace:list + workspaceList=$(chectl workspace:list) + + # Grep applied to MacOS + workspaceID=$(echo "$workspaceList" | grep workspace | awk '{ print $1} ') + workspaceID="${workspaceID%'ID'}" + echo "[INFO] Workspace id of created workspace is: ${workspaceID}" + + chectl workspace:start $workspaceID +} + disableOpenShiftOAuth() { yq -riSY '.spec.auth.openShiftoAuth = false' "${1}/che-operator/crds/org_v1_che_cr.yaml" } diff --git a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh index 41cf1b773..b47fdea4f 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh @@ -31,7 +31,7 @@ prepareTemplates() { runTest() { prepareTemplates deployEclipseChe "operator" "minikube" ${OPERATOR_IMAGE} ${TEMPLATES} - startWorkspace + startNewWorkspace } init diff --git a/.github/bin/minikube/test-latest-operator-singlehost-native.sh b/.github/bin/minikube/test-latest-operator-singlehost-native.sh index 8c0e918bf..1f7172c7b 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-native.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-native.sh @@ -31,7 +31,7 @@ prepareTemplates() { runTest() { prepareTemplates deployEclipseChe "operator" "minikube" ${OPERATOR_IMAGE} ${TEMPLATES} - startWorkspace + startNewWorkspace } init diff --git a/.github/bin/minishift/test-latest-operator.sh b/.github/bin/minishift/test-latest-operator.sh index 3aff70b34..fb282e14d 100755 --- a/.github/bin/minishift/test-latest-operator.sh +++ b/.github/bin/minishift/test-latest-operator.sh @@ -29,7 +29,7 @@ prepareTemplates() { runTest() { prepareTemplates deployEclipseChe "operator" "minishift" ${OPERATOR_IMAGE} ${TEMPLATES} - startWorkspace + startNewWorkspace } init diff --git a/.github/bin/minishift/test-update-operator.sh b/.github/bin/minishift/test-update-operator.sh index 9b6a88569..ba5f2ecfd 100755 --- a/.github/bin/minishift/test-update-operator.sh +++ b/.github/bin/minishift/test-update-operator.sh @@ -20,81 +20,28 @@ source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error trap "catchFinish" EXIT SIGINT -function installPreviousStableChe() { - cat "${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" - - # Start last stable version of che - chectl server:deploy --platform=minishift \ - --che-operator-image=quay.io/eclipse/che-operator:${previousPackageVersion} \ - --che-operator-cr-yaml="${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" \ - --templates="${previousOperatorTemplate}" \ - --installer=operator -} - -function waitForNewCheVersion() { - export n=0 - - while [ $n -le 500 ] - do - cheVersion=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheVersion}") - cheIsRunning=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheClusterRunning}" ) - oc get pods -n ${NAMESPACE} - if [ "${cheVersion}" == "${lastPackageVersion}" ] && [ "${cheIsRunning}" == "Available" ] - then - echo -e "\u001b[32m The latest Eclipse Che ${lastCSV} has been deployed \u001b[0m" - break - fi - sleep 6 - n=$(( n+1 )) - done - - if [ $n -gt 360 ] - then - echo "Failed to deploy the latest ${lastCSV} Eclipse Che." - exit 1 - fi -} - prepareTemplates() { - # set 'openShiftoAuth: false' - sed -i'.bak' -e "s/openShiftoAuth: .*/openShiftoAuth: false/" "${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" - sed -i'.bak' -e "s/openShiftoAuth: .*/openShiftoAuth: false/" "${lastOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" + disableOpenShiftOAuth ${PREVIOUS_OPERATOR_TEMPLATE} + disableOpenShiftOAuth ${LAST_OPERATOR_TEMPLATE} } runTest() { prepareTemplates - # deployEclipseChe "operator" "minishift" ${OPERATOR_IMAGE} ${TEMPLATES} - - # Create an workspace - chectl auth:login -u admin -p admin - chectl workspace:create --devfile=${OPERATOR_REPO}/.ci/util/devfile-test.yaml - - # Update the operator to the new release - chectl server:update -y \ - --che-operator-image=quay.io/eclipse/che-operator:${lastPackageVersion} \ - --templates="${lastOperatorTemplate}" - - waitForNewCheVersion - - # Sleep before starting a workspace - sleep 10s - - chectl auth:login -u admin -p admin - chectl workspace:list - workspaceList=$(chectl workspace:list) + deployEclipseChe "operator" "minishift" "quay.io/eclipse/che-operator:${PREVIOUS_PACKAGE_VERSION}" ${PREVIOUS_OPERATOR_TEMPLATE} + sleep 5s - # Grep applied to MacOS - workspaceID=$(echo "$workspaceList" | grep workspace | awk '{ print $1} ') - workspaceID="${workspaceID%'ID'}" - echo "[INFO] Workspace id of created workspace is: ${workspaceID}" + createWorkspace + sleep 5s - chectl workspace:start $workspaceID + updateEclipseChe "quay.io/eclipse/che-operator:${LAST_PACKAGE_VERSION}" ${LAST_OPERATOR_TEMPLATE} + waitEclipseCheDeployed ${LAST_PACKAGE_VERSION} + sleep 5s - # Wait for workspace to be up - waitWorkspaceStart # Function from ./util/ci_common.sh + startExistedWorkspace + waitWorkspaceStart } init -initStableTemplates +initStableTemplates "openshift" "stable" runTest diff --git a/.github/workflows/che-update-minikube.yaml b/.github/workflows/che-update-minikube.yaml index 5c66b4fc7..1978bb0f7 100644 --- a/.github/workflows/che-update-minikube.yaml +++ b/.github/workflows/che-update-minikube.yaml @@ -22,6 +22,8 @@ jobs: run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=stable + - name: Install jq + run: sudo pip install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-update-olm.sh # Run this step even the previous step fail diff --git a/.github/workflows/che-update-minishift.yaml b/.github/workflows/che-update-minishift.yaml index 118b570e3..aef6bbe97 100644 --- a/.github/workflows/che-update-minishift.yaml +++ b/.github/workflows/che-update-minishift.yaml @@ -20,6 +20,8 @@ jobs: - uses: actions/checkout@v1 - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next + - name: Install jq + run: sudo pip install yq - name: Install and start minishift OCP 3.11 cluster run: | brew cask install minishift diff --git a/.github/workflows/minikube-latest-singlehost.yaml b/.github/workflows/minikube-latest-singlehost.yaml index 7bffa317a..535f28541 100644 --- a/.github/workflows/minikube-latest-singlehost.yaml +++ b/.github/workflows/minikube-latest-singlehost.yaml @@ -38,6 +38,8 @@ jobs: run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next + - name: Install jq + run: sudo pip install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-native.sh # Run this step even the previous step fail to upload artifacts to GH diff --git a/.github/workflows/minishift-latest.yaml b/.github/workflows/minishift-latest.yaml index 87521f3a9..a5e8964d9 100644 --- a/.github/workflows/minishift-latest.yaml +++ b/.github/workflows/minishift-latest.yaml @@ -44,6 +44,8 @@ jobs: run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - name: Generate Minishift certificates run: /bin/bash .github/bin/minishift/certs.sh + - name: Install jq + run: sudo pip install yq - name: Run tests run: /bin/bash .github/bin/minishift/test-latest-operator.sh # Run this step even the previous step fail From 067231b737cda782d01c7957294266e49dffc820 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 13:35:12 +0200 Subject: [PATCH 09/34] Fixes Signed-off-by: Anatolii Bazko --- .github/workflows/minishift-latest.yaml | 2 +- ...ift.yaml => minishift-stable-updates.yaml} | 20 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) rename .github/workflows/{che-update-minishift.yaml => minishift-stable-updates.yaml} (76%) diff --git a/.github/workflows/minishift-latest.yaml b/.github/workflows/minishift-latest.yaml index a5e8964d9..cc8481eb5 100644 --- a/.github/workflows/minishift-latest.yaml +++ b/.github/workflows/minishift-latest.yaml @@ -42,7 +42,7 @@ jobs: minishift start --memory=5500 --vm-driver=virtualbox - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - - name: Generate Minishift certificates + - name: Replace Minishift default certificates run: /bin/bash .github/bin/minishift/certs.sh - name: Install jq run: sudo pip install yq diff --git a/.github/workflows/che-update-minishift.yaml b/.github/workflows/minishift-stable-updates.yaml similarity index 76% rename from .github/workflows/che-update-minishift.yaml rename to .github/workflows/minishift-stable-updates.yaml index aef6bbe97..075925490 100644 --- a/.github/workflows/che-update-minishift.yaml +++ b/.github/workflows/minishift-stable-updates.yaml @@ -18,23 +18,19 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v1 - - name: Install chectl - run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - - name: Install jq - run: sudo pip install yq - - name: Install and start minishift OCP 3.11 cluster + - name: Provision Minishift cluster run: | brew cask install minishift export MINISHIFT_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} minishift start --memory=5500 --vm-driver=virtualbox - - name: Generate minishift certificates - run: /bin/bash .github/action_scripts/minishift_cert_gen.sh + - name: Install chectl + run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=stable + - name: Install jq + run: sudo pip install yq + - name: Replace Minishift default certificates + run: /bin/bash .github/bin/minishift/certs.sh - name: Update minishift deprecated certificates and run e2e - run: | - # Run E2E tests - eval $(minishift oc-env) - pip install yq - /bin/bash .github/bin/minishift/test-update-operator.sh + run: /bin/bash .github/bin/minishift/test-update-operator.sh # Run this step even the previous step fail - uses: actions/upload-artifact@v2 if: ${{ always() }} From ac6ef271cf69000f40df45855c74f0bb3df9580f Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 13:53:06 +0200 Subject: [PATCH 10/34] Fixes Signed-off-by: Anatolii Bazko --- .github/workflows/e2e.yaml | 60 ------------------- .../workflows/minikube-latest-singlehost.yaml | 12 +++- .github/workflows/minishift-e2e.yaml | 34 +++++++++++ .github/workflows/minishift-latest.yaml | 7 ++- 4 files changed, 49 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/e2e.yaml create mode 100644 .github/workflows/minishift-e2e.yaml diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml deleted file mode 100644 index da23624fb..000000000 --- a/.github/workflows/e2e.yaml +++ /dev/null @@ -1,60 +0,0 @@ -# -# Copyright (c) 2012-2020 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 -name: Minishift -on: pull_request -jobs: - minishift-e2e: - name: e2e tests - runs-on: macos-latest - steps: - - uses: actions/checkout@v1 - - name: Build operator image - run: | - export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test - # coreutils provides a readlink that supports `-f` - - brew install coreutils docker docker-machine - - mkdir -p ~/.docker/machine/cache/ - sudo curl -Lo ~/.docker/machine/cache/boot2docker.iso https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso - - docker-machine --github-api-token="${{ secrets.GITHUB_TOKEN }}" create --driver virtualbox default - eval "$(docker-machine env default)" - export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" - - docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker save "${OPERATOR_IMAGE}" > operator.tar - sed -i'.bak' -e "s|quay.io\/eclipse\/che-operator:nightly|$OPERATOR_IMAGE|" deploy/operator-local.yaml - - docker-machine stop - - name: Install and start minishift OCP 3.11 cluster - run: | - brew cask install minishift - export MINISHIFT_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} - minishift start --memory=5500 --vm-driver=virtualbox - - name: Generate minishift certificates - run: /bin/bash .github/action_scripts/minishift_cert_gen.sh - - name: Update minishift deprecated certificates and run e2e - run: | - eval $(minishift oc-env) - eval $(minishift docker-env) && docker load -i operator.tar && rm operator.tar - - # Run E2E tests - cat deploy/operator-local.yaml - - oc apply -f deploy/crds/org_v1_che_crd.yaml - go mod tidy - go run e2e/*.go - - oc get events -n che - - uses: actions/upload-artifact@v2 - with: - name: minishift-e2e-artifacts - path: /tmp/artifacts-che diff --git a/.github/workflows/minikube-latest-singlehost.yaml b/.github/workflows/minikube-latest-singlehost.yaml index 535f28541..6ceb5fee0 100644 --- a/.github/workflows/minikube-latest-singlehost.yaml +++ b/.github/workflows/minikube-latest-singlehost.yaml @@ -21,6 +21,11 @@ jobs: run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next + - name: Install operator courier + run: | + python -m pip install --upgrade pip + pip install operator-courier==2.1.7 + pip install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-gateway.sh # Run this step even the previous step fail to upload artifacts to GH @@ -38,8 +43,11 @@ jobs: run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - - name: Install jq - run: sudo pip install yq + - name: Install operator courier + run: | + python -m pip install --upgrade pip + pip install operator-courier==2.1.7 + pip install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-native.sh # Run this step even the previous step fail to upload artifacts to GH diff --git a/.github/workflows/minishift-e2e.yaml b/.github/workflows/minishift-e2e.yaml new file mode 100644 index 000000000..4f907376d --- /dev/null +++ b/.github/workflows/minishift-e2e.yaml @@ -0,0 +1,34 @@ +# +# Copyright (c) 2012-2020 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 +name: Minishift +on: pull_request +jobs: + minishift-e2e: + name: e2e tests + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - name: Provision Minishift cluster + run: | + brew cask install minishift + export MINISHIFT_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} + minishift start --memory=5500 --vm-driver=virtualbox + - name: Replace Minishift default certificates + run: /bin/bash .github/bin/minishift/certs.sh + - name: Run tests + run: | + oc apply -f deploy/crds/org_v1_che_crd.yaml + go mod tidy + go run e2e/*.go + - uses: actions/upload-artifact@v2 + with: + name: minishift-e2e-artifacts + path: /tmp/artifacts-che diff --git a/.github/workflows/minishift-latest.yaml b/.github/workflows/minishift-latest.yaml index cc8481eb5..eecd24d57 100644 --- a/.github/workflows/minishift-latest.yaml +++ b/.github/workflows/minishift-latest.yaml @@ -44,8 +44,11 @@ jobs: run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - name: Replace Minishift default certificates run: /bin/bash .github/bin/minishift/certs.sh - - name: Install jq - run: sudo pip install yq + - name: Install operator courier + run: | + python -m pip install --upgrade pip + pip install operator-courier==2.1.7 + pip install yq - name: Run tests run: /bin/bash .github/bin/minishift/test-latest-operator.sh # Run this step even the previous step fail From 9607377c9ec599fa8c86d515c4adc0387fa95b92 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 14:14:21 +0200 Subject: [PATCH 11/34] Fixes Signed-off-by: Anatolii Bazko --- .ci/cico_olm_minikube.sh | 99 ------------------- .../nightly/minikube/function-utilities.sh | 78 --------------- .github/bin/common.sh | 17 ++++ .github/bin/minikube/test-latest-olm.sh | 32 ++++++ ...latforms.yaml => minikube-latest-olm.yaml} | 17 ++-- ... minikube-latest-operator-singlehost.yaml} | 0 6 files changed, 59 insertions(+), 184 deletions(-) delete mode 100755 .ci/cico_olm_minikube.sh delete mode 100644 .github/action_scripts/nightly/minikube/function-utilities.sh create mode 100755 .github/bin/minikube/test-latest-olm.sh rename .github/workflows/{olm_checks_platforms.yaml => minikube-latest-olm.yaml} (63%) rename .github/workflows/{minikube-latest-singlehost.yaml => minikube-latest-operator-singlehost.yaml} (100%) diff --git a/.ci/cico_olm_minikube.sh b/.ci/cico_olm_minikube.sh deleted file mode 100755 index f04e2adf4..000000000 --- a/.ci/cico_olm_minikube.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2012-2020 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 -# - -set -ex -# Detect the base directory where che-operator is cloned -SCRIPT=$(readlink -f "$0") -export SCRIPT - -OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")"); -export OPERATOR_REPO - -# Import operator bash utilities -source "${OPERATOR_REPO}"/.ci/util/ci_common.sh - -# Container image name of Catalog source -CATALOG_SOURCE_IMAGE=my_image -export CATALOG_SOURCE_IMAGE - -# Choose if install Eclipse Che using an operatorsource or Custom Catalog Source -INSTALLATION_TYPE="catalog" -export INSTALLATION_TYPE - -# Execute olm nightly files in openshift -PLATFORM="kubernetes" -export PLATFORM - -# Test nightly olm files -CHANNEL="nightly" -export CHANNEL - -# Test nightly olm files -NAMESPACE="che" -export NAMESPACE - -# Operator image -OPERATOR_IMAGE="quay.io/eclipse/che-operator:nightly" -export OPERATOR_IMAGE - -IMAGE_REGISTRY_HOST="0.0.0.0:5000" -export IMAGE_REGISTRY_HOST - -#Stop execution on any error -trap "catchFinish" EXIT SIGINT - -# Catch_Finish is executed after finish script. -catchFinish() { - result=$? - - if [ "$result" != "0" ]; then - echo "[ERROR] Please check the artifacts in github actions" - getCheClusterLogs - exit 1 - fi - - echo "[INFO] Job finished Successfully.Please check the artifacts in github actions" - getCheClusterLogs - - exit $result -} - -# run function run the tests in ci of custom catalog source. -function run() { - # Execute test catalog source script - source "${OPERATOR_REPO}"/olm/testCatalogSource.sh ${PLATFORM} ${CHANNEL} ${NAMESPACE} ${INSTALLATION_TYPE} ${CATALOG_SOURCE_IMAGE} - - # Create and start a workspace - getCheAcessToken - chectl workspace:create --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml - - getCheAcessToken - workspaceList=$(chectl workspace:list) - workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b') - chectl workspace:start $workspaceID - waitWorkspaceStart -} - -function setPrivateRegistryForDocker { - dockerDaemonConfig="/etc/docker/daemon.json" - sudo mkdir -p "/etc/docker" - sudo touch "${dockerDaemonConfig}" - - config="{\"insecure-registries\" : [\"${IMAGE_REGISTRY_HOST}\"]}" - echo "${config}" | sudo tee "${dockerDaemonConfig}" - - if [ -x "$(command -v docker)" ]; then - echo "[INFO] Restart docker daemon to set up private registry info." - sudo service docker restart - fi -} - -setPrivateRegistryForDocker -run diff --git a/.github/action_scripts/nightly/minikube/function-utilities.sh b/.github/action_scripts/nightly/minikube/function-utilities.sh deleted file mode 100644 index 3905df1a3..000000000 --- a/.github/action_scripts/nightly/minikube/function-utilities.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) 2020 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 - -# exit immediately when a command fails -set -e -# only exit with zero if all commands of the pipeline exit successfully -set -o pipefail -# error on unset variables -set -u -# print each command before executing it -set -x - -# Build latest operator image -function buildCheOperatorImage() { - docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker save "${OPERATOR_IMAGE}" > operator.tar - eval $(minikube docker-env) && docker load -i operator.tar && rm operator.tar -} - -# Get Token from single host mode deployment -function getSingleHostToken() { - export GATEWAY_HOSTNAME=$(minikube ip).nip.io - export CHE_API_ENDPOINT="https://${GATEWAY_HOSTNAME}/api" - export TOKEN_ENDPOINT="https://${GATEWAY_HOSTNAME}/auth/realms/che/protocol/openid-connect/token" - export CHE_ACCESS_TOKEN=$(curl --data "grant_type=password&client_id=che-public&username=admin&password=admin" -k ${TOKEN_ENDPOINT} | jq -r .access_token) -} - -# Utility to wait for a workspace to be started after workspace:create. -function waitSingleHostWorkspaceStart() { - set +e - export x=0 - while [ $x -le 180 ] - do - getSingleHostToken - - # List Workspaces and get the status - echo "[INFO] Getting workspace status:" - chectl workspace:list - workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE}) - workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ') - - if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ] - then - echo "[INFO] Workspace started successfully" - break - fi - sleep 10 - x=$(( x+1 )) - done - - if [ $x -gt 180 ] - then - echo "[ERROR] Workspace didn't start after 3 minutes." - exit 1 - fi -} - -# Get the access token from keycloak in openshift platforms and kubernetes -function getCheAcessToken() { - if [[ ${PLATFORM} == "openshift" ]] - then - KEYCLOAK_HOSTNAME=$(oc get route -n ${NAMESPACE} keycloak --template={{.spec.host}}) - TOKEN_ENDPOINT="https://${KEYCLOAK_HOSTNAME}/auth/realms/che/protocol/openid-connect/token" - export CHE_ACCESS_TOKEN=$(curl --data "grant_type=password&client_id=che-public&username=admin&password=admin" -k ${TOKEN_ENDPOINT} | jq -r .access_token) - else - KEYCLOAK_HOSTNAME=$(minikube ip).nip.io - TOKEN_ENDPOINT="https://${KEYCLOAK_HOSTNAME}/auth/realms/che/protocol/openid-connect/token" - export CHE_ACCESS_TOKEN=$(curl --data "grant_type=password&client_id=che-public&username=admin&password=admin" -k ${TOKEN_ENDPOINT} | jq -r .access_token) - fi -} diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 4b28e80d1..bd76cccf1 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -238,3 +238,20 @@ setCustomOperatorImage() { yq -riSY '.spec.template.spec.containers[0].image = '${2} "${1}/che-operator/operator.yaml" yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = IfNotPresent' "${1}/che-operator/operator.yaml" } + +insecurePrivateDockerRegistry() { + IMAGE_REGISTRY_HOST="0.0.0.0:5000" + export IMAGE_REGISTRY_HOST + + local dockerDaemonConfig="/etc/docker/daemon.json" + sudo mkdir -p "/etc/docker" + sudo touch "${dockerDaemonConfig}" + + config="{\"insecure-registries\" : [\"${IMAGE_REGISTRY_HOST}\"]}" + echo "${config}" | sudo tee "${dockerDaemonConfig}" + + if [ -x "$(command -v docker)" ]; then + echo "[INFO] Restart docker daemon to set up private registry info." + sudo service docker restart + fi +} diff --git a/.github/bin/minikube/test-latest-olm.sh b/.github/bin/minikube/test-latest-olm.sh new file mode 100755 index 000000000..b74604eaa --- /dev/null +++ b/.github/bin/minikube/test-latest-olm.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Copyright (c) 2012-2020 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 +# + +set -e +set -x +set -u + +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) +source "${OPERATOR_REPO}"/.github/bin/common.sh + +# Stop execution on any error +trap "catchFinish" EXIT SIGINT + +runTest() { + source "${OPERATOR_REPO}"/olm/testCatalogSource.sh "kubernetes" "nightly" ${NAMESPACE} "catalog" "my_image" + + sleep 5s + + startNewWorkspace + waitWorkspaceStart +} + +init +insecurePrivateDockerRegistry +runTest diff --git a/.github/workflows/olm_checks_platforms.yaml b/.github/workflows/minikube-latest-olm.yaml similarity index 63% rename from .github/workflows/olm_checks_platforms.yaml rename to .github/workflows/minikube-latest-olm.yaml index 284d81bdc..7ecd236f0 100644 --- a/.github/workflows/olm_checks_platforms.yaml +++ b/.github/workflows/minikube-latest-olm.yaml @@ -18,14 +18,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Install minikube kubernetes cluster - run: /bin/bash .github/bin/minikube/provision-cluster.sh - - name: Install jq - run: sudo pip install yq + - name: Provision Minikube cluster + run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl - run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - - name: Run che operator updates minikube - run: /bin/bash .ci/cico_olm_minikube.sh + run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next + - name: Install operator courier + run: | + python -m pip install --upgrade pip + pip install operator-courier==2.1.7 + pip install yq + - name: Run tests + run: /bin/bash .github/bin/minikube/test-latest-olm.sh # Run this step even the previous step fail - uses: actions/upload-artifact@v2 if: ${{ always() }} diff --git a/.github/workflows/minikube-latest-singlehost.yaml b/.github/workflows/minikube-latest-operator-singlehost.yaml similarity index 100% rename from .github/workflows/minikube-latest-singlehost.yaml rename to .github/workflows/minikube-latest-operator-singlehost.yaml From 48650dbddc1b2c56ff294d099831698d78b60186 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 14:15:27 +0200 Subject: [PATCH 12/34] Fixes Signed-off-by: Anatolii Bazko --- ...e-update-minikube.yaml => minikube-stable-updates.yaml} | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) rename .github/workflows/{che-update-minikube.yaml => minikube-stable-updates.yaml} (86%) diff --git a/.github/workflows/che-update-minikube.yaml b/.github/workflows/minikube-stable-updates.yaml similarity index 86% rename from .github/workflows/che-update-minikube.yaml rename to .github/workflows/minikube-stable-updates.yaml index 1978bb0f7..62b592864 100644 --- a/.github/workflows/che-update-minikube.yaml +++ b/.github/workflows/minikube-stable-updates.yaml @@ -22,8 +22,11 @@ jobs: run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=stable - - name: Install jq - run: sudo pip install yq + - name: Install operator courier + run: | + python -m pip install --upgrade pip + pip install operator-courier==2.1.7 + pip install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-update-olm.sh # Run this step even the previous step fail From 243b421b4b52503f1d05a98512a5e3147b6ea59e Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 14:39:50 +0200 Subject: [PATCH 13/34] Fixes Signed-off-by: Anatolii Bazko --- .../check-nightly-olm-bundle.sh} | 0 .../push-catalog-and-bundle-images.sh} | 0 ...kNightlyOpmBundle.yaml => check-nightly-olm-bundle.yaml} | 6 +++--- ...operator-build-nightly.yaml => nightly-image-build.yaml} | 0 ...talogImages.yaml => push-catalog-and-bundle-images.yaml} | 4 ++-- 5 files changed, 5 insertions(+), 5 deletions(-) rename .github/{action_scripts/operator_code_check.sh => bin/check-nightly-olm-bundle.sh} (100%) rename .github/{action_scripts/build_olm_bundle_images.sh => bin/push-catalog-and-bundle-images.sh} (100%) rename .github/workflows/{checkNightlyOpmBundle.yaml => check-nightly-olm-bundle.yaml} (86%) rename .github/workflows/{operator-build-nightly.yaml => nightly-image-build.yaml} (100%) rename .github/workflows/{pushCatalogImages.yaml => push-catalog-and-bundle-images.yaml} (90%) diff --git a/.github/action_scripts/operator_code_check.sh b/.github/bin/check-nightly-olm-bundle.sh similarity index 100% rename from .github/action_scripts/operator_code_check.sh rename to .github/bin/check-nightly-olm-bundle.sh diff --git a/.github/action_scripts/build_olm_bundle_images.sh b/.github/bin/push-catalog-and-bundle-images.sh similarity index 100% rename from .github/action_scripts/build_olm_bundle_images.sh rename to .github/bin/push-catalog-and-bundle-images.sh diff --git a/.github/workflows/checkNightlyOpmBundle.yaml b/.github/workflows/check-nightly-olm-bundle.yaml similarity index 86% rename from .github/workflows/checkNightlyOpmBundle.yaml rename to .github/workflows/check-nightly-olm-bundle.yaml index f65fc8d4f..1bc7aec03 100644 --- a/.github/workflows/checkNightlyOpmBundle.yaml +++ b/.github/workflows/check-nightly-olm-bundle.yaml @@ -10,12 +10,12 @@ # Red Hat, Inc. - initial API and implementation # -name: Check nightly "opm" bundle +name: Check nightly OLM bundle on: pull_request jobs: build: - name: Check nightly "opm" bundle + name: Check nightly OLM bundle runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 @@ -28,4 +28,4 @@ jobs: echo "GOPATH: ${GOPATH}" && export GITHUB_WORKSPACE="${GOPATH}/src/github.com/eclipse/${{ github.repository }}" && cd ${GITHUB_WORKSPACE} && - .github/action_scripts/operator_code_check.sh + .github/bin/check-nightly-olm-bundle.sh diff --git a/.github/workflows/operator-build-nightly.yaml b/.github/workflows/nightly-image-build.yaml similarity index 100% rename from .github/workflows/operator-build-nightly.yaml rename to .github/workflows/nightly-image-build.yaml diff --git a/.github/workflows/pushCatalogImages.yaml b/.github/workflows/push-catalog-and-bundle-images.yaml similarity index 90% rename from .github/workflows/pushCatalogImages.yaml rename to .github/workflows/push-catalog-and-bundle-images.yaml index 68b17c1df..28bcd332d 100644 --- a/.github/workflows/pushCatalogImages.yaml +++ b/.github/workflows/push-catalog-and-bundle-images.yaml @@ -20,7 +20,7 @@ jobs: build: name: Build runs-on: ubuntu-20.04 - + steps: - uses: actions/checkout@v1 @@ -32,4 +32,4 @@ jobs: password: ${{ secrets.QUAY_PASSWORD }} - name: Build catalog source and opm bundle images and push - run: "${GITHUB_WORKSPACE}/.github/action_scripts/build_olm_bundle_images.sh" + run: "${GITHUB_WORKSPACE}/.github/bin/push-catalog-and-bundle-images.sh" From 7d14d74266e3809412502a18d38afa9ac34db0ae Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 16:04:51 +0200 Subject: [PATCH 14/34] Fixes Signed-off-by: Anatolii Bazko --- .ci/cico_olm_openshift.sh | 64 ++------- .ci/cico_openshift_shost.sh | 131 ++++-------------- .ci/cico_updates_openshift.sh | 82 ++--------- .github/bin/common.sh | 4 +- .github/bin/minikube/test-latest-olm.sh | 3 - ...test-latest-operator-singlehost-gateway.sh | 1 + .../test-latest-operator-singlehost-native.sh | 1 + .github/bin/minikube/test-update-olm.sh | 96 ++----------- .github/bin/minishift/test-latest-operator.sh | 1 + 9 files changed, 67 insertions(+), 316 deletions(-) diff --git a/.ci/cico_olm_openshift.sh b/.ci/cico_olm_openshift.sh index 58b3f5632..f992492ef 100755 --- a/.ci/cico_olm_openshift.sh +++ b/.ci/cico_olm_openshift.sh @@ -9,65 +9,29 @@ # set -e - -# Detect the base directory where che-operator is cloned -SCRIPT=$(readlink -f "$0") -export SCRIPT - -OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")"); -export OPERATOR_REPO - -# ENV used by Openshift CI -ARTIFACTS_DIR="/tmp/artifacts" -export ARTIFACTS_DIR +set -x +set -u # Component is defined in Openshift CI job configuration. See: https://github.com/openshift/release/blob/master/ci-operator/config/devfile/devworkspace-operator/devfile-devworkspace-operator-master__v4.yaml#L8 -CI_COMPONENT="che-operator-catalog" -export CI_COMPONENT - -CATALOG_SOURCE_IMAGE_NAME=${CI_COMPONENT}:stable -export CATALOG_SOURCE_IMAGE_NAME - -# This image is builded by Openshift CI and exposed to be consumed for olm tests. -#OPENSHIFT_BUILD_NAMESPACE env var exposed by Openshift CI. More info about how images are builded in Openshift CI: https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates -CATALOG_SOURCE_IMAGE="che-catalog" -export CATALOG_SOURCE_IMAGE - -# Choose if install Eclipse Che using an operatorsource or Custom Catalog Source -INSTALLATION_TYPE="catalog" -export INSTALLATION_TYPE +export CI_COMPONENT="che-operator-catalog" +export CATALOG_SOURCE_IMAGE_NAME=${CI_COMPONENT}:stable -# Execute olm nightly files in openshift -PLATFORM="openshift" -export PLATFORM +export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0"))); +source "${OPERATOR_REPO}"/.github/bin/common.sh -# Test nightly olm files -CHANNEL="nightly" -export CHANNEL - -# Test nightly olm files -NAMESPACE="che" -export NAMESPACE +trap "catchFinish" EXIT SIGINT # run function run the tests in ci of custom catalog source. -function run() { +function runTests() { + # see olm.sh export OAUTH="false" - # Execute test catalog source script - source "${OPERATOR_REPO}"/olm/testCatalogSource.sh ${PLATFORM} ${CHANNEL} ${NAMESPACE} ${INSTALLATION_TYPE} ${CATALOG_SOURCE_IMAGE} - source "${OPERATOR_REPO}"/.ci/util/ci_common.sh + # Execute test catalog source script + source "${OPERATOR_REPO}"/olm/testCatalogSource.sh "openshift" "nightly" ${NAMESPACE} "catalog" "che-catalog" oc project ${NAMESPACE} - - # Create and start a workspace - getCheAcessToken - chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml - - getCheAcessToken - chectl workspace:list + startNewWorkspace waitWorkspaceStart } -run - -# grab che-operator namespace events after running olm nightly tests -oc get events -n ${NAMESPACE} | tee ${ARTIFACTS_DIR}/che-operator-events.log +init +runTests diff --git a/.ci/cico_openshift_shost.sh b/.ci/cico_openshift_shost.sh index 7004172e7..f493836ac 100755 --- a/.ci/cico_openshift_shost.sh +++ b/.ci/cico_openshift_shost.sh @@ -10,116 +10,35 @@ # Contributors: # Red Hat, Inc. - initial API and implementation -set -ex - -#Stop execution on any error -trap "catchFinish" EXIT SIGINT - -# Define global environments -function init() { - export SCRIPT=$(readlink -f "$0") - export SCRIPT_DIR=$(dirname "$SCRIPT") - export NAMESPACE="che" - export PLATFORM="openshift" - export ARTIFACTS_DIR="/tmp/artifacts/artifacts-che" - - # Set operator root directory - if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then - export OPERATOR_REPO=${WORKSPgetOCCheClusterLogsACE}; - else - export OPERATOR_REPO=$(dirname "$SCRIPT_DIR"); - fi - - # CHE_OPERATOR_IMAGE is exposed in openshift ci pod. This image is build in every job and used then to deploy Che - # More info about how images are builded in Openshift CI: https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates - export OPERATOR_IMAGE=${CHE_OPERATOR_IMAGE} - echo "[INFO] Che Operator Image used is: ${CHE_OPERATOR_IMAGE}" -} - -# Catch_Finish is executed after finish script. -catchFinish() { - result=$? - - if [ "$result" != "0" ]; then - echo "[ERROR] Please check the openshift ci artifacts" - collectCheLogWithChectl - exit 1 - fi - - echo "[INFO] Job finished Successfully.Please check openshift ci artifacts" - collectCheLogWithChectl - - exit $result +set -e +set -x +set -u + +export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0"))); +source "${OPERATOR_REPO}"/.github/bin/common.sh + +overrideDefaults() { + # CHE_OPERATOR_IMAGE is exposed in openshift ci pod. This image is build in every job and used then to deploy Che + # More info about how images are builded in Openshift CI: https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates + export OPERATOR_IMAGE=${CHE_OPERATOR_IMAGE} + echo "[INFO] Che Operator Image used is: ${CHE_OPERATOR_IMAGE}" } -# Utility to get che events and pod logs from openshift cluster -function collectCheLogWithChectl() { - mkdir -p /tmp/artifacts/artifacts-che - chectl server:logs --directory=${ARTIFACTS_DIR} +prepareTemplates() { + disableOpenShiftOAuth ${TEMPLATES} + disableUpdateAdminPassword ${TEMPLATES} + setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE} + setServerExposureStrategy ${TEMPLATES} "single-host" } -# Get Token from single host mode deployment -function getSingleHostToken() { - export KEYCLOAK_HOSTNAME=$(oc get routes/che -n ${NAMESPACE} -o jsonpath='{.spec.host}') - export TOKEN_ENDPOINT="https://${KEYCLOAK_HOSTNAME}/auth/realms/che/protocol/openid-connect/token" - export CHE_ACCESS_TOKEN=$(curl --data "grant_type=password&client_id=che-public&username=admin&password=admin" -k ${TOKEN_ENDPOINT} | jq -r .access_token) -} - -# Utility to wait for a workspace to be started after workspace:create. -function waitSingleHostWorkspaceStart() { - set +e - export x=0 - while [ $x -le 180 ] - do - getSingleHostToken - - # List Workspaces and get the status - chectl workspace:list - workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE}) - workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ') - - if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ] - then - echo "[INFO] Workspace started successfully" - break - fi - sleep 10 - x=$(( x+1 )) - done - - if [ $x -gt 180 ] - then - echo "[ERROR] Workspace didn't start after 3 minutes." - exit 1 - fi -} - -# Deploy Eclipse Che in single host mode -function run() { - # Patch file to pass to chectl - cat >/tmp/che-cr-patch.yaml < Date: Wed, 2 Dec 2020 16:07:17 +0200 Subject: [PATCH 15/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 2 ++ .github/bin/minishift/test-update-operator.sh | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index f2e313b70..b728ebf49 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -199,11 +199,13 @@ startNewWorkspace() { } createWorkspace() { + sleep 5s chectl auth:login -u admin -p admin chectl workspace:create --devfile=${OPERATOR_REPO}/.ci/util/devfile-test.yaml } startExistedWorkspace() { + sleep 5s chectl auth:login -u admin -p admin chectl workspace:list workspaceList=$(chectl workspace:list) diff --git a/.github/bin/minishift/test-update-operator.sh b/.github/bin/minishift/test-update-operator.sh index ba5f2ecfd..188aa367b 100755 --- a/.github/bin/minishift/test-update-operator.sh +++ b/.github/bin/minishift/test-update-operator.sh @@ -29,14 +29,10 @@ runTest() { prepareTemplates deployEclipseChe "operator" "minishift" "quay.io/eclipse/che-operator:${PREVIOUS_PACKAGE_VERSION}" ${PREVIOUS_OPERATOR_TEMPLATE} - sleep 5s - createWorkspace - sleep 5s updateEclipseChe "quay.io/eclipse/che-operator:${LAST_PACKAGE_VERSION}" ${LAST_OPERATOR_TEMPLATE} waitEclipseCheDeployed ${LAST_PACKAGE_VERSION} - sleep 5s startExistedWorkspace waitWorkspaceStart From b9715db990ffa16c366eba56021b64cc75dd0cf6 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 16:08:06 +0200 Subject: [PATCH 16/34] Fixes Signed-off-by: Anatolii Bazko --- .ci/cico_updates_openshift.sh | 2 +- .github/bin/minikube/test-update-olm.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/cico_updates_openshift.sh b/.ci/cico_updates_openshift.sh index c800eae7d..d0bec25b6 100755 --- a/.ci/cico_updates_openshift.sh +++ b/.ci/cico_updates_openshift.sh @@ -25,5 +25,5 @@ runTests() { } init -initStableTemplates +initStableTemplates "openshift" "stable" runTests diff --git a/.github/bin/minikube/test-update-olm.sh b/.github/bin/minikube/test-update-olm.sh index 4779c05e7..a37c5be96 100755 --- a/.github/bin/minikube/test-update-olm.sh +++ b/.github/bin/minikube/test-update-olm.sh @@ -28,5 +28,5 @@ runTests() { } init -initStableTemplates +initStableTemplates "kubernetes" "stable" runTest From 9bde8877ba0c5527543d2566c234ccf09ad9c037 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 16:24:20 +0200 Subject: [PATCH 17/34] Fixes Signed-off-by: Anatolii Bazko --- .github/workflows/minikube-latest-olm.yaml | 7 ++----- .../minikube-latest-operator-singlehost.yaml | 14 ++++---------- .github/workflows/minikube-stable-updates.yaml | 7 ++----- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/minikube-latest-olm.yaml b/.github/workflows/minikube-latest-olm.yaml index 7ecd236f0..771e472d2 100644 --- a/.github/workflows/minikube-latest-olm.yaml +++ b/.github/workflows/minikube-latest-olm.yaml @@ -22,11 +22,8 @@ jobs: run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - - name: Install operator courier - run: | - python -m pip install --upgrade pip - pip install operator-courier==2.1.7 - pip install yq + - name: Install jq + run: sudo pip install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-latest-olm.sh # Run this step even the previous step fail diff --git a/.github/workflows/minikube-latest-operator-singlehost.yaml b/.github/workflows/minikube-latest-operator-singlehost.yaml index 6ceb5fee0..894375ae4 100644 --- a/.github/workflows/minikube-latest-operator-singlehost.yaml +++ b/.github/workflows/minikube-latest-operator-singlehost.yaml @@ -21,11 +21,8 @@ jobs: run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - - name: Install operator courier - run: | - python -m pip install --upgrade pip - pip install operator-courier==2.1.7 - pip install yq + - name: Install jq + run: sudo pip install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-gateway.sh # Run this step even the previous step fail to upload artifacts to GH @@ -43,11 +40,8 @@ jobs: run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - - name: Install operator courier - run: | - python -m pip install --upgrade pip - pip install operator-courier==2.1.7 - pip install yq + - name: Install jq + run: sudo pip install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-native.sh # Run this step even the previous step fail to upload artifacts to GH diff --git a/.github/workflows/minikube-stable-updates.yaml b/.github/workflows/minikube-stable-updates.yaml index 62b592864..1978bb0f7 100644 --- a/.github/workflows/minikube-stable-updates.yaml +++ b/.github/workflows/minikube-stable-updates.yaml @@ -22,11 +22,8 @@ jobs: run: /bin/bash .github/bin/minikube/provision-cluster.sh - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=stable - - name: Install operator courier - run: | - python -m pip install --upgrade pip - pip install operator-courier==2.1.7 - pip install yq + - name: Install jq + run: sudo pip install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-update-olm.sh # Run this step even the previous step fail From 6c91cc54e1465563e809ccc01e364ff52186b80e Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 17:05:52 +0200 Subject: [PATCH 18/34] Fixes Signed-off-by: Anatolii Bazko --- .ci/cico_olm_openshift.sh | 1 - .ci/cico_openshift_shost.sh | 4 ++-- .../minikube/test-latest-operator-singlehost-gateway.sh | 2 +- .../bin/minikube/test-latest-operator-singlehost-native.sh | 2 +- .github/bin/minishift/test-latest-operator.sh | 2 +- .github/bin/minishift/test-update-operator.sh | 3 +-- .github/workflows/minikube-latest-operator-singlehost.yaml | 2 +- .github/workflows/minishift-latest.yaml | 7 ++----- 8 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.ci/cico_olm_openshift.sh b/.ci/cico_olm_openshift.sh index f992492ef..c74869f0a 100755 --- a/.ci/cico_olm_openshift.sh +++ b/.ci/cico_olm_openshift.sh @@ -28,7 +28,6 @@ function runTests() { # Execute test catalog source script source "${OPERATOR_REPO}"/olm/testCatalogSource.sh "openshift" "nightly" ${NAMESPACE} "catalog" "che-catalog" - oc project ${NAMESPACE} startNewWorkspace waitWorkspaceStart } diff --git a/.ci/cico_openshift_shost.sh b/.ci/cico_openshift_shost.sh index f493836ac..dd543ba03 100755 --- a/.ci/cico_openshift_shost.sh +++ b/.ci/cico_openshift_shost.sh @@ -32,13 +32,13 @@ prepareTemplates() { } runTests() { - prepareTemplates deployEclipseChe "operator" "openshift" ${OPERATOR_IMAGE} ${TEMPLATES} startNewWorkspace waitWorkspaceStart } init -initLatestTemplates overrideDefaults +initLatestTemplates +prepareTemplates runTests diff --git a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh index d20fbaead..75ac4aea7 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh @@ -29,7 +29,6 @@ prepareTemplates() { } runTest() { - prepareTemplates deployEclipseChe "operator" "minikube" ${OPERATOR_IMAGE} ${TEMPLATES} startNewWorkspace waitWorkspaceStart @@ -37,6 +36,7 @@ runTest() { init initLatestTemplates +prepareTemplates buildCheOperatorImage copyCheOperatorImageToMinikube runTest diff --git a/.github/bin/minikube/test-latest-operator-singlehost-native.sh b/.github/bin/minikube/test-latest-operator-singlehost-native.sh index e8ffa10db..b115701d6 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-native.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-native.sh @@ -29,7 +29,6 @@ prepareTemplates() { } runTest() { - prepareTemplates deployEclipseChe "operator" "minikube" ${OPERATOR_IMAGE} ${TEMPLATES} startNewWorkspace waitWorkspaceStart @@ -37,6 +36,7 @@ runTest() { init initLatestTemplates +prepareTemplates buildCheOperatorImage copyCheOperatorImageToMinikube runTest diff --git a/.github/bin/minishift/test-latest-operator.sh b/.github/bin/minishift/test-latest-operator.sh index 042c34370..e69c7147c 100755 --- a/.github/bin/minishift/test-latest-operator.sh +++ b/.github/bin/minishift/test-latest-operator.sh @@ -27,7 +27,6 @@ prepareTemplates() { } runTest() { - prepareTemplates deployEclipseChe "operator" "minishift" ${OPERATOR_IMAGE} ${TEMPLATES} startNewWorkspace waitWorkspaceStart @@ -35,6 +34,7 @@ runTest() { init initLatestTemplates +prepareTemplates # build is done on previous github action step copyCheOperatorImageToMinishift runTest diff --git a/.github/bin/minishift/test-update-operator.sh b/.github/bin/minishift/test-update-operator.sh index 188aa367b..5a605ad45 100755 --- a/.github/bin/minishift/test-update-operator.sh +++ b/.github/bin/minishift/test-update-operator.sh @@ -26,8 +26,6 @@ prepareTemplates() { } runTest() { - prepareTemplates - deployEclipseChe "operator" "minishift" "quay.io/eclipse/che-operator:${PREVIOUS_PACKAGE_VERSION}" ${PREVIOUS_OPERATOR_TEMPLATE} createWorkspace @@ -40,4 +38,5 @@ runTest() { init initStableTemplates "openshift" "stable" +prepareTemplates runTest diff --git a/.github/workflows/minikube-latest-operator-singlehost.yaml b/.github/workflows/minikube-latest-operator-singlehost.yaml index 894375ae4..1cbbc6118 100644 --- a/.github/workflows/minikube-latest-operator-singlehost.yaml +++ b/.github/workflows/minikube-latest-operator-singlehost.yaml @@ -41,7 +41,7 @@ jobs: - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - name: Install jq - run: sudo pip install yq + run: sudo pip3 install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-native.sh # Run this step even the previous step fail to upload artifacts to GH diff --git a/.github/workflows/minishift-latest.yaml b/.github/workflows/minishift-latest.yaml index eecd24d57..cc8481eb5 100644 --- a/.github/workflows/minishift-latest.yaml +++ b/.github/workflows/minishift-latest.yaml @@ -44,11 +44,8 @@ jobs: run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - name: Replace Minishift default certificates run: /bin/bash .github/bin/minishift/certs.sh - - name: Install operator courier - run: | - python -m pip install --upgrade pip - pip install operator-courier==2.1.7 - pip install yq + - name: Install jq + run: sudo pip install yq - name: Run tests run: /bin/bash .github/bin/minishift/test-latest-operator.sh # Run this step even the previous step fail From ed6b162e3f8fea436f126b890b848fb945bd1190 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 17:15:12 +0200 Subject: [PATCH 19/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 16 ++++++++++------ .../minikube-latest-operator-singlehost.yaml | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index b728ebf49..b896eb3d5 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -219,24 +219,28 @@ startExistedWorkspace() { } disableOpenShiftOAuth() { - yq -riSY '.spec.auth.openShiftoAuth = false' "${1}/che-operator/crds/org_v1_che_cr.yaml" + updateYaml "'.spec.auth.openShiftoAuth = false'" "${1}/che-operator/crds/org_v1_che_cr.yaml" } disableUpdateAdminPassword() { - yq -riSY '.spec.auth.updateAdminPassword = false' "${1}/che-operator/crds/org_v1_che_cr.yaml" + updateYaml "'.spec.auth.updateAdminPassword = false'" "${1}/che-operator/crds/org_v1_che_cr.yaml" } setServerExposureStrategy() { - yq -riSY '.spec.server.serverExposureStrategy = '${2} "${1}/che-operator/crds/org_v1_che_cr.yaml" + updateYaml "'.spec.server.serverExposureStrategy = '${2}" "${1}/che-operator/crds/org_v1_che_cr.yaml" } setSingleHostExposureType() { - yq -riSY '.spec.k8s.singleHostExposureType = '${2} "${1}/che-operator/crds/org_v1_che_cr.yaml" + updateYaml "'.spec.k8s.singleHostExposureType = '${2}" "${1}/che-operator/crds/org_v1_che_cr.yaml" } setCustomOperatorImage() { - yq -riSY '.spec.template.spec.containers[0].image = '${2} "${1}/che-operator/operator.yaml" - yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = IfNotPresent' "${1}/che-operator/operator.yaml" + updateYaml "'.spec.template.spec.containers[0].image = '${2}" "${1}/che-operator/operator.yaml" + updateYaml "'.spec.template.spec.containers[0].imagePullPolicy = IfNotPresent'" "${1}/che-operator/operator.yaml" +} + +updateYaml() { + yq -rSY ${1} > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${2} } insecurePrivateDockerRegistry() { diff --git a/.github/workflows/minikube-latest-operator-singlehost.yaml b/.github/workflows/minikube-latest-operator-singlehost.yaml index 1cbbc6118..894375ae4 100644 --- a/.github/workflows/minikube-latest-operator-singlehost.yaml +++ b/.github/workflows/minikube-latest-operator-singlehost.yaml @@ -41,7 +41,7 @@ jobs: - name: Install chectl run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - name: Install jq - run: sudo pip3 install yq + run: sudo pip install yq - name: Run tests run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-native.sh # Run this step even the previous step fail to upload artifacts to GH From 2bf6cd0030e505127cd0794634ac45f56b94e84c Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 17:18:41 +0200 Subject: [PATCH 20/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index b896eb3d5..98fb56363 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -219,24 +219,24 @@ startExistedWorkspace() { } disableOpenShiftOAuth() { - updateYaml "'.spec.auth.openShiftoAuth = false'" "${1}/che-operator/crds/org_v1_che_cr.yaml" + updateYaml ".spec.auth.openShiftoAuth = false" "${1}/che-operator/crds/org_v1_che_cr.yaml" } disableUpdateAdminPassword() { - updateYaml "'.spec.auth.updateAdminPassword = false'" "${1}/che-operator/crds/org_v1_che_cr.yaml" + updateYaml ".spec.auth.updateAdminPassword = false" "${1}/che-operator/crds/org_v1_che_cr.yaml" } setServerExposureStrategy() { - updateYaml "'.spec.server.serverExposureStrategy = '${2}" "${1}/che-operator/crds/org_v1_che_cr.yaml" + updateYaml ".spec.server.serverExposureStrategy = ${2}" "${1}/che-operator/crds/org_v1_che_cr.yaml" } setSingleHostExposureType() { - updateYaml "'.spec.k8s.singleHostExposureType = '${2}" "${1}/che-operator/crds/org_v1_che_cr.yaml" + updateYaml ".spec.k8s.singleHostExposureType = ${2}" "${1}/che-operator/crds/org_v1_che_cr.yaml" } setCustomOperatorImage() { - updateYaml "'.spec.template.spec.containers[0].image = '${2}" "${1}/che-operator/operator.yaml" - updateYaml "'.spec.template.spec.containers[0].imagePullPolicy = IfNotPresent'" "${1}/che-operator/operator.yaml" + updateYaml ".spec.template.spec.containers[0].image = ${2}" "${1}/che-operator/operator.yaml" + updateYaml ".spec.template.spec.containers[0].imagePullPolicy = IfNotPresent" "${1}/che-operator/operator.yaml" } updateYaml() { From ca01ab1a9c2a803b458dd85f846126416375cfcf Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 17:38:17 +0200 Subject: [PATCH 21/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 21 +++++++++++---------- deploy/t.sh | 13 +++++++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) create mode 100755 deploy/t.sh diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 98fb56363..e464e27d7 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -219,28 +219,29 @@ startExistedWorkspace() { } disableOpenShiftOAuth() { - updateYaml ".spec.auth.openShiftoAuth = false" "${1}/che-operator/crds/org_v1_che_cr.yaml" + local file="${1}/che-operator/crds/org_v1_che_cr.yaml" + yq -rSY '.spec.auth.openShiftoAuth = false' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} } disableUpdateAdminPassword() { - updateYaml ".spec.auth.updateAdminPassword = false" "${1}/che-operator/crds/org_v1_che_cr.yaml" + local file="${1}/che-operator/crds/org_v1_che_cr.yaml" + yq -rSY '.spec.auth.updateAdminPassword = false' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} } setServerExposureStrategy() { - updateYaml ".spec.server.serverExposureStrategy = ${2}" "${1}/che-operator/crds/org_v1_che_cr.yaml" + local file="${1}/che-operator/crds/org_v1_che_cr.yaml" + yq -rSY '.spec.server.serverExposureStrategy = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} } setSingleHostExposureType() { - updateYaml ".spec.k8s.singleHostExposureType = ${2}" "${1}/che-operator/crds/org_v1_che_cr.yaml" + local file="${1}/che-operator/crds/org_v1_che_cr.yaml" + yq -rSY '.spec.k8s.singleHostExposureType = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} } setCustomOperatorImage() { - updateYaml ".spec.template.spec.containers[0].image = ${2}" "${1}/che-operator/operator.yaml" - updateYaml ".spec.template.spec.containers[0].imagePullPolicy = IfNotPresent" "${1}/che-operator/operator.yaml" -} - -updateYaml() { - yq -rSY ${1} > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${2} + local file="${1}/che-operator/operator.yaml" + yq -rSY '.spec.template.spec.containers[0].image = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} + yq -rSY '.spec.template.spec.containers[0].imagePullPolicy = "IfNotPresent"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} } insecurePrivateDockerRegistry() { diff --git a/deploy/t.sh b/deploy/t.sh new file mode 100755 index 000000000..66eba806d --- /dev/null +++ b/deploy/t.sh @@ -0,0 +1,13 @@ +set -x + +setCustomOperatorImage() { + updateYaml "'.spec.template.spec.containers[0].imagePullPolicy = "IfNotPresent"'" ${1} + updateYaml "'.spec.template.spec.containers[0].image = "'${2}'"'" ${1} +} + +updateYaml() { + yq -rSY ${1} > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${2} +} + +setCustomOperatorImage operator.yaml ttttttt + From ffa37c4c177d8e9bccaf219e5fb3e9a093ea7de0 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 17:39:13 +0200 Subject: [PATCH 22/34] Fixes Signed-off-by: Anatolii Bazko --- deploy/t.sh | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100755 deploy/t.sh diff --git a/deploy/t.sh b/deploy/t.sh deleted file mode 100755 index 66eba806d..000000000 --- a/deploy/t.sh +++ /dev/null @@ -1,13 +0,0 @@ -set -x - -setCustomOperatorImage() { - updateYaml "'.spec.template.spec.containers[0].imagePullPolicy = "IfNotPresent"'" ${1} - updateYaml "'.spec.template.spec.containers[0].image = "'${2}'"'" ${1} -} - -updateYaml() { - yq -rSY ${1} > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${2} -} - -setCustomOperatorImage operator.yaml ttttttt - From cf7dc14ffba6a02e15da673e0c4db4aa16a25c90 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 17:53:33 +0200 Subject: [PATCH 23/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 10 +++++----- .../test-latest-operator-singlehost-gateway.sh | 2 +- olm/testCatalogSource.sh | 10 ++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index e464e27d7..ba80fb136 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -60,18 +60,18 @@ initStableTemplates() { export lastCSV=$(yq -r ".channels[] | select(.name == \"${channel}\") | .currentCSV" "${packageFilePath}") export LAST_PACKAGE_VERSION=$(echo "${lastCSV}" | sed -e "s/${packageName}.v//") - export previousCSV=$(sed -n 's|^ *replaces: *\([^ ]*\) *|\1|p' "${packageFolderPath}/${lastPackageVersion}/${packageName}.v${lastPackageVersion}.clusterserviceversion.yaml") + export previousCSV=$(sed -n 's|^ *replaces: *\([^ ]*\) *|\1|p' "${packageFolderPath}/${LAST_PACKAGE_VERSION}/${packageName}.v${LAST_PACKAGE_VERSION}.clusterserviceversion.yaml") export PREVIOUS_PACKAGE_VERSION=$(echo "${previousCSV}" | sed -e "s/${packageName}.v//") - export lastOperatorPath=${OPERATOR_REPO}/tmp/${lastPackageVersion} - export previousOperatorPath=${OPERATOR_REPO}/tmp/${previousPackageVersion} + export lastOperatorPath=${OPERATOR_REPO}/tmp/${LAST_PACKAGE_VERSION} + export previousOperatorPath=${OPERATOR_REPO}/tmp/${PREVIOUS_PACKAGE_VERSION} export LAST_OPERATOR_TEMPLATE=${lastOperatorPath}/chectl/templates export PREVIOUS_OPERATOR_TEMPLATE=${previousOperatorPath}/chectl/templates # clone the exact versions to use their templates - git clone --depth 1 --branch ${previousPackageVersion} https://github.com/eclipse/che-operator/ ${previousOperatorPath} - git clone --depth 1 --branch ${lastPackageVersion} https://github.com/eclipse/che-operator/ ${lastOperatorPath} + git clone --depth 1 --branch ${PREVIOUS_PACKAGE_VERSION} https://github.com/eclipse/che-operator/ ${previousOperatorPath} + git clone --depth 1 --branch ${LAST_PACKAGE_VERSION} https://github.com/eclipse/che-operator/ ${lastOperatorPath} # chectl requires 'che-operator' template folder mkdir -p "${LAST_OPERATOR_TEMPLATE}/che-operator" diff --git a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh index 75ac4aea7..6a5ba53b7 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh @@ -25,7 +25,7 @@ prepareTemplates() { disableUpdateAdminPassword ${TEMPLATES} setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE} setServerExposureStrategy ${TEMPLATES} "single-host" - setSingleHostExposureType ${TEMPLATES}"gateway" + setSingleHostExposureType ${TEMPLATES} "gateway" } runTest() { diff --git a/olm/testCatalogSource.sh b/olm/testCatalogSource.sh index 32ebfd206..c2f27f908 100755 --- a/olm/testCatalogSource.sh +++ b/olm/testCatalogSource.sh @@ -83,9 +83,7 @@ fi # Assign catalog source image CATALOG_SOURCE_IMAGE=$5 -if [ -z "${IMAGE_REGISTRY_USER_NAME}" ]; then - IMAGE_REGISTRY_USER_NAME=eclipse -fi +IMAGE_REGISTRY_USER_NAME=${IMAGE_REGISTRY_USER_NAME:-eclipse} echo "[INFO] Image 'IMAGE_REGISTRY_USER_NAME': ${IMAGE_REGISTRY_USER_NAME}" init() { @@ -118,7 +116,7 @@ init() { buildOLMImages() { # Manage catalog source for every platform in part. - # 1. Kubernetes: + # 1. Kubernetes: # a) Use Minikube cluster. Enable registry addon, build catalog source and olm bundle images, push them to embedded private registry. # b) Provide image registry env variables to push images to the real public registry(docker.io, quay.io etc). # 2. Openshift: build bundle image and push it using image stream. Launch deployment with custom grpc based catalog source image to install the latest bundle. @@ -127,7 +125,7 @@ buildOLMImages() { echo "[INFO]: Kubernetes platform detected" # Build operator image - if [ -n "${OPERATOR_IMAGE}" ];then + if [ -n "${OPERATOR_IMAGE}" ];then echo "[INFO]: Build operator image ${OPERATOR_IMAGE}..." cd "${OPERATOR_REPO}" && docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . @@ -257,7 +255,7 @@ run() { if [ ! ${PLATFORM} == "openshift" ] && [ "${CHANNEL}" == "nightly" ]; then forcePullingOlmImages "${CATALOG_BUNDLE_IMAGE}" fi - + installOperatorMarketPlace subscribeToInstallation From f3031e0c0d1d4868c34ae7aafb9be1dddcd1cc2b Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 18:02:36 +0200 Subject: [PATCH 24/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/minikube/test-update-olm.sh | 2 +- olm/olm.sh | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/bin/minikube/test-update-olm.sh b/.github/bin/minikube/test-update-olm.sh index a37c5be96..8598ec815 100755 --- a/.github/bin/minikube/test-update-olm.sh +++ b/.github/bin/minikube/test-update-olm.sh @@ -20,7 +20,7 @@ source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error trap "catchFinish" EXIT SIGINT -runTests() { +runTest() { "${OPERATOR_REPO}"/olm/testUpdate.sh "kubernetes" "stable" ${NAMESPACE} waitEclipseCheDeployed ${LAST_PACKAGE_VERSION} startNewWorkspace diff --git a/olm/olm.sh b/olm/olm.sh index 7af1b5ced..46b3c23ad 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -13,13 +13,7 @@ # Scripts to prepare OLM(operator lifecycle manager) and install che-operator package # with specific version using OLM. -if [ -z "${BASE_DIR}" ]; then - SCRIPT=$(readlink -f "$0") - export SCRIPT - - BASE_DIR=$(dirname "$(dirname "$SCRIPT")")/olm; - export BASE_DIR -fi +BASE_DIR=${BASE_DIR:-$(dirname $(dirname $(readlink -f "$0")))/olm} ROOT_DIR=$(dirname "${BASE_DIR}") @@ -64,7 +58,7 @@ else echo "[ERROR] Stable preview channel doesn't support installation using 'catalog'. Use 'Marketplace' instead of it." exit 1 fi - + platformPath="${BASE_DIR}/${packageName}" packageFolderPath="${platformPath}/deploy/olm-catalog/${packageName}" CSV_FILE="${packageFolderPath}/${PACKAGE_VERSION}/${packageName}.v${PACKAGE_VERSION}.clusterserviceversion.yaml" @@ -105,7 +99,7 @@ EOF createRpcCatalogSource() { NAMESPACE=${1} indexIp=${2} -cat < Date: Wed, 2 Dec 2020 18:32:45 +0200 Subject: [PATCH 25/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 5 +++++ .../bin/minikube/test-latest-operator-singlehost-gateway.sh | 1 + .../bin/minikube/test-latest-operator-singlehost-native.sh | 1 + .github/bin/minishift/test-latest-operator.sh | 2 +- .github/bin/minishift/test-update-operator.sh | 2 +- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index ba80fb136..8928147e8 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -238,6 +238,11 @@ setSingleHostExposureType() { yq -rSY '.spec.k8s.singleHostExposureType = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} } +removeIngressDomain() { + local file="${1}/che-operator/crds/org_v1_che_cr.yaml" + yq -rSY '.spec.k8s.ingressDomain = ""' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} +} + setCustomOperatorImage() { local file="${1}/che-operator/operator.yaml" yq -rSY '.spec.template.spec.containers[0].image = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} diff --git a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh index 6a5ba53b7..cab6fa508 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh @@ -26,6 +26,7 @@ prepareTemplates() { setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE} setServerExposureStrategy ${TEMPLATES} "single-host" setSingleHostExposureType ${TEMPLATES} "gateway" + removeIngressDomain ${TEMPLATES} } runTest() { diff --git a/.github/bin/minikube/test-latest-operator-singlehost-native.sh b/.github/bin/minikube/test-latest-operator-singlehost-native.sh index b115701d6..d5bae3e8b 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-native.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-native.sh @@ -26,6 +26,7 @@ prepareTemplates() { setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE} setServerExposureStrategy ${TEMPLATES} "single-host" setSingleHostExposureType ${TEMPLATES} "native" + removeIngressDomain ${TEMPLATES} } runTest() { diff --git a/.github/bin/minishift/test-latest-operator.sh b/.github/bin/minishift/test-latest-operator.sh index e69c7147c..cfd2b6a2b 100755 --- a/.github/bin/minishift/test-latest-operator.sh +++ b/.github/bin/minishift/test-latest-operator.sh @@ -14,7 +14,7 @@ set -e set -x set -u -export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname "${BASH_SOURCE[0]}")))) source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error diff --git a/.github/bin/minishift/test-update-operator.sh b/.github/bin/minishift/test-update-operator.sh index 5a605ad45..7b42941b0 100755 --- a/.github/bin/minishift/test-update-operator.sh +++ b/.github/bin/minishift/test-update-operator.sh @@ -14,7 +14,7 @@ set -e set -x set -u -export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname "${BASH_SOURCE[0]}")))) source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error From 94fbb72ef84e6ad0d00b5eeb04fcd3dd7648d7eb Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 2 Dec 2020 19:38:49 +0200 Subject: [PATCH 26/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 1 + .github/workflows/minishift-e2e.yaml | 1 + .github/workflows/minishift-latest.yaml | 4 +++- .github/workflows/minishift-stable-updates.yaml | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 8928147e8..16cf0b0d7 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -155,6 +155,7 @@ deployEclipseChe() { --installer ${installer} \ --chenamespace ${NAMESPACE} \ --che-operator-image ${image} \ + --skip-kubernetes-health-check \ --che-operator-cr-yaml ${templates}/che-operator/crds/org_v1_che_cr.yaml \ --templates ${templates} } diff --git a/.github/workflows/minishift-e2e.yaml b/.github/workflows/minishift-e2e.yaml index 4f907376d..843365716 100644 --- a/.github/workflows/minishift-e2e.yaml +++ b/.github/workflows/minishift-e2e.yaml @@ -25,6 +25,7 @@ jobs: run: /bin/bash .github/bin/minishift/certs.sh - name: Run tests run: | + eval $(minishift oc-env) oc apply -f deploy/crds/org_v1_che_crd.yaml go mod tidy go run e2e/*.go diff --git a/.github/workflows/minishift-latest.yaml b/.github/workflows/minishift-latest.yaml index cc8481eb5..a48bc473d 100644 --- a/.github/workflows/minishift-latest.yaml +++ b/.github/workflows/minishift-latest.yaml @@ -47,7 +47,9 @@ jobs: - name: Install jq run: sudo pip install yq - name: Run tests - run: /bin/bash .github/bin/minishift/test-latest-operator.sh + run: | + eval $(minishift oc-env) + /bin/bash .github/bin/minishift/test-latest-operator.sh # Run this step even the previous step fail - uses: actions/upload-artifact@v2 if: ${{ always() }} diff --git a/.github/workflows/minishift-stable-updates.yaml b/.github/workflows/minishift-stable-updates.yaml index 075925490..5c5687e4a 100644 --- a/.github/workflows/minishift-stable-updates.yaml +++ b/.github/workflows/minishift-stable-updates.yaml @@ -30,7 +30,9 @@ jobs: - name: Replace Minishift default certificates run: /bin/bash .github/bin/minishift/certs.sh - name: Update minishift deprecated certificates and run e2e - run: /bin/bash .github/bin/minishift/test-update-operator.sh + run: | + eval $(minishift oc-env) + /bin/bash .github/bin/minishift/test-update-operator.sh # Run this step even the previous step fail - uses: actions/upload-artifact@v2 if: ${{ always() }} From 9e8278f36db725dd2b06ae90d1538c144152311e Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Thu, 3 Dec 2020 07:41:21 +0200 Subject: [PATCH 27/34] Fixes Signed-off-by: Anatolii Bazko --- olm/olm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/olm/olm.sh b/olm/olm.sh index 46b3c23ad..3e8f2bb62 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -17,7 +17,7 @@ BASE_DIR=${BASE_DIR:-$(dirname $(dirname $(readlink -f "$0")))/olm} ROOT_DIR=$(dirname "${BASE_DIR}") -source ${ROOT_DIR}/olm/check-yq.sh +source $(dirname $(dirname $(readlink -f "$0")))/olm/check-yq.sh SOURCE_INSTALL=$4 From 46c8491ddef2e1794ba83834009aa086525e3a6f Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Thu, 3 Dec 2020 08:15:24 +0200 Subject: [PATCH 28/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 4 ++-- .../bin/minikube/test-latest-operator-singlehost-gateway.sh | 2 +- .../bin/minikube/test-latest-operator-singlehost-native.sh | 2 +- olm/olm.sh | 2 -- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 16cf0b0d7..accc80d4d 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -239,9 +239,9 @@ setSingleHostExposureType() { yq -rSY '.spec.k8s.singleHostExposureType = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} } -removeIngressDomain() { +setIngressDomain() { local file="${1}/che-operator/crds/org_v1_che_cr.yaml" - yq -rSY '.spec.k8s.ingressDomain = ""' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} + yq -rSY '.spec.k8s.ingressDomain = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file} } setCustomOperatorImage() { diff --git a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh index cab6fa508..a83020804 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh @@ -26,7 +26,7 @@ prepareTemplates() { setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE} setServerExposureStrategy ${TEMPLATES} "single-host" setSingleHostExposureType ${TEMPLATES} "gateway" - removeIngressDomain ${TEMPLATES} + setIngressDomain ${TEMPLATES} "$(minikube ip).nip.io" } runTest() { diff --git a/.github/bin/minikube/test-latest-operator-singlehost-native.sh b/.github/bin/minikube/test-latest-operator-singlehost-native.sh index d5bae3e8b..c7fc7c1ce 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-native.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-native.sh @@ -26,7 +26,7 @@ prepareTemplates() { setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE} setServerExposureStrategy ${TEMPLATES} "single-host" setSingleHostExposureType ${TEMPLATES} "native" - removeIngressDomain ${TEMPLATES} + setIngressDomain ${TEMPLATES} "$(minikube ip).nip.io" } runTest() { diff --git a/olm/olm.sh b/olm/olm.sh index 3e8f2bb62..a7cae095f 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -17,8 +17,6 @@ BASE_DIR=${BASE_DIR:-$(dirname $(dirname $(readlink -f "$0")))/olm} ROOT_DIR=$(dirname "${BASE_DIR}") -source $(dirname $(dirname $(readlink -f "$0")))/olm/check-yq.sh - SOURCE_INSTALL=$4 if [ -z ${SOURCE_INSTALL} ]; then SOURCE_INSTALL="Marketplace"; fi From 4d3afab98fa9e629d780cb2d6ac56c13f59ed375 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Thu, 3 Dec 2020 08:47:24 +0200 Subject: [PATCH 29/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 3 +-- olm/olm.sh | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index accc80d4d..9c68468c6 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -87,8 +87,7 @@ waitWorkspaceStart() { export x=0 while [ $x -le 180 ] do - getCheAcessToken - + chectl auth:login -u admin -p admin chectl workspace:list workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE}) workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ') diff --git a/olm/olm.sh b/olm/olm.sh index a7cae095f..2cd5aa387 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -13,10 +13,11 @@ # Scripts to prepare OLM(operator lifecycle manager) and install che-operator package # with specific version using OLM. -BASE_DIR=${BASE_DIR:-$(dirname $(dirname $(readlink -f "$0")))/olm} - +BASE_DIR=$(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}")))/olm ROOT_DIR=$(dirname "${BASE_DIR}") +source ${ROOT_DIR}/olm/check-yq.sh + SOURCE_INSTALL=$4 if [ -z ${SOURCE_INSTALL} ]; then SOURCE_INSTALL="Marketplace"; fi From 106a4f36e15443b7b864a23802957b4dc5afd424 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Thu, 3 Dec 2020 14:03:38 +0200 Subject: [PATCH 30/34] Fixes Signed-off-by: Anatolii Bazko --- olm/olm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/olm/olm.sh b/olm/olm.sh index 2cd5aa387..0ab4951fb 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -152,6 +152,7 @@ buildBundleImage() { # ${OPM_BINARY} alpha bundle validate -t "${CATALOG_BUNDLE_IMAGE_NAME_LOCAL}" --image-builder "${imageTool}" + SKIP_TLS_VERIFY="" if [ "${imageTool}" == "podman" ]; then SKIP_TLS_VERIFY=" --tls-verify=false" fi From 2242221602969126f21a9aac1928444b7893a2a1 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Thu, 3 Dec 2020 18:14:31 +0200 Subject: [PATCH 31/34] Fixes Signed-off-by: Anatolii Bazko --- olm/olm.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/olm/olm.sh b/olm/olm.sh index 0ab4951fb..e93654c33 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -177,11 +177,14 @@ buildCatalogImage() { imageTool=${3:-docker} - FROM_INDEX=${4} - if [ -n "${FROM_INDEX}" ]; then + FROM_INDEX=${4:-""} + BUILD_INDEX_IMAGE_ARG="" + if [ ! "${FROM_INDEX}" == "" ]; then BUILD_INDEX_IMAGE_ARG=" --from-index ${FROM_INDEX}" fi + SKIP_TLS_ARG="" + SKIP_TLS_VERIFY="" if [ "${imageTool}" == "podman" ]; then SKIP_TLS_ARG=" --skip-tls" SKIP_TLS_VERIFY=" --tls-verify=false" From c9053e476cbbb9d39f0911a8c54f536dde2504b6 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Fri, 4 Dec 2020 09:22:25 +0200 Subject: [PATCH 32/34] Fixes Signed-off-by: Anatolii Bazko --- .github/bin/common.sh | 4 ++++ olm/olm.sh | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 9c68468c6..2184acbcd 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -38,6 +38,10 @@ init() { export TEMPLATES=${OPERATOR_REPO}/tmp export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test" + export XDG_DATA_HOME=/tmp/chectl/data + export XDG_CACHE_HOME=/tmp/chectl/cache + export XDG_CONFIG_HOME=/tmp/chectl/config + # prepare templates directory rm -rf ${TEMPLATES} mkdir -p "${TEMPLATES}/che-operator" && chmod 777 "${TEMPLATES}" diff --git a/olm/olm.sh b/olm/olm.sh index e93654c33..478b4e15e 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -297,10 +297,7 @@ installOperatorMarketPlace() { } subscribeToInstallation() { - CSV_NAME="${1}" - if [ -z "${CSV_NAME}" ]; then - CSV_NAME="${CSV}" - fi + CSV_NAME="${1-${CSV}}" echo "Subscribing to version: ${CSV_NAME}" From a1f3f01a0a677443db3799ca51fd91957d154005 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Fri, 4 Dec 2020 12:49:53 +0200 Subject: [PATCH 33/34] Fixes Signed-off-by: Anatolii Bazko --- olm/olm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/olm/olm.sh b/olm/olm.sh index 478b4e15e..350977179 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -163,7 +163,7 @@ buildBundleImage() { # Build catalog source image with index based on bundle image. buildCatalogImage() { - CATALOG_IMAGENAME=${1} + export CATALOG_IMAGENAME=${1} if [ -z "${CATALOG_IMAGENAME}" ]; then echo "Please specify first argument: catalog image" exit 1 From b30dbb3b3b30bba13352f3055657696487701064 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Fri, 4 Dec 2020 14:00:42 +0200 Subject: [PATCH 34/34] Fixes Signed-off-by: Anatolii Bazko --- .ci/cico_olm_openshift.sh | 3 +-- .ci/cico_openshift_shost.sh | 1 - .ci/cico_updates_openshift.sh | 1 - .github/bin/common.sh | 2 -- .github/bin/minikube/test-latest-olm.sh | 5 ++--- .../bin/minikube/test-latest-operator-singlehost-gateway.sh | 2 +- .../bin/minikube/test-latest-operator-singlehost-native.sh | 3 +-- .github/bin/minikube/test-update-olm.sh | 3 +-- .github/bin/minishift/test-latest-operator.sh | 1 - .github/bin/minishift/test-update-operator.sh | 1 - olm/olm.sh | 2 +- 11 files changed, 7 insertions(+), 17 deletions(-) diff --git a/.ci/cico_olm_openshift.sh b/.ci/cico_olm_openshift.sh index c74869f0a..ade9c64aa 100755 --- a/.ci/cico_olm_openshift.sh +++ b/.ci/cico_olm_openshift.sh @@ -10,7 +10,6 @@ set -e set -x -set -u # Component is defined in Openshift CI job configuration. See: https://github.com/openshift/release/blob/master/ci-operator/config/devfile/devworkspace-operator/devfile-devworkspace-operator-master__v4.yaml#L8 export CI_COMPONENT="che-operator-catalog" @@ -27,7 +26,7 @@ function runTests() { export OAUTH="false" # Execute test catalog source script - source "${OPERATOR_REPO}"/olm/testCatalogSource.sh "openshift" "nightly" ${NAMESPACE} "catalog" "che-catalog" + "${OPERATOR_REPO}"/olm/testCatalogSource.sh "openshift" "nightly" ${NAMESPACE} "catalog" "che-catalog" startNewWorkspace waitWorkspaceStart } diff --git a/.ci/cico_openshift_shost.sh b/.ci/cico_openshift_shost.sh index dd543ba03..b8cddb4c5 100755 --- a/.ci/cico_openshift_shost.sh +++ b/.ci/cico_openshift_shost.sh @@ -12,7 +12,6 @@ set -e set -x -set -u export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0"))); source "${OPERATOR_REPO}"/.github/bin/common.sh diff --git a/.ci/cico_updates_openshift.sh b/.ci/cico_updates_openshift.sh index d0bec25b6..571953eb9 100755 --- a/.ci/cico_updates_openshift.sh +++ b/.ci/cico_updates_openshift.sh @@ -12,7 +12,6 @@ set -e set -x -set -u export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0"))); source "${OPERATOR_REPO}"/.github/bin/common.sh diff --git a/.github/bin/common.sh b/.github/bin/common.sh index 2184acbcd..d854f019f 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -11,8 +11,6 @@ # Red Hat, Inc. - initial API and implementation set -e -set -o pipefail -set -u set -x catchFinish() { diff --git a/.github/bin/minikube/test-latest-olm.sh b/.github/bin/minikube/test-latest-olm.sh index 6ed63974f..b58f6baba 100755 --- a/.github/bin/minikube/test-latest-olm.sh +++ b/.github/bin/minikube/test-latest-olm.sh @@ -10,16 +10,15 @@ set -e set -x -set -u -export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}"))))) source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error trap "catchFinish" EXIT SIGINT runTest() { - source "${OPERATOR_REPO}"/olm/testCatalogSource.sh "kubernetes" "nightly" ${NAMESPACE} "catalog" "my_image" + "${OPERATOR_REPO}"/olm/testCatalogSource.sh "kubernetes" "nightly" ${NAMESPACE} "catalog" "my_image" startNewWorkspace waitWorkspaceStart } diff --git a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh index a83020804..03e1ea2bf 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-gateway.sh @@ -14,7 +14,7 @@ set -e set -x set -u -export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}"))))) source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error diff --git a/.github/bin/minikube/test-latest-operator-singlehost-native.sh b/.github/bin/minikube/test-latest-operator-singlehost-native.sh index c7fc7c1ce..0e41d6d68 100755 --- a/.github/bin/minikube/test-latest-operator-singlehost-native.sh +++ b/.github/bin/minikube/test-latest-operator-singlehost-native.sh @@ -12,9 +12,8 @@ set -e set -x -set -u -export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}"))))) source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error diff --git a/.github/bin/minikube/test-update-olm.sh b/.github/bin/minikube/test-update-olm.sh index 8598ec815..3774c6a77 100755 --- a/.github/bin/minikube/test-update-olm.sh +++ b/.github/bin/minikube/test-update-olm.sh @@ -12,9 +12,8 @@ set -e set -x -set -u -export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "$0"))))) +export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}"))))) source "${OPERATOR_REPO}"/.github/bin/common.sh # Stop execution on any error diff --git a/.github/bin/minishift/test-latest-operator.sh b/.github/bin/minishift/test-latest-operator.sh index cfd2b6a2b..3b2155c2f 100755 --- a/.github/bin/minishift/test-latest-operator.sh +++ b/.github/bin/minishift/test-latest-operator.sh @@ -12,7 +12,6 @@ set -e set -x -set -u export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname "${BASH_SOURCE[0]}")))) source "${OPERATOR_REPO}"/.github/bin/common.sh diff --git a/.github/bin/minishift/test-update-operator.sh b/.github/bin/minishift/test-update-operator.sh index 7b42941b0..ce7bad60f 100755 --- a/.github/bin/minishift/test-update-operator.sh +++ b/.github/bin/minishift/test-update-operator.sh @@ -12,7 +12,6 @@ set -e set -x -set -u export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname "${BASH_SOURCE[0]}")))) source "${OPERATOR_REPO}"/.github/bin/common.sh diff --git a/olm/olm.sh b/olm/olm.sh index 350977179..478b4e15e 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -163,7 +163,7 @@ buildBundleImage() { # Build catalog source image with index based on bundle image. buildCatalogImage() { - export CATALOG_IMAGENAME=${1} + CATALOG_IMAGENAME=${1} if [ -z "${CATALOG_IMAGENAME}" ]; then echo "Please specify first argument: catalog image" exit 1