From b993129f5bafe1140639a385953917010ccd63f6 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Fri, 18 Sep 2020 12:23:00 +0200 Subject: [PATCH 01/11] Migrate jobs from ci.centos to GH actions Signed-off-by: Flavius Lacatusu --- .ci/cico_minishift_nightly.sh | 51 +----- .ci/cico_olm_minikube.sh | 27 ++- .ci/cico_olm_openshift.sh | 134 ++++++++------ .ci/cico_operator_prcheck.sh | 73 -------- .ci/cico_updates_minikube.sh | 17 +- .ci/cico_updates_minishift.sh | 80 +++------ .ci/cico_updates_openshift.sh | 7 +- .ci/start-minikube.sh | 27 ++- .ci/util/che-cert-generation.sh | 36 ---- .ci/util/ci_common.sh | 174 ++----------------- .github/action_scripts/minishift_cert_gen.sh | 63 +++++++ .github/workflows/che-nightly.yaml | 30 ++++ .github/workflows/che-operator-updates.yaml | 48 +++++ .github/workflows/checkNightlyOpmBundle.yaml | 2 +- .github/workflows/e2e.yaml | 34 ++++ .github/workflows/olm_checks_platforms.yaml | 28 +++ e2e/create.go | 2 +- e2e/tests.go | 2 +- olm/olm.sh | 1 + olm/testCatalogSource.sh | 2 - 20 files changed, 365 insertions(+), 473 deletions(-) delete mode 100644 .ci/cico_operator_prcheck.sh delete mode 100644 .ci/util/che-cert-generation.sh create mode 100644 .github/action_scripts/minishift_cert_gen.sh create mode 100644 .github/workflows/che-nightly.yaml create mode 100644 .github/workflows/che-operator-updates.yaml create mode 100644 .github/workflows/e2e.yaml create mode 100644 .github/workflows/olm_checks_platforms.yaml diff --git a/.ci/cico_minishift_nightly.sh b/.ci/cico_minishift_nightly.sh index 6be984cf0b..76305f952b 100755 --- a/.ci/cico_minishift_nightly.sh +++ b/.ci/cico_minishift_nightly.sh @@ -12,14 +12,14 @@ set -ex -init() { +function init() { export SCRIPT=$(readlink -f "$0") export SCRIPT_DIR=$(dirname "$SCRIPT") export RAM_MEMORY=8192 export NAMESPACE="che" - export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test" export PLATFORM="openshift" + # Set operator root directory if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then OPERATOR_REPO=${WORKSPACE}; else @@ -28,56 +28,14 @@ init() { } -installDependencies() { - install_VirtPackages - installStartDocker - start_libvirt - setup_kvm_machine_driver - minishift_installation - installChectl - installJQ - load_jenkins_vars -} - -self_signed_minishift() { - export DOMAIN=*.$(minishift ip).nip.io - - source ${OPERATOR_REPO}/.ci/util/che-cert-generation.sh - - #Configure Router with generated certificate: - oc login -u system:admin --insecure-skip-tls-verify=true - oc project default - oc delete secret router-certs - - cat domain.crt domain.key > minishift.crt - oc create secret tls router-certs --key=domain.key --cert=minishift.crt - oc rollout latest router - - oc create namespace che - - cp rootCA.crt ca.crt - oc create secret generic self-signed-certificate --from-file=ca.crt -n=che -} - -run() { +# Deploy Eclipse Che +function run() { cat >/tmp/che-cr-patch.yaml < minishift.crt - oc create secret tls router-certs --key=domain.key --cert=minishift.crt - oc rollout latest router - - oc create namespace che - - cp rootCA.crt ca.crt - oc create secret generic self-signed-certificate --from-file=ca.crt -n=che -} - -testUpdates() { +function minishiftUpdates() { # Install previous stable version of Eclipse Che - self_signed_minishift installLatestCheStable # Create an workspace @@ -133,7 +95,8 @@ testUpdates() { chectl workspace:create --devfile=${OPERATOR_REPO}/.ci/util/devfile-test.yaml # Change operator images defaults in the deployment - sed -i -e "s|${previousPackageVersion}|${lastPackageVersion}|" "${OPERATOR_REPO}/tmp/che-operator/operator.yaml" + sed -i'.bak' -e "s|${previousPackageVersion}|${lastPackageVersion}|" "${OPERATOR_REPO}/tmp/che-operator/operator.yaml" + # Update the operator to the new release chectl server:update --skip-version-check --installer=operator --platform=minishift --templates="${OPERATOR_REPO}/tmp" @@ -141,8 +104,14 @@ testUpdates() { waitForNewCheVersion getCheAcessToken # Function from ./util/ci_common.sh + chectl workspace:list workspaceList=$(chectl workspace:list) - workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b') + + # Grep applied to MacOS + workspaceID=$(echo "$workspaceList" | grep workspace | awk '{ print $1} ') + workspaceID="${workspaceID%'ID'}" + echo $workspaceID + chectl workspace:start $workspaceID # Wait for workspace to be up @@ -152,5 +121,4 @@ testUpdates() { init source "${OPERATOR_REPO}"/.ci/util/ci_common.sh -installDependencies -testUpdates +minishiftUpdates diff --git a/.ci/cico_updates_openshift.sh b/.ci/cico_updates_openshift.sh index 7ba02cee9e..98df0b5ed2 100755 --- a/.ci/cico_updates_openshift.sh +++ b/.ci/cico_updates_openshift.sh @@ -28,7 +28,8 @@ init() { export CHANNEL="stable" } -waitCheUpdateInstall() { +# Utility to wait for eclipse che to be up in Openshift +function waitCheUpdateInstall() { export packageName=eclipse-che-preview-${PLATFORM} export platformPath=${OPERATOR_REPO}/olm/${packageName} export packageFolderPath="${platformPath}/deploy/olm-catalog/${packageName}" @@ -60,7 +61,7 @@ waitCheUpdateInstall() { fi } -testUpdates() { +function openshiftUpdates() { "${OPERATOR_REPO}"/olm/testUpdate.sh ${PLATFORM} ${CHANNEL} ${NAMESPACE} getCheAcessToken @@ -86,4 +87,4 @@ testUpdates() { init source "${OPERATOR_REPO}"/.ci/util/ci_common.sh -testUpdates +openshiftUpdates diff --git a/.ci/start-minikube.sh b/.ci/start-minikube.sh index b3b3e6974f..42da2d6c5d 100755 --- a/.ci/start-minikube.sh +++ b/.ci/start-minikube.sh @@ -32,12 +32,6 @@ curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VER chmod +x minikube && \ sudo mv minikube /usr/local/bin/ -# Configure firewall rules for docker0 network -firewall-cmd --permanent --zone=trusted --add-interface=docker0 -firewall-cmd --reload -firewall-cmd --get-active-zones -firewall-cmd --list-all --zone=trusted - # Create kube folder mkdir "${HOME}"/.kube || true touch "${HOME}"/.kube/config @@ -49,11 +43,13 @@ minikube config set WantNoneDriverWarning false minikube config set vm-driver none minikube version +sudo ufw disable + # minikube start -minikube start --kubernetes-version=$KUBERNETES_VERSION --extra-config=apiserver.authorization-mode=RBAC +sudo minikube start --kubernetes-version=$KUBERNETES_VERSION --extra-config=kubelet.resolv-conf=/run/systemd/resolve/resolv.conf +sudo chown -R $USER $HOME/.kube $HOME/.minikube -# waiting for node(s) to be ready -JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done +minikube update-context #Give god access to the k8s API kubectl apply -f - < operator.tar eval $(${PLATFORM} docker-env) && docker load -i operator.tar && rm operator.tar } -minishift_installation() { - MSFT_RELEASE="1.34.2" - printInfo "Downloading Minishift binaries" - if [ ! -d "$OPERATOR_REPO/tmp" ]; then mkdir -p "$OPERATOR_REPO/tmp" && chmod 777 "$OPERATOR_REPO/tmp"; fi - curl -L https://github.com/minishift/minishift/releases/download/v$MSFT_RELEASE/minishift-$MSFT_RELEASE-linux-amd64.tgz \ - -o ${OPERATOR_REPO}/tmp/minishift-$MSFT_RELEASE-linux-amd64.tar && tar -xvf ${OPERATOR_REPO}/tmp/minishift-$MSFT_RELEASE-linux-amd64.tar -C /usr/local/bin --strip-components=1 - - printInfo "Setting github token and start a new minishift VM." - github_token_set - minishift start --memory=8192 && eval $(minishift oc-env) - oc login -u system:admin - oc adm policy add-cluster-role-to-user cluster-admin developer && oc login -u developer -p developer - printInfo "Successfully started OCv3.X on minishift machine" -} - -generate_self_signed_certs() { - IP_ADDRESS="172.17.0.1" - openssl req -x509 \ - -newkey rsa:4096 \ - -keyout key.pem \ - -out cert.pem \ - -days 365 \ - -subj "/CN=*.${IP_ADDRESS}.nip.io" \ - -nodes && cat cert.pem key.pem > ca.crt -} - -installEpelRelease() { - if yum repolist | grep epel; then - printWarn "Epel already installed, skipping instalation." - else - #excluding mirror1.ci.centos.org - printInfo "Installing epel..." - yum install -d1 --assumeyes epel-release - yum update --assumeyes -d1 - fi -} - -installYQ() { - printInfo "Installing yq portable command-line YAML processor..." - sudo yum install --assumeyes -d1 python3-pip - pip3 install --upgrade setuptools - pip3 install yq -} - -installJQ() { - installEpelRelease - yum install --assumeyes -d1 jq -} - -installChectl() { - printInfo "Installing chectl" - bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next - -} - -getCheAcessToken() { +# 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}}) @@ -160,18 +38,21 @@ getCheAcessToken() { fi } -waitWorkspaceStart() { +# Utility to wait for a workspace to be started after workspace:create. +function 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 -oP '\bRUNNING.*?\b') + workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ') if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ] then - printInfo "Workspace started successfully" + echo "[INFO] Workspace started successfully" break fi sleep 10 @@ -180,44 +61,25 @@ waitWorkspaceStart() { if [ $x -gt 180 ] then - echo "Workspace didn't start after 3 minutes." + echo "[ERROR] Workspace didn't start after 3 minutes." exit 1 fi } -getCheClusterLogs() { +# Utility to get all logs from che +function getCheClusterLogs() { mkdir -p /root/payload/report/che-logs cd /root/payload/report/che-logs for POD in $(kubectl get pods -o name -n ${NAMESPACE}); do for CONTAINER in $(kubectl get -n ${NAMESPACE} ${POD} -o jsonpath="{.spec.containers[*].name}"); do echo "" - printInfo "Getting logs from $POD" + echo "[INFO] Getting logs from $POD" echo "" kubectl logs ${POD} -c ${CONTAINER} -n ${NAMESPACE} |tee $(echo ${POD}-${CONTAINER}.log | sed 's|pod/||g') done done - printInfo "kubectl get events" + echo "[INFO] kubectl get events" kubectl get events -n ${NAMESPACE}| tee get_events.log - printInfo "kubectl get all" + echo "[INFO] kubectl get all" kubectl get all | tee get_all.log } - -## $1 = name of subdirectory into which the artifacts will be archived. Commonly it's job name. -archiveArtifacts() { - JOB_NAME=$1 - DATE=$(date +"%m-%d-%Y-%H-%M") - echo "Archiving artifacts from ${DATE} for ${JOB_NAME}/${BUILD_NUMBER}" - cd /root/payload - ls -la ./artifacts.key - chmod 600 ./artifacts.key - chown $(whoami) ./artifacts.key - mkdir -p ./che/${JOB_NAME}/${BUILD_NUMBER} - cp -R ./report ./che/${JOB_NAME}/${BUILD_NUMBER}/ | true - rsync --password-file=./artifacts.key -Hva --partial --relative ./che/${JOB_NAME}/${BUILD_NUMBER} devtools@artifacts.ci.centos.org::devtools/ -} - -load_jenkins_vars() { - set +x - eval "$(./env-toolkit load -f jenkins-env.json \ - CHE_BOT_GITHUB_TOKEN)" -} diff --git a/.github/action_scripts/minishift_cert_gen.sh b/.github/action_scripts/minishift_cert_gen.sh new file mode 100644 index 0000000000..e21c10d13c --- /dev/null +++ b/.github/action_scripts/minishift_cert_gen.sh @@ -0,0 +1,63 @@ +#!/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 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation + +# Please note. This certificates are generated only in MacOS +export CA_CN="Local Eclipse Che Signer" +export DOMAIN=\*.$( minishift ip ).nip.io +export OPENSSL_CNF=/System/Library/OpenSSL/openssl.cnf + +openssl genrsa -out ca.key 4096 +openssl req -x509 \ + -new -nodes \ + -key ca.key \ + -sha256 \ + -days 1024 \ + -out ca.crt \ + -subj /CN="${CA_CN}" \ + -reqexts SAN \ + -extensions SAN \ + -config <(cat ${OPENSSL_CNF} \ + <(printf '[SAN]\nbasicConstraints=critical, CA:TRUE\nkeyUsage=keyCertSign, cRLSign, digitalSignature')) + openssl genrsa -out domain.key 2048 + +openssl req -new -sha256 \ + -key domain.key \ + -subj "/O=Local Eclipse Che/CN=${DOMAIN}" \ + -reqexts SAN \ + -config <(cat ${OPENSSL_CNF} \ + <(printf "\n[SAN]\nsubjectAltName=DNS:${DOMAIN}\nbasicConstraints=critical, CA:FALSE\nkeyUsage=digitalSignature, keyEncipherment, keyAgreement, dataEncipherment\nextendedKeyUsage=serverAuth")) \ + -out domain.csr + + openssl x509 \ + -req \ + -sha256 \ + -extfile <(printf "subjectAltName=DNS:${DOMAIN}\nbasicConstraints=critical, CA:FALSE\nkeyUsage=digitalSignature, keyEncipherment, keyAgreement, dataEncipherment\nextendedKeyUsage=serverAuth") \ + -days 365 \ + -in domain.csr \ + -CA ca.crt \ + -CAkey ca.key \ + -CAcreateserial -out domain.crt + +# Add the newer minishift certificate to minishift router-certs +sleep 60 +eval $(minishift oc-env) + +oc login -u system:admin --insecure-skip-tls-verify=true +oc create namespace che +oc project default + +oc delete secret router-certs +cat domain.crt domain.key > minishift.crt +oc create secret tls router-certs --key=domain.key --cert=minishift.crt +oc rollout latest router +oc create secret generic self-signed-certificate --from-file=ca.crt -n=che +oc adm policy add-cluster-role-to-user cluster-admin developer && oc login -u developer -p developer diff --git a/.github/workflows/che-nightly.yaml b/.github/workflows/che-nightly.yaml new file mode 100644 index 0000000000..94068e94c9 --- /dev/null +++ b/.github/workflows/che-nightly.yaml @@ -0,0 +1,30 @@ +# +# 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: Che Operator che nightly +on: pull_request +jobs: + minishift-e2e: + name: Minishift che nightly + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - 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: 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 + - name: Update minishift deprecated certificates and run e2e + run: eval $(minishift oc-env) && /bin/bash .ci/cico_minishift_nightly.sh diff --git a/.github/workflows/che-operator-updates.yaml b/.github/workflows/che-operator-updates.yaml new file mode 100644 index 0000000000..abc28fb8df --- /dev/null +++ b/.github/workflows/che-operator-updates.yaml @@ -0,0 +1,48 @@ +# +# 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: Che Operator Updates +on: pull_request +jobs: + minikube-e2e: + name: Minikube + 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: 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 + minishift-update: + name: Minishift update + 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 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: | + # Run E2E tests + eval $(minishift oc-env) + pip install yq + /bin/bash .ci/cico_updates_minishift.sh diff --git a/.github/workflows/checkNightlyOpmBundle.yaml b/.github/workflows/checkNightlyOpmBundle.yaml index cf6ea72a78..3c766977a7 100644 --- a/.github/workflows/checkNightlyOpmBundle.yaml +++ b/.github/workflows/checkNightlyOpmBundle.yaml @@ -11,7 +11,7 @@ # name: Check nightly "opm" bundle -on: [pull_request, push] +on: pull_request jobs: build: diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 0000000000..7873213ca0 --- /dev/null +++ b/.github/workflows/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: Che Operator e2e tests +on: pull_request +jobs: + minishift-e2e: + name: Minishift e2e + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - 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) + + # Run E2E tests + oc apply -f deploy/crds/org_v1_che_crd.yaml + go mod tidy + go run e2e/*.go + diff --git a/.github/workflows/olm_checks_platforms.yaml b/.github/workflows/olm_checks_platforms.yaml new file mode 100644 index 0000000000..4d125dd2d2 --- /dev/null +++ b/.github/workflows/olm_checks_platforms.yaml @@ -0,0 +1,28 @@ +# +# 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: Che Operator olm +on: pull_request +jobs: + minikube-e2e: + name: Minikube olm changes + 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: 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 \ No newline at end of file diff --git a/e2e/create.go b/e2e/create.go index ab29d87a1a..42599958f1 100644 --- a/e2e/create.go +++ b/e2e/create.go @@ -104,7 +104,7 @@ func createNamespace(ns *corev1.Namespace) (err error) { ns, err = client.clientset.CoreV1().Namespaces().Create(ns) if err != nil { - logrus.Fatalf("Failed to create namespace %s: %s", ns.Name, err) + logrus.Warn(err) return err } return nil diff --git a/e2e/tests.go b/e2e/tests.go index 986402dca1..ca4a34765c 100644 --- a/e2e/tests.go +++ b/e2e/tests.go @@ -45,7 +45,7 @@ func main() { logrus.Infof("Creating a new namespace: %s", namespace) ns := newNamespace() if err := createNamespace(ns); err != nil { - logrus.Fatalf("Failed to create a namespace %s: %s", ns.Name, err) + logrus.Warn(err) } logrus.Info("Creating a new CR") diff --git a/olm/olm.sh b/olm/olm.sh index ee956ec69c..7f6f9dc66a 100755 --- a/olm/olm.sh +++ b/olm/olm.sh @@ -376,6 +376,7 @@ waitCheServerDeploy() { while [[ $i -le 480 ]] do status=$(kubectl get checluster/eclipse-che -n "${namespace}" -o jsonpath={.status.cheClusterRunning}) + kubectl get pods -n "${namespace}" if [ "${status:-UNAVAILABLE}" == "Available" ] then break diff --git a/olm/testCatalogSource.sh b/olm/testCatalogSource.sh index 421cd2187f..329d5b55ba 100755 --- a/olm/testCatalogSource.sh +++ b/olm/testCatalogSource.sh @@ -126,7 +126,6 @@ buildOLMImages() { if [[ "${PLATFORM}" == "kubernetes" ]] then echo "[INFO]: Kubernetes platform detected" - eval "$(minikube docker-env)" # Build operator image if [ -n "${OPERATOR_IMAGE}" ];then @@ -151,7 +150,6 @@ buildOLMImages() { buildCatalogImage "${CATALOG_SOURCE_IMAGE}" "${CATALOG_BUNDLE_IMAGE}" fi - minikube addons enable ingress echo "[INFO]: Successfully created catalog source container image and enabled minikube ingress." elif [[ "${PLATFORM}" == "openshift" ]] then From a4fe033b967c2f95e8def3eac9e7a247a49cb6ec Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Mon, 21 Sep 2020 09:04:57 +0200 Subject: [PATCH 02/11] Fixes Signed-off-by: Flavius Lacatusu --- .ci/cico_minishift_nightly.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.ci/cico_minishift_nightly.sh b/.ci/cico_minishift_nightly.sh index 76305f952b..82d77f1264 100755 --- a/.ci/cico_minishift_nightly.sh +++ b/.ci/cico_minishift_nightly.sh @@ -18,14 +18,13 @@ function init() { export RAM_MEMORY=8192 export NAMESPACE="che" export PLATFORM="openshift" - + export OPERATOR_IMAGE=quay.io/eclipse/che-operator:nightly # Set operator root directory if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then OPERATOR_REPO=${WORKSPACE}; else OPERATOR_REPO=$(dirname "$SCRIPT_DIR"); fi - } # Deploy Eclipse Che From 7c5ed743da8cff57a9c6b0d64716fac079116a6e Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Tue, 22 Sep 2020 13:19:36 +0200 Subject: [PATCH 03/11] Fix openshift tests and rename actions name Signed-off-by: Flavius Lacatusu --- .ci/cico_olm_openshift.sh | 134 ++++++++------------ .github/workflows/che-nightly.yaml | 4 +- .github/workflows/che-operator-updates.yaml | 4 +- .github/workflows/e2e.yaml | 3 +- .github/workflows/olm_checks_platforms.yaml | 4 +- 5 files changed, 60 insertions(+), 89 deletions(-) diff --git a/.ci/cico_olm_openshift.sh b/.ci/cico_olm_openshift.sh index fc8e823ee1..b26d1418ab 100755 --- a/.ci/cico_olm_openshift.sh +++ b/.ci/cico_olm_openshift.sh @@ -1,100 +1,72 @@ #!/bin/bash # -# Copyright (c) 2020 Red Hat, Inc. +# 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 - -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 "Failed on running tests. Please check logs or contact QE team (e-mail:codereadyqe-workspaces-qe@redhat.com, Slack: #che-qe-internal, Eclipse mattermost: 'Eclipse Che QE'" - echo "Logs should be availabe on http://artifacts.ci.centos.org/devtools/che/che-eclipse-minikube-updates/${ghprbPullId}/" - exit 1 - getCheClusterLogs - archiveArtifacts "che-operator-minikube-updates" - fi - rm -rf ~/.kube ~/.minikube - exit $result -} -init() { - SCRIPT=$(readlink -f "$0") - SCRIPT_DIR=$(dirname "$SCRIPT") +set -e - if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then - OPERATOR_REPO=${WORKSPACE}; - else - OPERATOR_REPO=$(dirname "$SCRIPT_DIR"); - fi +# Detect the base directory where che-operator is cloned +SCRIPT=$(readlink -f "$0") +export SCRIPT - RAM_MEMORY=8192 - PLATFORM="kubernetes" - NAMESPACE="che" - CHANNEL="stable" -} +OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")"); +export OPERATOR_REPO -waitCheUpdateInstall() { - 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//") - - echo -e "\u001b[34m Check installation last version che-operator...$lastPackageVersion \u001b[0m" - - export n=0 - - while [ $n -le 360 ] - do - cheVersion=$(kubectl get checluster/eclipse-che -n "${NAMESPACE}" -o jsonpath={.status.cheVersion}) - if [ "${cheVersion}" == $lastPackageVersion ] - then - echo -e "\u001b[32m Installed latest version che-operator: ${lastCSV} \u001b[0m" - break - fi - sleep 3 - n=$(( n+1 )) - done - - if [ $n -gt 360 ] - then - echo "Latest version install for Eclipse che failed." - exit 1 - fi -} +# ENV used by Openshift CI +ARTIFACTS_DIR="/tmp/artifacts" +export ARTIFACTS_DIR + +# 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 -testUpdates() { - "${OPERATOR_REPO}"/olm/testUpdate.sh ${PLATFORM} ${CHANNEL} ${NAMESPACE} - echo "Successfully installed Eclipse Che previous version." +# 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 - getCheAcessToken - chectl workspace:create --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml +# Choose if install Eclipse Che using an operatorsource or Custom Catalog Source +INSTALLATION_TYPE="catalog" +export INSTALLATION_TYPE - waitCheUpdateInstall - getCheAcessToken +# Execute olm nightly files in openshift +PLATFORM="openshift" +export PLATFORM - workspaceList=$(chectl workspace:list) - workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b') - echo $workspaceID - chectl workspace:start $workspaceID +# Test nightly olm files +CHANNEL="nightly" +export CHANNEL - waitWorkspaceStart +# Test nightly olm files +NAMESPACE="che" +export NAMESPACE + +# 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} + + source "${OPERATOR_REPO}"/.ci/util/ci_common.sh + 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 + waitWorkspaceStart } -init -source "${OPERATOR_REPO}"/.ci/util/ci_common.sh -testUpdates +run + +# grab che-operator namespace events after running olm nightly tests +oc get events -n ${NAMESPACE} | tee ${ARTIFACTS_DIR}/che-operator-events.log diff --git a/.github/workflows/che-nightly.yaml b/.github/workflows/che-nightly.yaml index 94068e94c9..827811d768 100644 --- a/.github/workflows/che-nightly.yaml +++ b/.github/workflows/che-nightly.yaml @@ -9,11 +9,11 @@ # Contributors: # Red Hat, Inc. - initial API and implementation -name: Che Operator che nightly +name: Testing latest changes on: pull_request jobs: minishift-e2e: - name: Minishift che nightly + name: Minishift runs-on: macos-latest steps: - uses: actions/checkout@v1 diff --git a/.github/workflows/che-operator-updates.yaml b/.github/workflows/che-operator-updates.yaml index abc28fb8df..1e2f7b0d68 100644 --- a/.github/workflows/che-operator-updates.yaml +++ b/.github/workflows/che-operator-updates.yaml @@ -10,7 +10,7 @@ # Red Hat, Inc. - initial API and implementation # -name: Che Operator Updates +name: Testing stable versions updates on: pull_request jobs: minikube-e2e: @@ -27,7 +27,7 @@ jobs: - name: Run che operator updates minikube run: /bin/bash .ci/cico_updates_minikube.sh minishift-update: - name: Minishift update + name: Minishift runs-on: macos-latest steps: - uses: actions/checkout@v1 diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 7873213ca0..a953dfee7c 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -12,7 +12,7 @@ name: Che Operator e2e tests on: pull_request jobs: minishift-e2e: - name: Minishift e2e + name: Minishift runs-on: macos-latest steps: - uses: actions/checkout@v1 @@ -31,4 +31,3 @@ jobs: oc apply -f deploy/crds/org_v1_che_crd.yaml go mod tidy go run e2e/*.go - diff --git a/.github/workflows/olm_checks_platforms.yaml b/.github/workflows/olm_checks_platforms.yaml index 4d125dd2d2..b2ca0de563 100644 --- a/.github/workflows/olm_checks_platforms.yaml +++ b/.github/workflows/olm_checks_platforms.yaml @@ -10,11 +10,11 @@ # Red Hat, Inc. - initial API and implementation # -name: Che Operator olm +name: Testing latest changes with olm on: pull_request jobs: minikube-e2e: - name: Minikube olm changes + name: Minikube runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 From 4b3e6805e1de7b2957c2cfef20b419b609039fb5 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Tue, 22 Sep 2020 14:14:26 +0200 Subject: [PATCH 04/11] Add artifacts with job results to actions Signed-off-by: Flavius Lacatusu --- .ci/cico_minishift_nightly.sh | 19 ++++++++++++++++ .ci/cico_olm_minikube.sh | 24 +++++++++++++++++++-- .ci/cico_updates_minikube.sh | 12 ++++++----- .ci/cico_updates_minishift.sh | 19 ++++++++++++++++ .ci/util/ci_common.sh | 4 ++-- .github/workflows/che-nightly.yaml | 4 ++++ .github/workflows/che-operator-updates.yaml | 8 +++++++ .github/workflows/e2e.yaml | 4 ++++ .github/workflows/olm_checks_platforms.yaml | 6 +++++- 9 files changed, 90 insertions(+), 10 deletions(-) diff --git a/.ci/cico_minishift_nightly.sh b/.ci/cico_minishift_nightly.sh index 82d77f1264..01f47f6a24 100755 --- a/.ci/cico_minishift_nightly.sh +++ b/.ci/cico_minishift_nightly.sh @@ -12,6 +12,25 @@ 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" + getCheClusterLogs + exit 1 + fi + + echo "[INFO] JOb finished Successfully.Please check the artifacts in github actions" + getCheClusterLogs + + exit $result +} + function init() { export SCRIPT=$(readlink -f "$0") export SCRIPT_DIR=$(dirname "$SCRIPT") diff --git a/.ci/cico_olm_minikube.sh b/.ci/cico_olm_minikube.sh index ac2519c7b1..93fd059ba6 100755 --- a/.ci/cico_olm_minikube.sh +++ b/.ci/cico_olm_minikube.sh @@ -16,6 +16,9 @@ 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 @@ -43,13 +46,30 @@ 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} - source "${OPERATOR_REPO}"/.ci/util/ci_common.sh - # Create and start a workspace getCheAcessToken chectl workspace:create --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml diff --git a/.ci/cico_updates_minikube.sh b/.ci/cico_updates_minikube.sh index fc8e823ee1..a0b6db28b9 100644 --- a/.ci/cico_updates_minikube.sh +++ b/.ci/cico_updates_minikube.sh @@ -18,14 +18,16 @@ trap "catchFinish" EXIT SIGINT # Catch_Finish is executed after finish script. catchFinish() { result=$? + if [ "$result" != "0" ]; then - echo "Failed on running tests. Please check logs or contact QE team (e-mail:codereadyqe-workspaces-qe@redhat.com, Slack: #che-qe-internal, Eclipse mattermost: 'Eclipse Che QE'" - echo "Logs should be availabe on http://artifacts.ci.centos.org/devtools/che/che-eclipse-minikube-updates/${ghprbPullId}/" - exit 1 + echo "[ERROR] Please check the artifacts in github actions" getCheClusterLogs - archiveArtifacts "che-operator-minikube-updates" + exit 1 fi - rm -rf ~/.kube ~/.minikube + + echo "[INFO] JOb finished Successfully.Please check the artifacts in github actions" + getCheClusterLogs + exit $result } diff --git a/.ci/cico_updates_minishift.sh b/.ci/cico_updates_minishift.sh index 8db32fa16a..417e7f0ace 100755 --- a/.ci/cico_updates_minishift.sh +++ b/.ci/cico_updates_minishift.sh @@ -12,6 +12,25 @@ 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" + getCheClusterLogs + exit 1 + fi + + echo "[INFO] JOb finished Successfully.Please check the artifacts in github actions" + getCheClusterLogs + + exit $result +} + function init() { export SCRIPT=$(readlink -f "$0") export SCRIPT_DIR=$(dirname "$SCRIPT") diff --git a/.ci/util/ci_common.sh b/.ci/util/ci_common.sh index f4ab2b481b..fd6beea401 100644 --- a/.ci/util/ci_common.sh +++ b/.ci/util/ci_common.sh @@ -68,8 +68,8 @@ function waitWorkspaceStart() { # Utility to get all logs from che function getCheClusterLogs() { - mkdir -p /root/payload/report/che-logs - cd /root/payload/report/che-logs + mkdir -p /tmp/artifacts-che + cd /tmp/artifacts-che for POD in $(kubectl get pods -o name -n ${NAMESPACE}); do for CONTAINER in $(kubectl get -n ${NAMESPACE} ${POD} -o jsonpath="{.spec.containers[*].name}"); do echo "" diff --git a/.github/workflows/che-nightly.yaml b/.github/workflows/che-nightly.yaml index 827811d768..3997ac9ebe 100644 --- a/.github/workflows/che-nightly.yaml +++ b/.github/workflows/che-nightly.yaml @@ -28,3 +28,7 @@ jobs: run: /bin/bash .github/action_scripts/minishift_cert_gen.sh - name: Update minishift deprecated certificates and run e2e run: eval $(minishift oc-env) && /bin/bash .ci/cico_minishift_nightly.sh + - uses: actions/upload-artifact@v2 + with: + name: che-nightly-artifacts + path: /tmp/artifacts-che diff --git a/.github/workflows/che-operator-updates.yaml b/.github/workflows/che-operator-updates.yaml index 1e2f7b0d68..5999e470cf 100644 --- a/.github/workflows/che-operator-updates.yaml +++ b/.github/workflows/che-operator-updates.yaml @@ -26,6 +26,10 @@ jobs: 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 + - uses: actions/upload-artifact@v2 + with: + name: minikube-updates-artifacts + path: /tmp/artifacts-che minishift-update: name: Minishift runs-on: macos-latest @@ -46,3 +50,7 @@ jobs: eval $(minishift oc-env) pip install yq /bin/bash .ci/cico_updates_minishift.sh + - uses: actions/upload-artifact@v2 + with: + name: minishift-updates-artifacts + path: /tmp/artifacts-che diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index a953dfee7c..f9fcc3dc63 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -31,3 +31,7 @@ jobs: 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 \ No newline at end of file diff --git a/.github/workflows/olm_checks_platforms.yaml b/.github/workflows/olm_checks_platforms.yaml index b2ca0de563..bfa82e587a 100644 --- a/.github/workflows/olm_checks_platforms.yaml +++ b/.github/workflows/olm_checks_platforms.yaml @@ -25,4 +25,8 @@ jobs: - 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 \ No newline at end of file + run: /bin/bash .ci/cico_olm_minikube.sh + - uses: actions/upload-artifact@v2 + with: + name: minikube-olm-artifacts + path: /tmp/artifacts-che \ No newline at end of file From ef701eb2c71102a3322212949fcadea1027c5da1 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Wed, 23 Sep 2020 10:53:51 +0200 Subject: [PATCH 05/11] Build operator image in nightly tests Signed-off-by: Flavius Lacatusu --- .ci/cico_minishift_nightly.sh | 14 +++++++++++++- .ci/util/ci_common.sh | 19 ++++++++++++------- .github/workflows/che-nightly.yaml | 23 +++++++++++++++++++++-- .github/workflows/e2e.yaml | 18 +++++++++++++++++- 4 files changed, 63 insertions(+), 11 deletions(-) diff --git a/.ci/cico_minishift_nightly.sh b/.ci/cico_minishift_nightly.sh index 01f47f6a24..7101677331 100755 --- a/.ci/cico_minishift_nightly.sh +++ b/.ci/cico_minishift_nightly.sh @@ -37,7 +37,8 @@ function init() { export RAM_MEMORY=8192 export NAMESPACE="che" export PLATFORM="openshift" - export OPERATOR_IMAGE=quay.io/eclipse/che-operator:nightly + export CLI_TOOL="oc" + # Set operator root directory if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then OPERATOR_REPO=${WORKSPACE}; @@ -56,6 +57,17 @@ spec: EOL echo "======= Che cr patch =======" cat /tmp/che-cr-patch.yaml + + # OPERATOR_IMAGE In CI is defined in .github/workflows/che-nightly.yaml + if [[ ! -z "${OPERATOR_IMAGE}" ]]; then + OPERATOR_IMAGE="quay.io/eclipse/che-operator:nightly" + fi + + cat deploy/operator.yaml | \ + sed 's|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|' | \ + sed 's|quay.io/eclipse/che-operator:nightly|'${OPERATOR_IMAGE}'|' | \ + oc apply -n ${NAMESPACE} -f - + chectl server:start --platform=minishift --skip-kubernetes-health-check --installer=operator --chenamespace=${NAMESPACE} --che-operator-cr-patch-yaml=/tmp/che-cr-patch.yaml --che-operator-image ${OPERATOR_IMAGE} # Create and start a workspace diff --git a/.ci/util/ci_common.sh b/.ci/util/ci_common.sh index fd6beea401..29b0e89ac8 100644 --- a/.ci/util/ci_common.sh +++ b/.ci/util/ci_common.sh @@ -70,16 +70,21 @@ function waitWorkspaceStart() { function getCheClusterLogs() { mkdir -p /tmp/artifacts-che cd /tmp/artifacts-che - for POD in $(kubectl get pods -o name -n ${NAMESPACE}); do - for CONTAINER in $(kubectl get -n ${NAMESPACE} ${POD} -o jsonpath="{.spec.containers[*].name}"); do + + # OPERATOR_IMAGE In CI is defined in .github/workflows/che-nightly.yaml + if [[ ! -z "${CLI_TOOL}" ]]; then + CLI_TOOL="kubectl" + fi + + for POD in $($CLI_TOOL get pods -o name -n ${NAMESPACE}); do + for CONTAINER in $($CLI_TOOL get -n ${NAMESPACE} ${POD} -o jsonpath="{.spec.containers[*].name}"); do echo "" echo "[INFO] Getting logs from $POD" echo "" - kubectl logs ${POD} -c ${CONTAINER} -n ${NAMESPACE} |tee $(echo ${POD}-${CONTAINER}.log | sed 's|pod/||g') + $CLI_TOOL logs ${POD} -c ${CONTAINER} -n ${NAMESPACE} |tee $(echo ${POD}-${CONTAINER}.log | sed 's|pod/||g') done done - echo "[INFO] kubectl get events" - kubectl get events -n ${NAMESPACE}| tee get_events.log - echo "[INFO] kubectl get all" - kubectl get all | tee get_all.log + echo "[INFO] Get events" + $CLI_TOOL get events -n ${NAMESPACE}| tee get_events.log + $CLI_TOOL get all | tee get_all.log } diff --git a/.github/workflows/che-nightly.yaml b/.github/workflows/che-nightly.yaml index 3997ac9ebe..0055b487fe 100644 --- a/.github/workflows/che-nightly.yaml +++ b/.github/workflows/che-nightly.yaml @@ -17,6 +17,18 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v1 + # All docker operations should be done in this step + - name: Build operator image + run: | + export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test + + brew install docker-machine docker + docker-machine create --driver virtualbox default + eval "$(docker-machine env default)" + + docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker save "${OPERATOR_IMAGE}" > operator.tar + + docker-machine stop - name: Install and start minishift OCP 3.11 cluster run: | brew cask install minishift @@ -27,8 +39,15 @@ jobs: - 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) && /bin/bash .ci/cico_minishift_nightly.sh + 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_nightly.sh - uses: actions/upload-artifact@v2 with: - name: che-nightly-artifacts + name: minishift-che-nightly-artifacts path: /tmp/artifacts-che diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index f9fcc3dc63..5564506bb8 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -16,6 +16,17 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v1 + - name: Build operator image + run: | + export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test + + brew install docker-machine docker + docker-machine create --driver virtualbox default + eval "$(docker-machine env default)" + 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 @@ -26,12 +37,17 @@ jobs: - 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 \ No newline at end of file + path: /tmp/artifacts-che From 56884fa9606f54f7504062a749b86e633c366647 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Wed, 23 Sep 2020 11:00:32 +0200 Subject: [PATCH 06/11] Add github_token secret Signed-off-by: Flavius Lacatusu --- .github/workflows/che-nightly.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/che-nightly.yaml b/.github/workflows/che-nightly.yaml index 0055b487fe..84ce20b649 100644 --- a/.github/workflows/che-nightly.yaml +++ b/.github/workflows/che-nightly.yaml @@ -23,7 +23,7 @@ jobs: export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test brew install docker-machine docker - docker-machine create --driver virtualbox default + docker-machine --github-api-token=${{ secrets.GITHUB_TOKEN }} create --driver virtualbox default eval "$(docker-machine env default)" docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker save "${OPERATOR_IMAGE}" > operator.tar From 555fa6669d8488a643c4000d0cf2d7ce67559369 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Wed, 23 Sep 2020 11:03:35 +0200 Subject: [PATCH 07/11] Fixes Signed-off-by: Flavius Lacatusu --- .github/workflows/che-nightly.yaml | 2 +- .github/workflows/e2e.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/che-nightly.yaml b/.github/workflows/che-nightly.yaml index 84ce20b649..fcd3a3cfeb 100644 --- a/.github/workflows/che-nightly.yaml +++ b/.github/workflows/che-nightly.yaml @@ -23,7 +23,7 @@ jobs: export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test brew install docker-machine docker - docker-machine --github-api-token=${{ secrets.GITHUB_TOKEN }} create --driver virtualbox default + docker-machine --github-api-token="${{ secrets.GITHUB_TOKEN }}" create --driver virtualbox default eval "$(docker-machine env default)" docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker save "${OPERATOR_IMAGE}" > operator.tar diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 5564506bb8..d6d961e94f 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -21,7 +21,7 @@ jobs: export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test brew install docker-machine docker - docker-machine create --driver virtualbox default + docker-machine --github-api-token="${{ secrets.GITHUB_TOKEN }}" create --driver virtualbox default eval "$(docker-machine env default)" 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 From 0746ccef96c6d4310ca7fb85cd67cf0c9d9cbc75 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Wed, 23 Sep 2020 11:46:33 +0200 Subject: [PATCH 08/11] Fixes Signed-off-by: Flavius Lacatusu --- .ci/cico_minishift_nightly.sh | 4 +--- .ci/util/ci_common.sh | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.ci/cico_minishift_nightly.sh b/.ci/cico_minishift_nightly.sh index 7101677331..bcb74bc9ae 100755 --- a/.ci/cico_minishift_nightly.sh +++ b/.ci/cico_minishift_nightly.sh @@ -59,9 +59,7 @@ EOL cat /tmp/che-cr-patch.yaml # OPERATOR_IMAGE In CI is defined in .github/workflows/che-nightly.yaml - if [[ ! -z "${OPERATOR_IMAGE}" ]]; then - OPERATOR_IMAGE="quay.io/eclipse/che-operator:nightly" - fi + export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test" cat deploy/operator.yaml | \ sed 's|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|' | \ diff --git a/.ci/util/ci_common.sh b/.ci/util/ci_common.sh index 29b0e89ac8..50a8a557bd 100644 --- a/.ci/util/ci_common.sh +++ b/.ci/util/ci_common.sh @@ -72,7 +72,7 @@ function getCheClusterLogs() { cd /tmp/artifacts-che # OPERATOR_IMAGE In CI is defined in .github/workflows/che-nightly.yaml - if [[ ! -z "${CLI_TOOL}" ]]; then + if [[ "${CLI_TOOL}" == "oc" ]]; then CLI_TOOL="kubectl" fi From 014490739888026545b9e97b23a6f6b6a897ef03 Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Wed, 23 Sep 2020 12:43:12 +0200 Subject: [PATCH 09/11] Fix artifacts Signed-off-by: Flavius Lacatusu --- .ci/cico_minishift_nightly.sh | 24 +++++++++++++++++++++--- .ci/cico_olm_minikube.sh | 2 -- .ci/cico_updates_minishift.sh | 22 ++++++++++++++++++++-- .ci/start-minikube.sh | 2 +- .ci/util/ci_common.sh | 15 +++++---------- 5 files changed, 47 insertions(+), 18 deletions(-) diff --git a/.ci/cico_minishift_nightly.sh b/.ci/cico_minishift_nightly.sh index bcb74bc9ae..c3effa4d0f 100755 --- a/.ci/cico_minishift_nightly.sh +++ b/.ci/cico_minishift_nightly.sh @@ -21,23 +21,23 @@ catchFinish() { if [ "$result" != "0" ]; then echo "[ERROR] Please check the artifacts in github actions" - getCheClusterLogs + getOCCheClusterLogs exit 1 fi echo "[INFO] JOb finished Successfully.Please check the artifacts in github actions" - getCheClusterLogs + 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" - export CLI_TOOL="oc" # Set operator root directory if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then @@ -47,6 +47,24 @@ function init() { fi } +# 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() { cat >/tmp/che-cr-patch.yaml < Date: Wed, 23 Sep 2020 14:45:16 +0200 Subject: [PATCH 10/11] Implement suggestions Signed-off-by: Flavius Lacatusu --- .ci/cico_minishift_nightly.sh | 2 +- .ci/cico_olm_minikube.sh | 4 +--- .ci/cico_updates_minikube.sh | 16 ++++++++-------- .ci/cico_updates_minishift.sh | 4 ++-- .ci/cico_updates_openshift.sh | 5 ++--- .ci/start-minikube.sh | 2 -- .github/workflows/olm_checks_platforms.yaml | 2 +- 7 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.ci/cico_minishift_nightly.sh b/.ci/cico_minishift_nightly.sh index c3effa4d0f..0dca2ad63c 100755 --- a/.ci/cico_minishift_nightly.sh +++ b/.ci/cico_minishift_nightly.sh @@ -25,7 +25,7 @@ catchFinish() { exit 1 fi - echo "[INFO] JOb finished Successfully.Please check the artifacts in github actions" + echo "[INFO] Job finished Successfully.Please check the artifacts in github actions" getOCCheClusterLogs exit $result diff --git a/.ci/cico_olm_minikube.sh b/.ci/cico_olm_minikube.sh index 5496b3a646..f04e2adf49 100755 --- a/.ci/cico_olm_minikube.sh +++ b/.ci/cico_olm_minikube.sh @@ -59,7 +59,7 @@ catchFinish() { exit 1 fi - echo "[INFO] JOb finished Successfully.Please check the artifacts in github actions" + echo "[INFO] Job finished Successfully.Please check the artifacts in github actions" getCheClusterLogs exit $result @@ -95,7 +95,5 @@ function setPrivateRegistryForDocker { fi } -echo "[INFO] Trying to get pod name of the registry proxy..." -REGISTRY_PROXY_POD=$(kubectl get pods -n kube-system -o yaml | grep "name: registry-proxy-" | sed -e 's;.*name: \(\);\1;') || true setPrivateRegistryForDocker run diff --git a/.ci/cico_updates_minikube.sh b/.ci/cico_updates_minikube.sh index a0b6db28b9..1b5d6f0b5e 100644 --- a/.ci/cico_updates_minikube.sh +++ b/.ci/cico_updates_minikube.sh @@ -16,7 +16,7 @@ set -ex trap "catchFinish" EXIT SIGINT # Catch_Finish is executed after finish script. -catchFinish() { +function catchFinish() { result=$? if [ "$result" != "0" ]; then @@ -25,13 +25,13 @@ catchFinish() { exit 1 fi - echo "[INFO] JOb finished Successfully.Please check the artifacts in github actions" + echo "[INFO] Job finished Successfully.Please check the artifacts in github actions" getCheClusterLogs exit $result } -init() { +function init() { SCRIPT=$(readlink -f "$0") SCRIPT_DIR=$(dirname "$SCRIPT") @@ -47,7 +47,7 @@ init() { CHANNEL="stable" } -waitCheUpdateInstall() { +function waitCheUpdateInstall() { export packageName=eclipse-che-preview-${PLATFORM} export platformPath=${OPERATOR_REPO}/olm/${packageName} export packageFolderPath="${platformPath}/deploy/olm-catalog/${packageName}" @@ -74,14 +74,14 @@ waitCheUpdateInstall() { if [ $n -gt 360 ] then - echo "Latest version install for Eclipse che failed." + echo "[ERROR] Latest version install for Eclipse che failed." exit 1 fi } -testUpdates() { +function testUpdates() { "${OPERATOR_REPO}"/olm/testUpdate.sh ${PLATFORM} ${CHANNEL} ${NAMESPACE} - echo "Successfully installed Eclipse Che previous version." + echo "[INFO] Successfully installed Eclipse Che previous version." getCheAcessToken chectl workspace:create --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml @@ -91,7 +91,7 @@ testUpdates() { workspaceList=$(chectl workspace:list) workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b') - echo $workspaceID + echo "[INFO] Workspace id of created workspace is: ${workspaceID}" chectl workspace:start $workspaceID waitWorkspaceStart diff --git a/.ci/cico_updates_minishift.sh b/.ci/cico_updates_minishift.sh index 986ec5cebc..f4f4ea5da0 100755 --- a/.ci/cico_updates_minishift.sh +++ b/.ci/cico_updates_minishift.sh @@ -25,7 +25,7 @@ catchFinish() { exit 1 fi - echo "[INFO] JOb finished Successfully.Please check the artifacts in github actions" + echo "[INFO] Job finished Successfully.Please check the artifacts in github actions" getOCCheClusterLogs exit $result @@ -147,7 +147,7 @@ function minishiftUpdates() { # Grep applied to MacOS workspaceID=$(echo "$workspaceList" | grep workspace | awk '{ print $1} ') workspaceID="${workspaceID%'ID'}" - echo $workspaceID + echo "[INFO] Workspace id of created workspace is: ${workspaceID}" chectl workspace:start $workspaceID diff --git a/.ci/cico_updates_openshift.sh b/.ci/cico_updates_openshift.sh index 98df0b5ed2..2a7ac14c8c 100755 --- a/.ci/cico_updates_openshift.sh +++ b/.ci/cico_updates_openshift.sh @@ -22,13 +22,12 @@ init() { export OPERATOR_REPO=$(dirname "$SCRIPT_DIR"); fi - export RAM_MEMORY=8192 export PLATFORM="openshift" export NAMESPACE="che" export CHANNEL="stable" } -# Utility to wait for eclipse che to be up in Openshift +# Utility to wait for Eclipse Che to be up in Openshift function waitCheUpdateInstall() { export packageName=eclipse-che-preview-${PLATFORM} export platformPath=${OPERATOR_REPO}/olm/${packageName} @@ -56,7 +55,7 @@ function waitCheUpdateInstall() { if [ $n -gt 360 ] then - echo "Latest version install for Eclipse che failed." + echo "[ERROR] Latest version install for Eclipse Che failed." exit 1 fi } diff --git a/.ci/start-minikube.sh b/.ci/start-minikube.sh index 033afe698d..58f4e9f873 100755 --- a/.ci/start-minikube.sh +++ b/.ci/start-minikube.sh @@ -43,8 +43,6 @@ minikube config set WantNoneDriverWarning false minikube config set vm-driver none minikube version -sudo ufw disable - # minikube start sudo minikube start --kubernetes-version=$KUBERNETES_VERSION --extra-config=kubelet.resolv-conf=/run/systemd/resolve/resolv.conf sudo chown -R $USER $HOME/.kube $HOME/.minikube diff --git a/.github/workflows/olm_checks_platforms.yaml b/.github/workflows/olm_checks_platforms.yaml index bfa82e587a..f89dc6461e 100644 --- a/.github/workflows/olm_checks_platforms.yaml +++ b/.github/workflows/olm_checks_platforms.yaml @@ -29,4 +29,4 @@ jobs: - uses: actions/upload-artifact@v2 with: name: minikube-olm-artifacts - path: /tmp/artifacts-che \ No newline at end of file + path: /tmp/artifacts-che From b881421fd10dc6786033f37a19b36061761dbbbf Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Thu, 24 Sep 2020 08:58:25 +0200 Subject: [PATCH 11/11] Try to fix docker api github token Signed-off-by: Flavius Lacatusu --- .github/workflows/che-nightly.yaml | 4 +++- .github/workflows/e2e.yaml | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/che-nightly.yaml b/.github/workflows/che-nightly.yaml index fcd3a3cfeb..0006133a59 100644 --- a/.github/workflows/che-nightly.yaml +++ b/.github/workflows/che-nightly.yaml @@ -21,10 +21,12 @@ jobs: - name: Build operator image run: | export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test + # coreutils provides a readlink that supports `-f` - brew install docker-machine docker + brew install coreutils docker docker-machine 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 diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index d6d961e94f..d7c9812390 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -19,10 +19,13 @@ jobs: - name: Build operator image run: | export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test + # coreutils provides a readlink that supports `-f` - brew install docker-machine docker + brew install coreutils docker docker-machine 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