Change single host native deployment test

Signed-off-by: Flavius Lacatusu <flacatus@redhat.com>
pull/481/head
Flavius Lacatusu 2020-10-05 12:59:00 +02:00
parent b6fda13cdd
commit 1f09d952bb
No known key found for this signature in database
GPG Key ID: AB9AB3E390E38ABD
4 changed files with 48 additions and 77 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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 <<EOL
spec:
server:
serverExposureStrategy: 'single-host'
auth:
updateAdminPassword: false
openShiftoAuth: false
k8s:
singleHostExposureType: 'gateway'
EOL
echo "======= Che cr patch ======="
cat /tmp/che-cr-patch.yaml
# Use custom changes, don't pull image from quay.io
oc create namespace che
cat ${OPERATOR_REPO}/deploy/operator.yaml | \
sed 's|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|' | \
sed 's|quay.io/eclipse/che-operator:nightly|'${OPERATOR_IMAGE}'|' | \
oc apply -n ${NAMESPACE} -f -
# Start to deploy Che
chectl server:start --platform=minikube --skip-kubernetes-health-check --installer=operator \
--chenamespace=${NAMESPACE} --che-operator-image=${OPERATOR_IMAGE} --che-operator-cr-patch-yaml=/tmp/che-cr-patch.yaml
# Create and start a workspace
getSingleHostToken # Function from ./util/ci_common.sh
chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
# Wait for workspace to be up
waitSingleHostWorkspaceStart
chectl server:delete --chenamespace=${NAMESPACE} --skip-deletion-check
}
# Deploy Eclipse Che in single host mode(native exposure type)
function runSHostNativeExposure() {
# Patch file to pass to chectl
@ -156,7 +108,7 @@ EOL
cat /tmp/che-cr-patch.yaml
# Use custom changes, don't pull image from quay.io
checkNamespace
kubectl create namespace ${NAMESPACE}
cat ${OPERATOR_REPO}/deploy/operator.yaml | \
sed 's|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|' | \
sed 's|quay.io/eclipse/che-operator:nightly|'${OPERATOR_IMAGE}'|' | \
@ -176,13 +128,9 @@ EOL
chectl server:delete --chenamespace=${NAMESPACE} --skip-deletion-check
}
init
source "${OPERATOR_REPO}"/.ci/util/ci_common.sh
source "${OPERATOR_REPO}"/.github/action_scripts/nightly/minikube/function-utilities.sh
echo "[INFO] Start to Building Che Operator Image"
buildCheOperatorImage
echo "[INFO] Start to run single host with gateway exposure mode"
runSHostGatewayExposure
echo "[INFO] Start to run single host in native mode"
echo "[INFO] Start to run single host with native exposure mode"
runSHostNativeExposure

View File

@ -9,12 +9,30 @@
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
name: Testing single host nightly deployment
name: Testing latest changes
on: pull_request
jobs:
minikube-shost:
name: Minikube
minikube-gateway:
name: single-host/gateway
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 single host tests
run: /bin/bash .github/action_scrits/nightly/minikube/single-host-gateway.sh
# Run this step even the previous step fail to upload artifacts to GH
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: minikube-updates-artifacts
path: /tmp/artifacts-che
minikube-native:
name: single-host/native
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1