Merge pull request #321 from flacatus/minishift_updates
Add CI script to support updates testing in minishiftpull/324/head
commit
7cd7be2341
|
|
@ -28,14 +28,6 @@ init() {
|
|||
CHANNEL="nightly"
|
||||
}
|
||||
|
||||
minishift_olm_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/bin --strip-components=1
|
||||
}
|
||||
|
||||
install_Dependencies() {
|
||||
installYQ
|
||||
installJQ
|
||||
|
|
|
|||
|
|
@ -99,6 +99,8 @@ testUpdates() {
|
|||
workspaceList=$(chectl workspace:list)
|
||||
workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b')
|
||||
chectl workspace:start $workspaceID
|
||||
|
||||
waitWorkspaceStart
|
||||
}
|
||||
|
||||
init
|
||||
|
|
|
|||
|
|
@ -0,0 +1,133 @@
|
|||
#!/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
|
||||
|
||||
trap 'Catch_Finish $?' EXIT SIGINT
|
||||
|
||||
# Catch errors and force to delete minishift VM.
|
||||
Catch_Finish() {
|
||||
rm -rf ${OPERATOR_REPO}/tmp ~/.minishift && yes | minishift delete
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
# Create tmp folder and add che operator templates used by server:update command.
|
||||
mkdir -p "$OPERATOR_REPO/tmp" && chmod 777 "$OPERATOR_REPO/tmp"
|
||||
cp -r deploy "$OPERATOR_REPO/tmp/che-operator"
|
||||
}
|
||||
|
||||
installDependencies() {
|
||||
installYQ
|
||||
installJQ
|
||||
install_VirtPackages
|
||||
installStartDocker
|
||||
start_libvirt
|
||||
minishift_installation
|
||||
installChectl
|
||||
load_jenkins_vars
|
||||
}
|
||||
|
||||
installLatestCheStable() {
|
||||
# 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//")
|
||||
|
||||
# Add stable Che images and tag to CR
|
||||
sed -i "s/tlsSupport: true/tlsSupport: false/" ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml
|
||||
sed -i "s/cheImage: ''/cheImage: quay.io\/eclipse\/che-server/" ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml
|
||||
sed -i "s/cheImageTag: ''/cheImageTag: ${previousPackageVersion}/" ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml
|
||||
sed -i "s/devfileRegistryImage: ''/devfileRegistryImage: quay.io\/eclipse\/che-devfile-registry:"${previousPackageVersion}"/" ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml
|
||||
sed -i "s/pluginRegistryImage: ''/pluginRegistryImage: quay.io\/eclipse\/che-plugin-registry:"${previousPackageVersion}"/" ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml
|
||||
sed -i "s/identityProviderImage: ''/identityProviderImage: quay.io\/eclipse\/che-keycloak:"${previousPackageVersion}"/" ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml
|
||||
|
||||
# Start last stable version of che
|
||||
chectl server:start --platform=minishift --che-operator-cr-yaml=${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml \
|
||||
--che-operator-image=quay.io/eclipse/che-operator:${previousPackageVersion} --installer=operator
|
||||
}
|
||||
|
||||
# Utility to wait for new release to be up
|
||||
waitForNewCheVersion() {
|
||||
export n=0
|
||||
|
||||
while [ $n -le 360 ]
|
||||
do
|
||||
cheVersion=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o jsonpath={.status.cheVersion})
|
||||
oc get pods -n ${NAMESPACE}
|
||||
if [ "${cheVersion}" == $lastPackageVersion ]
|
||||
then
|
||||
echo -e "\u001b[32m Installed latest version che-operator: ${lastCSV} \u001b[0m"
|
||||
break
|
||||
fi
|
||||
sleep 6
|
||||
n=$(( n+1 ))
|
||||
done
|
||||
|
||||
if [ $n -gt 360 ]
|
||||
then
|
||||
echo "Latest version install for Eclipse che failed."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
testUpdates() {
|
||||
# Install previous stable version of Eclipse Che
|
||||
installLatestCheStable
|
||||
|
||||
# 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 --skip-version-check --installer=operator --platform=minishift --che-operator-image=quay.io/eclipse/che-operator:${lastPackageVersion} --templates="tmp"
|
||||
|
||||
# Patch images and tag the latest release
|
||||
oc patch checluster eclipse-che --type='json' -p='[{"op": "replace", "path": "/spec/auth/identityProviderImage", "value":"quay.io/eclipse/che-keycloak:'${lastPackageVersion}'"}]'
|
||||
oc patch checluster eclipse-che --type='json' -p='[{"op": "replace", "path": "/spec/server/devfileRegistryImage", "value":"quay.io/eclipse/che-devfile-registry:'${lastPackageVersion}'"}]'
|
||||
oc patch checluster eclipse-che --type='json' -p='[{"op": "replace", "path": "/spec/server/pluginRegistryImage", "value":"quay.io/eclipse/che-plugin-registry:'${lastPackageVersion}'"}]'
|
||||
oc patch checluster eclipse-che --type='json' -p='[{"op": "replace", "path": "/spec/server/cheImageTag", "value":"'${lastPackageVersion}'"}]'
|
||||
|
||||
waitForNewCheVersion
|
||||
|
||||
getCheAcessToken # Function from ./util/ci_common.sh
|
||||
workspaceList=$(chectl workspace:list)
|
||||
workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b')
|
||||
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
|
||||
installDependencies
|
||||
testUpdates
|
||||
|
|
@ -108,13 +108,6 @@ generate_self_signed_certs() {
|
|||
-nodes && cat cert.pem key.pem > ca.crt
|
||||
}
|
||||
|
||||
minikube_installation() {
|
||||
start_libvirt
|
||||
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
|
||||
&& chmod +x minikube
|
||||
sudo install minikube /usr/local/bin/ && rm -rf minikube
|
||||
}
|
||||
|
||||
installEpelRelease() {
|
||||
if yum repolist | grep epel; then
|
||||
printWarn "Epel already installed, skipping instalation."
|
||||
|
|
@ -145,9 +138,41 @@ installChectl() {
|
|||
}
|
||||
|
||||
getCheAcessToken() {
|
||||
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)
|
||||
if [[ ${PLATFORM} == "openshift" ]]
|
||||
then
|
||||
KEYCLOAK_HOSTNAME=$(oc get route -n ${NAMESPACE} keycloak --template={{.spec.host}})
|
||||
TOKEN_ENDPOINT="http://${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
|
||||
}
|
||||
|
||||
waitWorkspaceStart() {
|
||||
export x=0
|
||||
set +e
|
||||
getCheAcessToken
|
||||
while [ $x -le 180 ]
|
||||
do
|
||||
workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE})
|
||||
workspaceStatus=$(echo "$workspaceList" | grep -oP '\bRUNNING.*?\b')
|
||||
|
||||
if [ "${workspaceStatus}" == "RUNNING" ]
|
||||
then
|
||||
printInfo "Workspace started started successfully"
|
||||
break
|
||||
fi
|
||||
sleep 3
|
||||
x=$(( x+1 ))
|
||||
done
|
||||
|
||||
if [ $x -gt 180 ]
|
||||
then
|
||||
echo "Workspace didn't start after 3 minutes."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
getCheClusterLogs() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue