parent
c1db99d060
commit
0aaf04df51
|
|
@ -13,11 +13,6 @@
|
|||
########## More info about how it is configured can be found here: https://docs.ci.openshift.org/docs/how-tos/testing-operator-sdk-operators #############
|
||||
#######################################################################################################################################################
|
||||
|
||||
export XDG_CONFIG_HOME=/tmp/chectl/config
|
||||
export XDG_CACHE_HOME=/tmp/chectl/cache
|
||||
export XDG_DATA_HOME=/tmp/chectl/data
|
||||
|
||||
|
||||
# exit immediately when a command fails
|
||||
set -e
|
||||
# only exit with zero if all commands of the pipeline exit successfully
|
||||
|
|
@ -25,83 +20,27 @@ set -o pipefail
|
|||
# error on unset variables
|
||||
set -u
|
||||
|
||||
export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0")));
|
||||
source "${OPERATOR_REPO}"/.github/bin/common.sh
|
||||
|
||||
#Stop execution on any error
|
||||
trap "catchFinish" EXIT SIGINT
|
||||
|
||||
# Detect the base directory where che-operator is cloned
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
export SCRIPT
|
||||
|
||||
OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")");
|
||||
export OPERATOR_REPO
|
||||
|
||||
# Artifacts dir where job will store all che events and logs
|
||||
ARTIFACTS_DIR="/tmp/artifacts"
|
||||
export ARTIFACTS_DIR
|
||||
|
||||
# Execute olm nightly files in openshift
|
||||
PLATFORM="openshift"
|
||||
export PLATFORM
|
||||
|
||||
# Test nightly olm files
|
||||
NAMESPACE="eclipse-che"
|
||||
export NAMESPACE
|
||||
|
||||
# CI_CHE_OPERATOR_IMAGE it is che operator image builded in openshift CI job workflow. More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates
|
||||
export OPERATOR_IMAGE=${CI_CHE_OPERATOR_IMAGE:-"quay.io/eclipse/che-operator:nightly"}
|
||||
|
||||
# Get nightly CSV
|
||||
export CSV_FILE
|
||||
CSV_FILE="${OPERATOR_REPO}/deploy/olm-catalog/eclipse-che-preview-${PLATFORM}/manifests/che-operator.clusterserviceversion.yaml"
|
||||
|
||||
# Define Che exposure strategy
|
||||
CHE_EXPOSURE_STRATEGY="multiuser"
|
||||
export CHE_EXPOSURE_STRATEGY
|
||||
|
||||
# Import common functions utilities
|
||||
source "${OPERATOR_REPO}"/.github/bin/common.sh
|
||||
|
||||
# Patch che operator image with image builded from source in Openshift CI job.
|
||||
function patchCheOperatorImage() {
|
||||
echo -e "[INFO] Getting che operator pod name..."
|
||||
OPERATOR_POD=$(oc get pods -o json -n ${NAMESPACE} | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name')
|
||||
oc patch pod ${OPERATOR_POD} -n ${NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":'${OPERATOR_IMAGE}'}]'
|
||||
|
||||
# The following command retrieve the operator image
|
||||
OPERATOR_POD_IMAGE=$(oc get pods -n ${NAMESPACE} -o json | jq -r '.items[] | select(.metadata.name | test("che-operator-")).spec.containers[].image')
|
||||
echo -e "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}"
|
||||
overrideDefaults() {
|
||||
# CI_CHE_OPERATOR_IMAGE it is che operator image builded in openshift CI job workflow. More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates
|
||||
export OPERATOR_IMAGE=${CI_CHE_OPERATOR_IMAGE:-"quay.io/eclipse/che-operator:nightly"}
|
||||
}
|
||||
|
||||
# Create CheCluster object in Openshift ci with desired values
|
||||
function applyCRCheCluster() {
|
||||
echo "Creating Custom Resource"
|
||||
CRs=$(yq -r '.metadata.annotations["alm-examples"]' "${CSV_FILE}")
|
||||
CR=$(echo "$CRs" | yq -r ".[0]")
|
||||
if [ "${PLATFORM}" == "openshift" ] && [ "${OAUTH}" == "false" ]; then
|
||||
CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = false")
|
||||
fi
|
||||
if [ "${CHE_EXPOSURE_STRATEGY}" == "single-host" ]
|
||||
then
|
||||
CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY}\"")
|
||||
fi
|
||||
echo -e "$CR"
|
||||
echo "$CR" | oc apply -n "${NAMESPACE}" -f -
|
||||
}
|
||||
|
||||
# Run che deployment after patch operator image.
|
||||
function deployEclipseChe() {
|
||||
export OAUTH="false"
|
||||
|
||||
runTests() {
|
||||
# Deploy Eclipse Che applying CR
|
||||
applyCRCheCluster
|
||||
waitEclipseCheDeployed
|
||||
|
||||
applyOlmCR
|
||||
waitEclipseCheDeployed "nightly"
|
||||
startNewWorkspace
|
||||
|
||||
chectl workspace:list --chenamespace=${NAMESPACE}
|
||||
waitWorkspaceStart
|
||||
}
|
||||
|
||||
init
|
||||
overrideDefaults
|
||||
patchCheOperEclipseCheOperatorSubscription
|
||||
printOlmCheObjects
|
||||
patchCheOperatorImage
|
||||
deployEclipseChe
|
||||
runTests
|
||||
|
|
|
|||
|
|
@ -36,10 +36,15 @@ init() {
|
|||
export TEMPLATES=${OPERATOR_REPO}/tmp
|
||||
export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test"
|
||||
|
||||
export CHE_EXPOSURE_STRATEGY="multi-host"
|
||||
export OAUTH="false"
|
||||
|
||||
export XDG_DATA_HOME=/tmp/chectl/data
|
||||
export XDG_CACHE_HOME=/tmp/chectl/cache
|
||||
export XDG_CONFIG_HOME=/tmp/chectl/config
|
||||
|
||||
export OPENSHIFT_NIGHTLY_CSV_FILE="${OPERATOR_REPO}/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml"
|
||||
|
||||
# prepare templates directory
|
||||
rm -rf ${TEMPLATES}
|
||||
mkdir -p "${TEMPLATES}/che-operator" && chmod 777 "${TEMPLATES}"
|
||||
|
|
@ -269,7 +274,7 @@ insecurePrivateDockerRegistry() {
|
|||
}
|
||||
|
||||
# Utility to print objects created by Openshift CI automatically
|
||||
function printOlmCheObjects() {
|
||||
printOlmCheObjects() {
|
||||
echo -e "[INFO] Operator Group object created in namespace: ${NAMESPACE}"
|
||||
oc get operatorgroup -n "${NAMESPACE}" -o yaml
|
||||
|
||||
|
|
@ -279,3 +284,26 @@ function printOlmCheObjects() {
|
|||
echo -e "[INFO] Subscription object created in namespace: ${NAMESPACE}"
|
||||
oc get subscription -n "${NAMESPACE}" -o yaml
|
||||
}
|
||||
|
||||
# Patch subscription with image builded from source in Openshift CI job.
|
||||
patchEclipseCheOperatorSubscription() {
|
||||
OPERATOR_POD=$(oc get pods -o json -n ${NAMESPACE} | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name')
|
||||
oc patch pod ${OPERATOR_POD} -n ${NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":'${OPERATOR_IMAGE}'}]'
|
||||
|
||||
# The following command retrieve the operator image
|
||||
OPERATOR_POD_IMAGE=$(oc get pods -n ${NAMESPACE} -o json | jq -r '.items[] | select(.metadata.name | test("che-operator-")).spec.containers[].image')
|
||||
echo -e "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}"
|
||||
}
|
||||
|
||||
# Create CheCluster object in Openshift ci with desired values
|
||||
applyOlmCR() {
|
||||
echo "Creating Custom Resource"
|
||||
|
||||
CRs=$(yq -r '.metadata.annotations["alm-examples"]' "${OPENSHIFT_NIGHTLY_CSV_FILE}")
|
||||
CR=$(echo "$CRs" | yq -r ".[0]")
|
||||
CR=$(echo "$CR" | yq -r ".spec.auth.openShiftoAuth = \"${OAUTH}\"")
|
||||
CR=$(echo "$CR" | yq -r ".spec.server.serverExposureStrategy = \"${CHE_EXPOSURE_STRATEGY}\"")
|
||||
|
||||
echo -e "$CR"
|
||||
echo "$CR" | oc apply -n "${NAMESPACE}" -f -
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue