From 1f09d952bbb9e6d6103a03d24bb8a7f3a51b4f7e Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Mon, 5 Oct 2020 12:59:00 +0200 Subject: [PATCH] Change single host native deployment test Signed-off-by: Flavius Lacatusu --- .../nightly/minikube/function-utilities.sh | 21 +++-- .../nightly/minikube/single-host-gateway.sh | 2 +- .../nightly/minikube/single-host-native.sh | 76 +++---------------- .github/workflows/single-host-tests.yaml | 26 ++++++- 4 files changed, 48 insertions(+), 77 deletions(-) rename .ci/cico_minikube_shost.sh => .github/action_scripts/nightly/minikube/single-host-native.sh (61%) mode change 100755 => 100644 diff --git a/.github/action_scripts/nightly/minikube/function-utilities.sh b/.github/action_scripts/nightly/minikube/function-utilities.sh index 7800c9fff..87101cb8f 100644 --- a/.github/action_scripts/nightly/minikube/function-utilities.sh +++ b/.github/action_scripts/nightly/minikube/function-utilities.sh @@ -26,15 +26,13 @@ function buildCheOperatorImage() { } # Utility to wait for a workspace to be started after workspace:create. -function waitSingleHostWorkspaceStart() { +function waitWorkspaceStart() { set +e export x=0 while [ $x -le 180 ] do - getSingleHostToken + getCheAcessToken - # 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} ') @@ -55,9 +53,16 @@ function waitSingleHostWorkspaceStart() { fi } -# Get Token from single host mode deployment -function getSingleHostToken() { - export GATEWAY_HOSTNAME=$(minikube ip).nip.io - export TOKEN_ENDPOINT="https://${GATEWAY_HOSTNAME}/auth/realms/che/protocol/openid-connect/token" +# 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=keycloak-che.$(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/action_scripts/nightly/minikube/single-host-gateway.sh b/.github/action_scripts/nightly/minikube/single-host-gateway.sh index b42b22578..d445b6632 100644 --- a/.github/action_scripts/nightly/minikube/single-host-gateway.sh +++ b/.github/action_scripts/nightly/minikube/single-host-gateway.sh @@ -28,7 +28,7 @@ export RAM_MEMORY=8192 export NAMESPACE="che" export PLATFORM="kubernetes" -# Directory where che artifacts will be stored and uploded to GH actions artifacts +# Directory where che artifacts will be stored and uploaded to GH actions artifacts export ARTIFACTS_DIR="/tmp/artifacts-che" # Set operator root directory diff --git a/.ci/cico_minikube_shost.sh b/.github/action_scripts/nightly/minikube/single-host-native.sh old mode 100755 new mode 100644 similarity index 61% rename from .ci/cico_minikube_shost.sh rename to .github/action_scripts/nightly/minikube/single-host-native.sh index 5656546fd..7bac1bfad --- a/.ci/cico_minikube_shost.sh +++ b/.github/action_scripts/nightly/minikube/single-host-native.sh @@ -19,25 +19,20 @@ set -u # print each command before executing it set -x -#Stop execution on any error +# 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 OPERATOR_REPO=$(dirname "$SCRIPT_DIR"); +export OPERATOR_REPO="${GITHUB_WORKSPACE}" +export RAM_MEMORY=8192 +export NAMESPACE="che" +export PLATFORM="kubernetes" - 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" - # Directory where che artifacts will be stored and uploded to GH actions artifacts - export ARTIFACTS_DIR="/tmp/artifacts-che" - - # Set operator root directory - export OPERATOR_IMAGE="che-operator:tests" -} +# Set operator root directory +export OPERATOR_IMAGE="che-operator:tests" # Catch_Finish is executed after finish script. catchFinish() { @@ -98,49 +93,6 @@ function waitSingleHostWorkspaceStart() { fi } -# 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 -} - -# Deploy Eclipse Che in single host mode(gateway exposure type) -function runSHostGatewayExposure() { - # Patch file to pass to chectl - cat >/tmp/che-cr-patch.yaml <