Merge and add s-host tests modifications

Signed-off-by: Flavius Lacatusu <flacatus@redhat.com>
pull/564/head
Flavius Lacatusu 2020-12-09 08:41:37 +01:00
commit edb9648fea
No known key found for this signature in database
GPG Key ID: AB9AB3E390E38ABD
49 changed files with 922 additions and 1403 deletions

View File

@ -1,119 +0,0 @@
#!/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
#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"
getOCCheClusterLogs
exit 1
fi
echo "[INFO] Job finished Successfully.Please check the artifacts in github actions"
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"
# Set operator root directory
if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then
OPERATOR_REPO=${WORKSPACE};
else
OPERATOR_REPO=$(dirname "$SCRIPT_DIR");
fi
}
installYq() {
YQ=$(command -v yq) || true
if [[ ! -x "${YQ}" ]]; then
pip3 install wheel
pip3 install yq
fi
echo "[INFO] $(yq --version)"
echo "[INFO] $(jq --version)"
}
# 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() {
# OPERATOR_IMAGE In CI is defined in .github/workflows/che-nightly.yaml
export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test"
rm -rf tmp
# prepare template folder
mkdir -p "${OPERATOR_REPO}/tmp/che-operator" && chmod 777 "${OPERATOR_REPO}/tmp"
cp -rf ${OPERATOR_REPO}/deploy/* "${OPERATOR_REPO}/tmp/che-operator"
# prepare CR
sed -i'.bak' -e "s|openShiftoAuth: .*|openShiftoAuth: false|" "${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml"
yq -riSY '.spec.auth.updateAdminPassword = false' "${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml"
# update operator yaml
sed -i'.bak' -e "s|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|" "${OPERATOR_REPO}/tmp/che-operator/operator.yaml"
sed -i'.bak' -e "s|quay.io/eclipse/che-operator:nightly|'${OPERATOR_IMAGE}'|" "${OPERATOR_REPO}/tmp/che-operator/operator.yaml"
cat ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml
cat ${OPERATOR_REPO}/tmp/che-operator/operator.yaml
# Deploy Eclipse Che
chectl server:deploy --platform=minishift \
--installer operator \
--chenamespace ${NAMESPACE} \
--che-operator-image ${OPERATOR_IMAGE} \
--che-operator-cr-yaml ${OPERATOR_REPO}/tmp/che-operator/crds/org_v1_che_cr.yaml \
--templates ${OPERATOR_REPO}/tmp
# Create and start a workspace
chectl auth:login -u admin -p admin
chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
# Wait for workspace to be up
waitWorkspaceStart # Function from ./util/ci_common.sh
oc get events -n ${NAMESPACE}
}
init
installYq
source "${OPERATOR_REPO}"/.ci/util/ci_common.sh
run

View File

@ -1,99 +0,0 @@
#!/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
#
set -ex
# Detect the base directory where che-operator is cloned
SCRIPT=$(readlink -f "$0")
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
# Choose if install Eclipse Che using an operatorsource or Custom Catalog Source
INSTALLATION_TYPE="catalog"
export INSTALLATION_TYPE
# Execute olm nightly files in openshift
PLATFORM="kubernetes"
export PLATFORM
# Test nightly olm files
CHANNEL="nightly"
export CHANNEL
# Test nightly olm files
NAMESPACE="che"
export NAMESPACE
# Operator image
OPERATOR_IMAGE="quay.io/eclipse/che-operator:nightly"
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}
# Create and start a workspace
getCheAcessToken
chectl workspace:create --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
getCheAcessToken
workspaceList=$(chectl workspace:list)
workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b')
chectl workspace:start $workspaceID
waitWorkspaceStart
}
function setPrivateRegistryForDocker {
dockerDaemonConfig="/etc/docker/daemon.json"
sudo mkdir -p "/etc/docker"
sudo touch "${dockerDaemonConfig}"
config="{\"insecure-registries\" : [\"${IMAGE_REGISTRY_HOST}\"]}"
echo "${config}" | sudo tee "${dockerDaemonConfig}"
if [ -x "$(command -v docker)" ]; then
echo "[INFO] Restart docker daemon to set up private registry info."
sudo service docker restart
fi
}
setPrivateRegistryForDocker
run

View File

@ -1,125 +0,0 @@
#!/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
#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 NAMESPACE="che"
export PLATFORM="openshift"
export ARTIFACTS_DIR="/tmp/artifacts/artifacts-che"
# Set operator root directory
if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then
export OPERATOR_REPO=${WORKSPgetOCCheClusterLogsACE};
else
export OPERATOR_REPO=$(dirname "$SCRIPT_DIR");
fi
# CHE_OPERATOR_IMAGE is exposed in openshift ci pod. This image is build in every job and used then to deploy Che
# More info about how images are builded in Openshift CI: https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates
export OPERATOR_IMAGE=${CHE_OPERATOR_IMAGE}
echo "[INFO] Che Operator Image used is: ${CHE_OPERATOR_IMAGE}"
}
# Catch_Finish is executed after finish script.
catchFinish() {
result=$?
if [ "$result" != "0" ]; then
echo "[ERROR] Please check the openshift ci artifacts"
collectCheLogWithChectl
exit 1
fi
echo "[INFO] Job finished Successfully.Please check openshift ci artifacts"
collectCheLogWithChectl
exit $result
}
# Utility to get che events and pod logs from openshift cluster
function collectCheLogWithChectl() {
mkdir -p /tmp/artifacts/artifacts-che
chectl server:logs --directory=${ARTIFACTS_DIR}
}
# Get Token from single host mode deployment
function getSingleHostToken() {
export KEYCLOAK_HOSTNAME=$(oc get routes/che -n ${NAMESPACE} -o jsonpath='{.spec.host}')
export 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)
}
# Utility to wait for a workspace to be started after workspace:create.
function waitSingleHostWorkspaceStart() {
set +e
export x=0
while [ $x -le 180 ]
do
getSingleHostToken
# List Workspaces and get the status
chectl workspace:list
workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE})
workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ')
if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ]
then
echo "[INFO] Workspace started successfully"
break
fi
sleep 10
x=$(( x+1 ))
done
if [ $x -gt 180 ]
then
echo "[ERROR] Workspace didn't start after 3 minutes."
exit 1
fi
}
# Deploy Eclipse Che in single host mode
function run() {
# Patch file to pass to chectl
cat >/tmp/che-cr-patch.yaml <<EOL
spec:
server:
serverExposureStrategy: 'single-host'
auth:
updateAdminPassword: false
openShiftoAuth: false
EOL
echo "======= Che cr patch ======="
cat /tmp/che-cr-patch.yaml
# Start to deploy Che
chectl server:deploy --platform=openshift --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
getSingleHostToken
chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
# Wait for workspace to be up
waitSingleHostWorkspaceStart
}
init
source "${OPERATOR_REPO}"/.ci/util/ci_common.sh
run

View File

@ -1,102 +0,0 @@
#!/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
#Stop execution on any error
trap "catchFinish" EXIT SIGINT
# Catch_Finish is executed after finish script.
function 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() {
SCRIPT=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT")
if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then
OPERATOR_REPO=${WORKSPACE};
else
OPERATOR_REPO=$(dirname "$SCRIPT_DIR");
fi
RAM_MEMORY=8192
PLATFORM="kubernetes"
NAMESPACE="che"
CHANNEL="stable"
}
function 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 "[ERROR] Latest version install for Eclipse che failed."
exit 1
fi
}
function testUpdates() {
"${OPERATOR_REPO}"/olm/testUpdate.sh ${PLATFORM} ${CHANNEL} ${NAMESPACE}
echo "[INFO] Successfully installed Eclipse Che previous version."
getCheAcessToken
chectl workspace:create --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
waitCheUpdateInstall
getCheAcessToken
workspaceList=$(chectl workspace:list)
workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b')
echo "[INFO] Workspace id of created workspace is: ${workspaceID}"
chectl workspace:start $workspaceID
waitWorkspaceStart
}
init
source "${OPERATOR_REPO}"/.ci/util/ci_common.sh
testUpdates

View File

@ -1,174 +0,0 @@
#!/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 -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"
getOCCheClusterLogs
exit 1
fi
echo "[INFO] Job finished Successfully.Please check the artifacts in github actions"
getOCCheClusterLogs
exit $result
}
function 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
# 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//")
export lastOperatorPath=${OPERATOR_REPO}/tmp/${lastPackageVersion}
export previousOperatorPath=${OPERATOR_REPO}/tmp/${previousPackageVersion}
export lastOperatorTemplate=${lastOperatorPath}/chectl/templates
export previousOperatorTemplate=${previousOperatorPath}/chectl/templates
rm -rf tmp
# Create tmp folder to save "operator" installer templates
mkdir -p "${OPERATOR_REPO}/tmp" && chmod 777 "${OPERATOR_REPO}/tmp"
# clone the exact versions to use their templates
git clone --depth 1 --branch ${previousPackageVersion} https://github.com/eclipse/che-operator/ ${previousOperatorPath}
git clone --depth 1 --branch ${lastPackageVersion} https://github.com/eclipse/che-operator/ ${lastOperatorPath}
# chectl requires 'che-operator' template folder
mkdir -p "${lastOperatorTemplate}/che-operator"
mkdir -p "${previousOperatorTemplate}/che-operator"
cp -rf ${previousOperatorPath}/deploy/* "${previousOperatorTemplate}/che-operator"
cp -rf ${lastOperatorPath}/deploy/* "${lastOperatorTemplate}/che-operator"
# set 'openShiftoAuth: false'
sed -i'.bak' -e "s/openShiftoAuth: .*/openShiftoAuth: false/" "${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml"
sed -i'.bak' -e "s/openShiftoAuth: .*/openShiftoAuth: false/" "${lastOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml"
}
function installPreviousStableChe() {
cat "${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml"
# Start last stable version of che
chectl server:deploy --platform=minishift \
--che-operator-image=quay.io/eclipse/che-operator:${previousPackageVersion} \
--che-operator-cr-yaml="${previousOperatorTemplate}/che-operator/crds/org_v1_che_cr.yaml" \
--templates="${previousOperatorTemplate}" \
--installer=operator
}
function waitForNewCheVersion() {
export n=0
while [ $n -le 500 ]
do
cheVersion=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheVersion}")
cheIsRunning=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheClusterRunning}" )
oc get pods -n ${NAMESPACE}
if [ "${cheVersion}" == "${lastPackageVersion}" ] && [ "${cheIsRunning}" == "Available" ]
then
echo -e "\u001b[32m The latest Eclipse Che ${lastCSV} has been deployed \u001b[0m"
break
fi
sleep 6
n=$(( n+1 ))
done
if [ $n -gt 360 ]
then
echo "Failed to deploy the latest ${lastCSV} Eclipse Che."
exit 1
fi
}
# Utility to get che events and pod logs from openshift
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
}
function minishiftUpdates() {
# Install previous stable version of Eclipse Che
installPreviousStableChe
# 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 -y \
--che-operator-image=quay.io/eclipse/che-operator:${lastPackageVersion} \
--templates="${lastOperatorTemplate}"
waitForNewCheVersion
# Sleep before starting a workspace
sleep 10s
chectl auth:login -u admin -p admin
chectl workspace:list
workspaceList=$(chectl workspace:list)
# Grep applied to MacOS
workspaceID=$(echo "$workspaceList" | grep workspace | awk '{ print $1} ')
workspaceID="${workspaceID%'ID'}"
echo "[INFO] Workspace id of created workspace is: ${workspaceID}"
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
minishiftUpdates

View File

@ -10,80 +10,19 @@
# Contributors:
# Red Hat, Inc. - initial API and implementation
set -ex
set -e
set -x
init() {
export SCRIPT=$(readlink -f "$0")
export SCRIPT_DIR=$(dirname "$SCRIPT")
if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then
export OPERATOR_REPO=${WORKSPACE};
else
export OPERATOR_REPO=$(dirname "$SCRIPT_DIR");
fi
export PLATFORM="openshift"
export NAMESPACE="che"
export CHANNEL="stable"
}
# 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}"
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 "[ERROR] Latest version install for Eclipse Che failed."
exit 1
fi
}
function openshiftUpdates() {
"${OPERATOR_REPO}"/olm/testUpdate.sh ${PLATFORM} ${CHANNEL} ${NAMESPACE}
getCheAcessToken
chectl workspace:create --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
waitCheUpdateInstall
getCheAcessToken
local cheVersion=$(kubectl get checluster/eclipse-che -n "${NAMESPACE}" -o jsonpath={.status.cheVersion})
echo "[INFO] Successfully installed Eclipse Che: ${cheVersion}"
sleep 120
getCheAcessToken
workspaceList=$(chectl workspace:list)
workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b')
chectl workspace:start $workspaceID
chectl workspace:list
export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0")));
source "${OPERATOR_REPO}"/.github/bin/common.sh
runTests() {
"${OPERATOR_REPO}"/olm/testUpdate.sh "openshift" "stable" ${NAMESPACE}
waitEclipseCheDeployed ${LAST_PACKAGE_VERSION}
startNewWorkspace
waitWorkspaceStart
echo "[INFO] Successfully started an workspace on Eclipse Che: ${cheVersion}"
}
init
source "${OPERATOR_REPO}"/.ci/util/ci_common.sh
openshiftUpdates
initStableTemplates "openshift" "stable"
runTests

View File

@ -1,3 +1,4 @@
#!/bin/bash
#
# Copyright (c) 2012-2020 Red Hat, Inc.
# This program and the accompanying materials are made
@ -11,66 +12,19 @@
set -e
# Get the access token from keycloak in openshift platforms and kubernetes
function getCheAcessToken() {
if [[ ${PLATFORM} == "openshift" ]]
then
export CHE_API_ENDPOINT=$(oc get route -n ${NAMESPACE} che --template={{.spec.host}})/api
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
export CHE_API_ENDPOINT=che-che.$(minikube ip).nip.io/api
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
}
# 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 --chenamespace=${NAMESPACE}
workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE})
workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ')
echo -e ""
if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ]
then
echo "[INFO] Workspace started successfully"
break
fi
sleep 10
x=$(( x+1 ))
done
if [ $x -gt 180 ]
then
echo "[ERROR] Workspace didn't start after 3 minutes."
exit 1
fi
}
# Create cheCluster object in Openshift ci with desired values
# 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}" == "kubernetes" ]
then
CR=$(echo "$CR" | yq -r ".spec.k8s.ingressDomain = \"$(minikube ip).nip.io\"")
fi
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 -
}
@ -101,20 +55,38 @@ function waitCheServerDeploy() {
fi
}
# Utility to get all logs from che
function getCheClusterLogs() {
mkdir -p /tmp/artifacts-che
cd /tmp/artifacts-che
# Utility to wait for a workspace to be started after workspace:create.
function waitWorkspaceStart() {
set +e
chectl auth:login --chenamespace=${NAMESPACE} -u admin -p admin
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 ""
echo "[INFO] Getting logs from $POD"
echo ""
kubectl logs ${POD} -c ${CONTAINER} -n ${NAMESPACE} |tee $(echo ${POD}-${CONTAINER}.log | sed 's|pod/||g')
done
export x=0
while [ $x -le 180 ]
do
chectl workspace:list --chenamespace=${NAMESPACE}
workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE})
workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ')
echo -e ""
if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ]
then
echo "[INFO] Workspace started successfully"
break
fi
sleep 10
x=$(( x+1 ))
done
echo "[INFO] Get events"
kubectl get events -n ${NAMESPACE}| tee get_events.log
kubectl get all | tee get_all.log
if [ $x -gt 180 ]
then
echo -e "[ERROR] Workspace didn't start after 3 minutes."
exit 1
fi
}
function startNewWorkspace() {
# Create and start a workspace
sleep 5s
chectl auth:login -u admin -p admin --chenamespace=${NAMESPACE}
chectl workspace:create --chenamespace=${NAMESPACE} --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
}

15
.ci/devfile-test.yaml Normal file
View File

@ -0,0 +1,15 @@
#!/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
metadata:
name: e2e-tests
apiVersion: 1.0.0

View File

@ -9,7 +9,7 @@
#
################################ !!! IMPORTANT !!! ################################
########### THIS JOB use Openshift CI operators workflows to run nightly olm tests ####
########### THIS JOB USE openshift ci operators workflows to run #####################
########## More info about how it is configured can be found here: https://docs.ci.openshift.org/docs/how-tos/testing-operator-sdk-operators #############
#######################################################################################################################################################
@ -53,8 +53,12 @@ export OPERATOR_IMAGE=${CI_CHE_OPERATOR_IMAGE:-"quay.io/eclipse/che-operator:nig
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}"/.ci/util/ci_common.sh
source "${OPERATOR_REPO}"/.ci/common.sh
# catchFinish is executed after finish script.
function catchFinish() {
@ -75,25 +79,25 @@ function catchFinish() {
# Utility to print objects created by Openshift CI automatically
function printOlmCheObjects() {
echo -e "[INFO] Operator Group object created in namespace ${NAMESPACE}:"
echo -e "[INFO] Operator Group object created in namespace: ${NAMESPACE}"
oc get operatorgroup -n "${NAMESPACE}" -o yaml
echo -e "[INFO] Catalog Source object created in namespace ${NAMESPACE}:"
echo -e "[INFO] Catalog Source object created in namespace: ${NAMESPACE}"
oc get catalogsource -n "${NAMESPACE}" -o yaml
echo -e "[INFO] Subscription object created in namespace ${NAMESPACE}"
echo -e "[INFO] Subscription object created in namespace: ${NAMESPACE}"
oc get subscription -n "${NAMESPACE}" -o yaml
}
# Patch che operator image with image builded from source in Openshift CI job.
function patchCheOperatorImage() {
echo "[INFO] Getting che operator pod name..."
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 "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}"
echo -e "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}"
}
# Run che deployment after patch operator image.
@ -104,12 +108,8 @@ function deployEclipseChe() {
applyCRCheCluster
waitCheServerDeploy
# Create a workspace
getCheAcessToken
chectl workspace:create --start --chenamespace=${NAMESPACE} --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
startNewWorkspace
# Start a workspace and wait until workspace it is alive
getCheAcessToken
chectl workspace:list --chenamespace=${NAMESPACE}
waitWorkspaceStart
}

119
.ci/oci-single-host.sh Executable file
View File

@ -0,0 +1,119 @@
#!/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
#
################################ !!! IMPORTANT !!! ################################
########### THIS JOB USE openshift ci operators workflows to run #####################
########## 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
set -o pipefail
# error on unset variables
set -u
#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
CSV_FILE="${OPERATOR_REPO}/deploy/olm-catalog/eclipse-che-preview-${PLATFORM}/manifests/che-operator.clusterserviceversion.yaml"
export CSV_FILE
# Define Che exposure strategy
CHE_EXPOSURE_STRATEGY="single-host"
export CHE_EXPOSURE_STRATEGY
# Import common functions utilities
source "${OPERATOR_REPO}"/.ci/common.sh
# catchFinish is executed after finish script.
function catchFinish() {
result=$?
mkdir -p ${ARTIFACTS_DIR}/che-logs
if [ "$result" != "0" ]; then
echo "[ERROR] Please check openshift ci artifacts"
chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACTS_DIR}/che-logs
exit 1
fi
echo "[INFO] Job finished Successfully. Please check the artifacts in openshift ci artifacts"
chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACTS_DIR}/che-logs
exit $result
}
# Utility to print objects created by Openshift CI automatically
function printOlmCheObjects() {
echo -e "[INFO] Operator Group object created in namespace ${NAMESPACE}:"
oc get operatorgroup -n "${NAMESPACE}" -o yaml
echo -e "[INFO] Catalog Source object created in namespace ${NAMESPACE}:"
oc get catalogsource -n "${NAMESPACE}" -o yaml
echo -e "[INFO] Subscription object created in namespace ${NAMESPACE}"
oc get subscription -n "${NAMESPACE}" -o yaml
}
# Patch che operator image with image builded from source in Openshift CI job.
function patchCheOperatorImage() {
echo "[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 "[INFO] CHE operator image is ${OPERATOR_POD_IMAGE}"
}
# Run che deployment after patch operator image.
function deployEclipseChe() {
export OAUTH="false"
# Deploy Eclipse Che applying CR
applyCRCheCluster
waitCheServerDeploy
startNewWorkspace
chectl workspace:list --chenamespace=${NAMESPACE}
waitWorkspaceStart
}
printOlmCheObjects
patchCheOperatorImage
deployEclipseChe

View File

@ -1,3 +1,15 @@
#!/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
**/*.diff
**/*.sh
**/*Dockerfile

View File

@ -1,3 +1,14 @@
#!/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
# Dockerfile to bootstrap build and test in openshift-ci

View File

@ -1,15 +0,0 @@
FROM quay.io/operator-framework/upstream-registry-builder as builder
# Docker build in ci needs the complete route of the che operator repo dir...
COPY olm/eclipse-che-preview-openshift/deploy manifests/eclipse-che-preview-openshift
RUN ./bin/initializer --permissive -o ./bundles.db
FROM openshift/origin-base
COPY --from=builder /build/bin/initializer /initializer
COPY --from=builder /build/bin/configmap-server /bin/configmap-server
COPY --from=builder /build/bundles.db /bundles.db
COPY --from=builder /build/bin/registry-server /registry-server
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe
EXPOSE 50051
ENTRYPOINT ["/registry-server"]
CMD ["--database", "bundles.db"]

View File

@ -1,3 +0,0 @@
metadata:
name: e2e-tests
apiVersion: 1.0.0

View File

@ -1,78 +0,0 @@
#!/usr/bin/env 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
# exit immediately when a command fails
set -e
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
# error on unset variables
set -u
# print each command before executing it
set -x
# 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
}
# Get Token from single host mode deployment
function getSingleHostToken() {
export GATEWAY_HOSTNAME=$(minikube ip).nip.io
export CHE_API_ENDPOINT="https://${GATEWAY_HOSTNAME}/api"
export TOKEN_ENDPOINT="https://${GATEWAY_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)
}
# Utility to wait for a workspace to be started after workspace:create.
function waitSingleHostWorkspaceStart() {
set +e
export x=0
while [ $x -le 180 ]
do
getSingleHostToken
# 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} ')
if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ]
then
echo "[INFO] Workspace started successfully"
break
fi
sleep 10
x=$(( x+1 ))
done
if [ $x -gt 180 ]
then
echo "[ERROR] Workspace didn't start after 3 minutes."
exit 1
fi
}
# 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=$(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

@ -1,99 +0,0 @@
#!/usr/bin/env 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
# exit immediately when a command fails
set -e
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
# error on unset variables
set -u
# print each command before executing it
set -x
# Stop execution on any error
trap "catchFinish" EXIT SIGINT
# Define global environments
export OPERATOR_REPO="${GITHUB_WORKSPACE}"
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"
# Set operator root directory
export OPERATOR_IMAGE="che-operator:pr-check"
# Catch_Finish is executed after finish script.
catchFinish() {
result=$?
if [ "$result" != "0" ]; then
echo "[ERROR] Please check the github actions artifacts"
collectCheLogWithChectl
exit 1
fi
echo "[INFO] Job finished Successfully.Please check github actions artifacts"
collectCheLogWithChectl
exit $result
}
# Utility to get che events and pod logs from openshift cluster
function collectCheLogWithChectl() {
mkdir -p ${ARTIFACTS_DIR}
chectl server:logs --directory=${ARTIFACTS_DIR}
}
# 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
kubectl 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:deploy --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
# Wait for workspace to be up for native deployment from ${PROJECT_DIR}/.github/action_scripts/minikube/function-utilities.sh
getSingleHostToken
chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
# Wait for workspace to be up
waitSingleHostWorkspaceStart
}
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

View File

@ -1,97 +0,0 @@
#!/usr/bin/env 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
# exit immediately when a command fails
set -e
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
# error on unset variables
set -u
# print each command before executing it
set -x
# Stop execution on any error
trap "catchFinish" EXIT SIGINT
# Define global environments
export OPERATOR_REPO="${GITHUB_WORKSPACE}"
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"
# Set operator root directory
export OPERATOR_IMAGE="che-operator:pr-check"
# Catch_Finish is executed after finish script.
catchFinish() {
result=$?
if [ "$result" != "0" ]; then
echo "[ERROR] Please check the github actions artifacts"
collectCheLogWithChectl
exit 1
fi
echo "[INFO] Job finished Successfully.Please check github actions artifacts"
collectCheLogWithChectl
exit $result
}
# Utility to get che events and pod logs from openshift cluster
function collectCheLogWithChectl() {
mkdir -p ${ARTIFACTS_DIR}
chectl server:logs --directory=${ARTIFACTS_DIR}
}
# Deploy Eclipse Che in single host mode(native exposure type)
function runSHostNativeExposure() {
# Patch file to pass to chectl
cat >/tmp/che-cr-patch.yaml <<EOL
spec:
server:
serverExposureStrategy: 'single-host'
auth:
updateAdminPassword: false
openShiftoAuth: false
EOL
echo "======= Che cr patch ======="
cat /tmp/che-cr-patch.yaml
# Use custom changes, don't pull image from quay.io
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}'|' | \
oc apply -n ${NAMESPACE} -f -
# Start to deploy Che
chectl server:deploy --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
# Get the token from utility in ${PROJECT_DIR}/.github/action_scripts/minikube/function-utilities.sh
getSingleHostToken
chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
# Wait for workspace to be up for native deployment from ${PROJECT_DIR}/.github/action_scripts/minikube/function-utilities.sh
waitSingleHostWorkspaceStart
}
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 native single host mode"
runSHostNativeExposure

269
.github/bin/common.sh vendored Executable file
View File

@ -0,0 +1,269 @@
#!/usr/bin/env 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 -e
set -x
catchFinish() {
result=$?
collectCheLogWithChectl
if [ "$result" != "0" ]; then
echo "[ERROR] Job failed."
else
echo "[INFO] Job completed successfully."
fi
echo "[INFO] Please check github actions artifacts."
exit $result
}
init() {
export SCRIPT=$(readlink -f "$0")
export SCRIPT_DIR=$(dirname "$SCRIPT")
export RAM_MEMORY=8192
export NAMESPACE="che"
export ARTIFACTS_DIR="/tmp/artifacts-che"
export TEMPLATES=${OPERATOR_REPO}/tmp
export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test"
export XDG_DATA_HOME=/tmp/chectl/data
export XDG_CACHE_HOME=/tmp/chectl/cache
export XDG_CONFIG_HOME=/tmp/chectl/config
# prepare templates directory
rm -rf ${TEMPLATES}
mkdir -p "${TEMPLATES}/che-operator" && chmod 777 "${TEMPLATES}"
}
initLatestTemplates() {
cp -rf ${OPERATOR_REPO}/deploy/* "${TEMPLATES}/che-operator"
}
initStableTemplates() {
local platform=$1
local channel=$2
# 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 LAST_PACKAGE_VERSION=$(echo "${lastCSV}" | sed -e "s/${packageName}.v//")
export previousCSV=$(sed -n 's|^ *replaces: *\([^ ]*\) *|\1|p' "${packageFolderPath}/${LAST_PACKAGE_VERSION}/${packageName}.v${LAST_PACKAGE_VERSION}.clusterserviceversion.yaml")
export PREVIOUS_PACKAGE_VERSION=$(echo "${previousCSV}" | sed -e "s/${packageName}.v//")
export lastOperatorPath=${OPERATOR_REPO}/tmp/${LAST_PACKAGE_VERSION}
export previousOperatorPath=${OPERATOR_REPO}/tmp/${PREVIOUS_PACKAGE_VERSION}
export LAST_OPERATOR_TEMPLATE=${lastOperatorPath}/chectl/templates
export PREVIOUS_OPERATOR_TEMPLATE=${previousOperatorPath}/chectl/templates
# clone the exact versions to use their templates
git clone --depth 1 --branch ${PREVIOUS_PACKAGE_VERSION} https://github.com/eclipse/che-operator/ ${previousOperatorPath}
git clone --depth 1 --branch ${LAST_PACKAGE_VERSION} https://github.com/eclipse/che-operator/ ${lastOperatorPath}
# chectl requires 'che-operator' template folder
mkdir -p "${LAST_OPERATOR_TEMPLATE}/che-operator"
mkdir -p "${PREVIOUS_OPERATOR_TEMPLATE}/che-operator"
cp -rf ${previousOperatorPath}/deploy/* "${PREVIOUS_OPERATOR_TEMPLATE}/che-operator"
cp -rf ${lastOperatorPath}/deploy/* "${LAST_OPERATOR_TEMPLATE}/che-operator"
}
# Utility to wait for a workspace to be started after workspace:create.
waitWorkspaceStart() {
set +e
export x=0
while [ $x -le 180 ]
do
chectl auth:login -u admin -p admin
chectl workspace:list
workspaceList=$(chectl workspace:list --chenamespace=${NAMESPACE})
workspaceStatus=$(echo "$workspaceList" | grep RUNNING | awk '{ print $4} ')
if [ "${workspaceStatus:-NOT_RUNNING}" == "RUNNING" ]
then
echo "[INFO] Workspace started successfully"
break
fi
sleep 10
x=$(( x+1 ))
done
if [ $x -gt 180 ]
then
echo "[ERROR] Workspace didn't start after 3 minutes."
exit 1
fi
}
installYq() {
YQ=$(command -v yq) || true
if [[ ! -x "${YQ}" ]]; then
pip3 install wheel
pip3 install yq
fi
echo "[INFO] $(yq --version)"
echo "[INFO] $(jq --version)"
}
# Graps Eclipse Che logs
collectCheLogWithChectl() {
mkdir -p ${ARTIFACTS_DIR}
chectl server:logs --directory=${ARTIFACTS_DIR}
}
# Build latest operator image
buildCheOperatorImage() {
docker build -t "${OPERATOR_IMAGE}" -f Dockerfile . && docker save "${OPERATOR_IMAGE}" > operator.tar
}
copyCheOperatorImageToMinikube() {
eval $(minikube docker-env) && docker load -i operator.tar && rm operator.tar
}
copyCheOperatorImageToMinishift() {
eval $(minishift docker-env) && docker load -i operator.tar && rm operator.tar
}
deployEclipseChe() {
local installer=$1
local platform=$2
local image=$3
local templates=$4
echo "[INFO] Eclipse Che custom resource"
cat ${templates}/che-operator/crds/org_v1_che_cr.yaml
echo "[INFO] Eclipse Che operator deployment"
cat ${templates}/che-operator/operator.yaml
chectl server:deploy \
--platform=${platform} \
--installer ${installer} \
--chenamespace ${NAMESPACE} \
--che-operator-image ${image} \
--skip-kubernetes-health-check \
--che-operator-cr-yaml ${templates}/che-operator/crds/org_v1_che_cr.yaml \
--templates ${templates}
}
waitEclipseCheDeployed() {
local version=$1
export n=0
while [ $n -le 500 ]
do
cheVersion=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheVersion}")
cheIsRunning=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheClusterRunning}" )
oc get pods -n ${NAMESPACE}
if [ "${cheVersion}" == "${version}" ] && [ "${cheIsRunning}" == "Available" ]
then
echo -e "\u001b[32m Eclipse Che ${version} has been succesfully deployed \u001b[0m"
break
fi
sleep 6
n=$(( n+1 ))
done
if [ $n -gt 360 ]
then
echo "Failed to deploy Eclipse Che ${version}"
exit 1
fi
}
updateEclipseChe() {
local image=$1
local templates=$2
chectl server:update -y --che-operator-image=${image} --templates=${templates}
}
startNewWorkspace() {
# Create and start a workspace
sleep 5s
chectl auth:login -u admin -p admin
chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
}
createWorkspace() {
sleep 5s
chectl auth:login -u admin -p admin
chectl workspace:create --devfile=${OPERATOR_REPO}/.ci/util/devfile-test.yaml
}
startExistedWorkspace() {
sleep 5s
chectl auth:login -u admin -p admin
chectl workspace:list
workspaceList=$(chectl workspace:list)
# Grep applied to MacOS
workspaceID=$(echo "$workspaceList" | grep workspace | awk '{ print $1} ')
workspaceID="${workspaceID%'ID'}"
echo "[INFO] Workspace id of created workspace is: ${workspaceID}"
chectl workspace:start $workspaceID
}
disableOpenShiftOAuth() {
local file="${1}/che-operator/crds/org_v1_che_cr.yaml"
yq -rSY '.spec.auth.openShiftoAuth = false' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
}
disableUpdateAdminPassword() {
local file="${1}/che-operator/crds/org_v1_che_cr.yaml"
yq -rSY '.spec.auth.updateAdminPassword = false' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
}
setServerExposureStrategy() {
local file="${1}/che-operator/crds/org_v1_che_cr.yaml"
yq -rSY '.spec.server.serverExposureStrategy = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
}
setSingleHostExposureType() {
local file="${1}/che-operator/crds/org_v1_che_cr.yaml"
yq -rSY '.spec.k8s.singleHostExposureType = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
}
setIngressDomain() {
local file="${1}/che-operator/crds/org_v1_che_cr.yaml"
yq -rSY '.spec.k8s.ingressDomain = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
}
setCustomOperatorImage() {
local file="${1}/che-operator/operator.yaml"
yq -rSY '.spec.template.spec.containers[0].image = "'${2}'"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
yq -rSY '.spec.template.spec.containers[0].imagePullPolicy = "IfNotPresent"' $file > /tmp/tmp.yaml && mv /tmp/tmp.yaml ${file}
}
insecurePrivateDockerRegistry() {
IMAGE_REGISTRY_HOST="$(minikube ip):5000"
export IMAGE_REGISTRY_HOST
local dockerDaemonConfig="/etc/docker/daemon.json"
sudo mkdir -p "/etc/docker"
sudo touch "${dockerDaemonConfig}"
config="{\"insecure-registries\" : [\"${IMAGE_REGISTRY_HOST}\"]}"
echo "${config}" | sudo tee "${dockerDaemonConfig}"
if [ -x "$(command -v docker)" ]; then
echo "[INFO] Restart docker daemon to set up private registry info."
sudo service docker restart
fi
}

View File

@ -9,10 +9,10 @@
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
set -ex
# Minikube environments config
export MINIKUBE_VERSION=v1.8.2
export KUBERNETES_VERSION=v1.16.2
export MINIKUBE_VERSION=v1.15.1
export KUBERNETES_VERSION=v1.19.4
export MINIKUBE_HOME=$HOME
export CHANGE_MINIKUBE_NONE_USER=true
export KUBECONFIG=$HOME/.kube/config

28
.github/bin/minikube/test-latest-olm.sh vendored Executable file
View File

@ -0,0 +1,28 @@
#!/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
#
set -e
set -x
export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}")))))
source "${OPERATOR_REPO}"/.github/bin/common.sh
# Stop execution on any error
trap "catchFinish" EXIT SIGINT
runTest() {
"${OPERATOR_REPO}"/olm/testCatalogSource.sh "kubernetes" "nightly" ${NAMESPACE} "catalog" "my_image"
startNewWorkspace
waitWorkspaceStart
}
init
insecurePrivateDockerRegistry
runTest

View File

@ -0,0 +1,43 @@
#!/usr/bin/env 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 -e
set -x
set -u
export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}")))))
source "${OPERATOR_REPO}"/.github/bin/common.sh
# Stop execution on any error
trap "catchFinish" EXIT SIGINT
prepareTemplates() {
disableOpenShiftOAuth ${TEMPLATES}
disableUpdateAdminPassword ${TEMPLATES}
setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE}
setServerExposureStrategy ${TEMPLATES} "single-host"
setSingleHostExposureType ${TEMPLATES} "gateway"
setIngressDomain ${TEMPLATES} "$(minikube ip).nip.io"
}
runTest() {
deployEclipseChe "operator" "minikube" ${OPERATOR_IMAGE} ${TEMPLATES}
startNewWorkspace
waitWorkspaceStart
}
init
initLatestTemplates
prepareTemplates
buildCheOperatorImage
copyCheOperatorImageToMinikube
runTest

View File

@ -0,0 +1,42 @@
#!/usr/bin/env 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 -e
set -x
export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}")))))
source "${OPERATOR_REPO}"/.github/bin/common.sh
# Stop execution on any error
trap "catchFinish" EXIT SIGINT
prepareTemplates() {
disableOpenShiftOAuth ${TEMPLATES}
disableUpdateAdminPassword ${TEMPLATES}
setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE}
setServerExposureStrategy ${TEMPLATES} "single-host"
setSingleHostExposureType ${TEMPLATES} "native"
setIngressDomain ${TEMPLATES} "$(minikube ip).nip.io"
}
runTest() {
deployEclipseChe "operator" "minikube" ${OPERATOR_IMAGE} ${TEMPLATES}
startNewWorkspace
waitWorkspaceStart
}
init
initLatestTemplates
prepareTemplates
buildCheOperatorImage
copyCheOperatorImageToMinikube
runTest

58
.github/bin/minikube/test-update-olm.sh vendored Executable file
View File

@ -0,0 +1,58 @@
#!/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 -e
export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}")))))
NAMESPACE="eclipse-che"
export CTSRC_IMAGE="myimage:latest"
export CONTAINER_HOST=ssh://root@linuxhost/run/podman/podman.sock
#"imagePullPolicy":"IfNotPresent"
source "${OPERATOR_REPO}"/.github/bin/common.sh
# Stop execution on any error
trap "catchFinish" EXIT SIGINT
insecurePrivateDockerRegistry
# Build latest stable catalog image
buildK8SCheCatalogImage() {
echo ${OPERATOR_REPO}
eval $(minikube podman-env)
podman build -t "${CTSRC_IMAGE}" -f "${OPERATOR_REPO}"/olm/eclipse-che-preview-kubernetes/Dockerfile ${OPERATOR_REPO}/olm/eclipse-che-preview-kubernetes
printf '%s\t%s\n' "$(minikube ip)" 'registry.kube' | sudo tee -a /etc/hosts
podman push $CTSRC_IMAGE $(minikube ip):5000/$CTSRC_IMAGE
exit 0
}
buildK8SCheCatalogImage
CATSRC=$(
oc create -f - -o jsonpath='{.metadata.name}' <<EOF
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: catalog-operator
namespace: eclipse-che
spec:
sourceType: grpc
image: localhost/"$CTSRC_IMAGE"
EOF
)
OPERATOR_POD=$(kubectl get pods -o json -n ${NAMESPACE} | jq -r '.items[] | select(.metadata.name | test("catalog-operator-")).metadata.name')
exit 0
oc patch pod "$OPERATOR_POD" -n ${NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/imagePullPolicy", "value":"IfNotPresent"}]'
echo "CatalogSource name is \"$CATSRC\""

View File

39
.github/bin/minishift/test-latest-operator.sh vendored Executable file
View File

@ -0,0 +1,39 @@
#!/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 -e
set -x
export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname "${BASH_SOURCE[0]}"))))
source "${OPERATOR_REPO}"/.github/bin/common.sh
# Stop execution on any error
trap "catchFinish" EXIT SIGINT
prepareTemplates() {
disableOpenShiftOAuth ${TEMPLATES}
disableUpdateAdminPassword ${TEMPLATES}
setCustomOperatorImage ${TEMPLATES} ${OPERATOR_IMAGE}
}
runTest() {
deployEclipseChe "operator" "minishift" ${OPERATOR_IMAGE} ${TEMPLATES}
startNewWorkspace
waitWorkspaceStart
}
init
initLatestTemplates
prepareTemplates
# build is done on previous github action step
copyCheOperatorImageToMinishift
runTest

41
.github/bin/minishift/test-update-operator.sh vendored Executable file
View File

@ -0,0 +1,41 @@
#!/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 -e
set -x
export OPERATOR_REPO=$(dirname $(dirname $(dirname $(dirname "${BASH_SOURCE[0]}"))))
source "${OPERATOR_REPO}"/.github/bin/common.sh
# Stop execution on any error
trap "catchFinish" EXIT SIGINT
prepareTemplates() {
disableOpenShiftOAuth ${PREVIOUS_OPERATOR_TEMPLATE}
disableOpenShiftOAuth ${LAST_OPERATOR_TEMPLATE}
}
runTest() {
deployEclipseChe "operator" "minishift" "quay.io/eclipse/che-operator:${PREVIOUS_PACKAGE_VERSION}" ${PREVIOUS_OPERATOR_TEMPLATE}
createWorkspace
updateEclipseChe "quay.io/eclipse/che-operator:${LAST_PACKAGE_VERSION}" ${LAST_OPERATOR_TEMPLATE}
waitEclipseCheDeployed ${LAST_PACKAGE_VERSION}
startExistedWorkspace
waitWorkspaceStart
}
init
initStableTemplates "openshift" "stable"
prepareTemplates
runTest

View File

@ -10,12 +10,12 @@
# Red Hat, Inc. - initial API and implementation
#
name: Check nightly "opm" bundle
name: Check nightly OLM bundle
on: pull_request
jobs:
build:
name: Check nightly "opm" bundle
name: Check nightly OLM bundle
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
@ -28,4 +28,4 @@ jobs:
echo "GOPATH: ${GOPATH}" &&
export GITHUB_WORKSPACE="${GOPATH}/src/github.com/eclipse/${{ github.repository }}" &&
cd ${GITHUB_WORKSPACE} &&
.github/action_scripts/operator_code_check.sh
.github/bin/check-nightly-olm-bundle.sh

View File

@ -1,60 +0,0 @@
#
# 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: Minishift
on: pull_request
jobs:
minishift-e2e:
name: e2e tests
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: Build operator image
run: |
export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test
# coreutils provides a readlink that supports `-f`
brew install coreutils docker docker-machine
mkdir -p ~/.docker/machine/cache/
sudo curl -Lo ~/.docker/machine/cache/boot2docker.iso https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso
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
docker-machine stop
- 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)
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

View File

@ -18,14 +18,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install minikube kubernetes cluster
run: /bin/bash .ci/start-minikube.sh
- name: Provision Minikube cluster
run: /bin/bash .github/bin/minikube/provision-cluster.sh
- name: Install chectl
run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next
- 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
- name: Run tests
run: /bin/bash .github/bin/minikube/test-latest-olm.sh
# Run this step even the previous step fail
- uses: actions/upload-artifact@v2
if: ${{ always() }}

View File

@ -17,36 +17,36 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install minikube kubernetes cluster
run: /bin/bash .ci/start-minikube.sh
- name: Provision Minikube cluster
run: /bin/bash .github/bin/minikube/provision-cluster.sh
- name: Install chectl
run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=next
- 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_scripts/nightly/minikube/single-host-gateway.sh
- name: Run tests
run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-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-single-host-gateway
name: minikube-single-host-gateway-artifacts
path: /tmp/artifacts-che
minikube-native:
name: Testing latest changes (single-host/native)
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: Provision Minikube cluster
run: /bin/bash .github/bin/minikube/provision-cluster.sh
- 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_scripts/nightly/minikube/single-host-native.sh
- name: Install jq
run: sudo pip install yq
- name: Run tests
run: /bin/bash .github/bin/minikube/test-latest-operator-singlehost-native.sh
# Run this step even the previous step fail to upload artifacts to GH
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: minikube-single-host-native
name: minikube-single-host-native-artifacts
path: /tmp/artifacts-che

View File

@ -18,14 +18,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install minikube kubernetes cluster
run: /bin/bash .ci/start-minikube.sh
- name: Provision Minikube cluster
run: /bin/bash .github/bin/minikube/provision-cluster.sh
- name: Install chectl
run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=stable
- 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
- name: Run tests
run: /bin/bash .github/bin/minikube/test-update-olm.sh
# Run this step even the previous step fail
- uses: actions/upload-artifact@v2
if: ${{ always() }}

35
.github/workflows/minishift-e2e.yaml vendored Normal file
View File

@ -0,0 +1,35 @@
#
# 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: Minishift
on: pull_request
jobs:
minishift-e2e:
name: e2e tests
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: Provision Minishift cluster
run: |
brew cask install minishift
export MINISHIFT_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }}
minishift start --memory=5500 --vm-driver=virtualbox
- name: Replace Minishift default certificates
run: /bin/bash .github/bin/minishift/certs.sh
- name: Run tests
run: |
eval $(minishift oc-env)
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

View File

@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v1
# All docker operations should be done in this step
- name: Build operator image
- name: Build Che operator image
run: |
export OPERATOR_IMAGE=quay.io/eclipse/che-operator:test
# coreutils provides a readlink that supports `-f`
@ -35,27 +35,24 @@ jobs:
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
- name: Provision Minishift 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
- name: Replace Minishift default certificates
run: /bin/bash .github/bin/minishift/certs.sh
- name: Install jq
run: sudo pip install yq
- name: Run tests
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
/bin/bash .github/bin/minishift/test-latest-operator.sh
# Run this step even the previous step fail
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: minishift-che-nightly-artifacts
name: minishift-latests-artifacts
path: /tmp/artifacts-che

View File

@ -18,21 +18,21 @@ jobs:
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
- name: Provision Minishift 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: Install chectl
run: bash <(curl -sL https://www.eclipse.org/che/chectl/) --channel=stable
- name: Install jq
run: sudo pip install yq
- name: Replace Minishift default certificates
run: /bin/bash .github/bin/minishift/certs.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
/bin/bash .github/bin/minishift/test-update-operator.sh
# Run this step even the previous step fail
- uses: actions/upload-artifact@v2
if: ${{ always() }}

View File

@ -20,7 +20,7 @@ jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
@ -32,4 +32,4 @@ jobs:
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build catalog source and opm bundle images and push
run: "${GITHUB_WORKSPACE}/.github/action_scripts/build_olm_bundle_images.sh"
run: "${GITHUB_WORKSPACE}/.github/bin/push-catalog-and-bundle-images.sh"

View File

@ -1,18 +1,15 @@
# This Workflow performs a full release of che-operator
name: release
name: Release Che Operator
on:
workflow_dispatch:
inputs:
version:
description: 'version'
default: '7.x.y'
description: 'The version that is going to be released. Should be in format 7.y.z'
required: true
default: '7.y.z'
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
@ -21,14 +18,11 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install operator courier
- name: Install operator courier, yq, and base32 wrapper
run: |
python -m pip install --upgrade pip
pip install operator-courier==2.1.7
pip install yq
- name: Install base32
run: |
# get base32 util from che-release project
wget https://raw.githubusercontent.com/eclipse/che-release/master/utils/base32
# copy base32 python-based helper script into dir that's accessed from PATH (so it's accessible to this and other called scripts)
@ -36,36 +30,29 @@ jobs:
sudo chmod +x /usr/local/bin/base32
#remove base32 from current directory to avoid it being commited during release
rm $(pwd)/base32
- name: Release operator
run: |
CHE_VERSION=${{ github.event.inputs.version }}
echo "CHE_VERSION=${CHE_VERSION}"
BRANCH=${CHE_VERSION%.*}.x
echo "BRANCH=${BRANCH}"
git config --global user.name "Mykhailo Kuznietsov"
git config --global user.email "mkuznets@redhat.com"
export GITHUB_TOKEN=${{ secrets.CHE_BOT_GITHUB_TOKEN }}
set -e
OP_SDK_DIR=/opt/operator-sdk
mkdir -p $OP_SDK_DIR
if [[ ${CHE_VERSION%.*} == 7.21 ]];then
wget https://github.com/operator-framework/operator-sdk/releases/download/v0.10.0/operator-sdk-v0.10.0-x86_64-linux-gnu -O $OP_SDK_DIR/operator-sdk
else
OPERATOR_SDK=$(sed -r 's|operator-sdk:\s*(.*)|\1|' REQUIREMENTS)
wget https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK}/operator-sdk-${OPERATOR_SDK}-x86_64-linux-gnu -O $OP_SDK_DIR/operator-sdk
fi
chmod +x $OP_SDK_DIR/operator-sdk
export PATH="$PATH:$OP_SDK_DIR"
export QUAY_ECLIPSE_CHE_USERNAME=${{ secrets.QUAY_USERNAME }}
export QUAY_ECLIPSE_CHE_PASSWORD=${{ secrets.QUAY_PASSWORD }}
# we usually do not update nightly files during major releases
if [[ ${CHE_VERSION} == *".0" ]]; then
./make-release.sh ${CHE_VERSION} --release --release-olm-files --update-nightly-olm-files
@ -73,18 +60,23 @@ jobs:
git checkout ${BRANCH}
bash -x ./make-release.sh ${CHE_VERSION} --release --release-olm-files
fi
# default robot account on quay does not have permissions for application repos
# so we provide credentials for accounts that do
export QUAY_USERNAME_K8S=${{ secrets.QUAY_ECLIPSE_CHE_OPERATOR_KUBERNETES_USERNAME }}
export QUAY_PASSWORD_K8S=${{ secrets.QUAY_ECLIPSE_CHE_OPERATOR_KUBERNETES_PASSWORD }}
export QUAY_USERNAME_OS=${{ secrets.QUAY_ECLIPSE_CHE_OPERATOR_OPENSHIFT_USERNAME }}
export QUAY_PASSWORD_OS=${{ secrets.QUAY_ECLIPSE_CHE_OPERATOR_OPENSHIFT_PASSWORD }}
# uncomment after https://github.com/eclipse/che/issues/18393 fix
# git checkout ${CHE_VERSION}-release
# ./make-release.sh ${CHE_VERSION} --push-olm-files
# echo "[DEBUG] Using credentials:"
# echo "[DEBUG] QUAY_USERNAME_K8S = ${QUAY_USERNAME_K8S} and"
# echo "[DEBUG] QUAY_USERNAME_OS = ${QUAY_USERNAME_OS}"
# publish quay applications to:
# https://quay.io/application/eclipse-che-operator-kubernetes/eclipse-che-preview-kubernetes?tab=releases and
# https://quay.io/application/eclipse-che-operator-openshift/eclipse-che-preview-openshift?tab=releases
git checkout ${CHE_VERSION}-release
./make-release.sh ${CHE_VERSION} --push-olm-files
# perform extra checkouts to ensure branches exist locally
git checkout ${BRANCH}
git checkout ${CHE_VERSION}-release

1
.gitignore vendored
View File

@ -108,7 +108,6 @@ tags
.history
build/
bin/
olm/generated
deploy/olm-catalog/eclipse-che-preview-kubernetes/generated
deploy/olm-catalog/eclipse-che-preview-openshift/generated

View File

@ -30,10 +30,9 @@ spec:
# the difference is in images, labels, exec commands
cheFlavor: ''
# Comma-separated list of ClusterRoles that will be assigned
# to che ServiceAccount. By default it is set to `che-namespace-editor`, which is used by Che
# to label the namespaces. Set it empty to not grant any cluster-wide permissions to Che ServiceAccount.
# Be aware that che-operator has to already have all permissions in these ClusterRoles to be able to grant them.
cheClusterRoles: 'che-namespace-editor'
# to che ServiceAccount. Be aware that che-operator has to already have all permissions in these
# ClusterRoles to be able to grant them.
cheClusterRoles: ''
# specifies a custom cluster role to user for the Che workspaces
# Uses the default roles if left blank.
cheWorkspaceClusterRole: ''

View File

@ -45,7 +45,7 @@ metadata:
},
"server": {
"allowUserDefinedWorkspaceNamespaces": false,
"cheClusterRoles": "che-namespace-editor",
"cheClusterRoles": "",
"cheFlavor": "",
"cheImage": "",
"cheImageTag": "",
@ -84,13 +84,13 @@ metadata:
categories: Developer Tools
certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly
createdAt: "2020-11-25T12:37:35Z"
createdAt: "2020-12-04T12:44:42Z"
description: A Kube-native development solution that delivers portable and collaborative
developer workspaces.
operatorframework.io/suggested-namespace: eclipse-che
repository: https://github.com/eclipse/che-operator
support: Eclipse Foundation
name: eclipse-che-preview-kubernetes.v7.23.0-36.nightly
name: eclipse-che-preview-kubernetes.v7.23.0-38.nightly
namespace: placeholder
spec:
apiservicedefinitions: {}
@ -473,4 +473,4 @@ spec:
maturity: stable
provider:
name: Eclipse Foundation
version: 7.23.0-36.nightly
version: 7.23.0-38.nightly

View File

@ -37,7 +37,7 @@ metadata:
},
"server": {
"allowUserDefinedWorkspaceNamespaces": false,
"cheClusterRoles": "che-namespace-editor",
"cheClusterRoles": "",
"cheFlavor": "",
"cheImage": "",
"cheImageTag": "",
@ -76,13 +76,13 @@ metadata:
categories: Developer Tools, OpenShift Optional
certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly
createdAt: "2020-11-25T12:37:42Z"
createdAt: "2020-12-04T12:44:49Z"
description: A Kube-native development solution that delivers portable and collaborative
developer workspaces in OpenShift.
operatorframework.io/suggested-namespace: eclipse-che
repository: https://github.com/eclipse/che-operator
support: Eclipse Foundation
name: eclipse-che-preview-openshift.v7.23.0-36.nightly
name: eclipse-che-preview-openshift.v7.23.0-38.nightly
namespace: placeholder
spec:
apiservicedefinitions: {}

View File

@ -151,11 +151,10 @@ releaseOperatorCode() {
echo "[INFO] Validating changes for $operatorlocalyaml"
checkImageReferences $operatorlocalyaml
echo "[INFO] List of changed files:"
git status -s
echo "[INFO] Commiting changes"
git commit -am "Update defaults tags to "$RELEASE --signoff
if git status --porcelain; then
git commit -am "Update defaults tags to "$RELEASE --signoff
fi
echo "[INFO] Building operator image"
docker build -t "quay.io/eclipse/che-operator:${RELEASE}" .
@ -173,12 +172,10 @@ updateNightlyOlmFiles() {
. ${BASE_DIR}/update-nightly-bundle.sh nightly
unset BASE_DIR
echo "[INFO] List of changed files:"
git status -s
echo "[INFO] Commiting changes"
git add -A
git commit -m "Update nightly olm files" --signoff
if git status --porcelain; then
git commit -am "Update nightly olm files" --signoff
fi
}
releaseOlmFiles() {
@ -199,13 +196,10 @@ releaseOlmFiles() {
test -f $kubernetes/$RELEASE/eclipse-che-preview-kubernetes.crd.yaml
test -f $openshift/$RELEASE/eclipse-che-preview-openshift.crd.yaml
echo "[INFO] List of changed files:"
git status -s
echo git status -s
echo "[INFO] Commiting changes"
git add -A
git commit -m "Release OLM files to "$RELEASE --signoff
if git status --porcelain; then
git commit -am "Release OLM files to "$RELEASE --signoff
fi
}
pushOlmFilesToQuayIo() {
@ -234,8 +228,9 @@ createPRToMasterBranch() {
git checkout -B $tmpBranch
git diff refs/heads/${BRANCH}...refs/heads/${RELEASE_BRANCH} ':(exclude)deploy/operator-local.yaml' ':(exclude)deploy/operator.yaml' | git apply -3
. ${RELEASE_DIR}/replace-images-tags.sh nightly master
git add -A
git commit -m "Copy "$RELEASE" csv to master" --signoff
if git status --porcelain; then
git commit -am "Copy "$RELEASE" csv to master" --signoff
fi
git push origin $tmpBranch -f
hub pull-request --base master --head ${tmpBranch} -m "Copy "$RELEASE" csv to master"
}

View File

@ -1,17 +1,25 @@
FROM quay.io/operator-framework/upstream-registry-builder:v1.15.1 as builder
#!/bin/bash
#
# Copyright (c) 2012-2018 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
FROM quay.io/operator-framework/upstream-registry-builder as builder
COPY deploy manifests/eclipse-che-preview-kubernetes
RUN ./bin/initializer -o ./bundles.db
RUN /bin/initializer -o ./bundles.db
FROM openshift/origin-base
COPY --from=builder /bin/initializer /initializer
COPY --from=builder /bin/configmap-server /bin/configmap-server
FROM scratch
COPY --from=builder /bundles.db /bundles.db
COPY --from=builder /bin/registry-server /registry-server
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe
EXPOSE 50051
ENTRYPOINT ["/registry-server"]
CMD ["--database", "bundles.db"]

View File

@ -1,17 +1,26 @@
FROM quay.io/operator-framework/upstream-registry-builder:v1.15.1 as builder
#!/bin/bash
#
# Copyright (c) 2012-2018 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
FROM quay.io/operator-framework/upstream-registry-builder as builder
COPY deploy manifests/eclipse-che-preview-openshift
RUN ./bin/initializer -o ./bundles.db
RUN /bin/initializer -o ./bundles.db
FROM openshift/origin-base
COPY --from=builder /bin/initializer /initializer
COPY --from=builder /bin/configmap-server /bin/configmap-server
FROM scratch
COPY --from=builder /bundles.db /bundles.db
COPY --from=builder /bin/registry-server /registry-server
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe
EXPOSE 50051
ENTRYPOINT ["/registry-server"]
CMD ["--database", "bundles.db"]

View File

@ -13,14 +13,7 @@
# Scripts to prepare OLM(operator lifecycle manager) and install che-operator package
# with specific version using OLM.
if [ -z "${BASE_DIR}" ]; then
SCRIPT=$(readlink -f "$0")
export SCRIPT
BASE_DIR=$(dirname "$(dirname "$SCRIPT")")/olm;
export BASE_DIR
fi
BASE_DIR=$(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}")))/olm
ROOT_DIR=$(dirname "${BASE_DIR}")
source ${ROOT_DIR}/olm/check-yq.sh
@ -64,7 +57,7 @@ else
echo "[ERROR] Stable preview channel doesn't support installation using 'catalog'. Use 'Marketplace' instead of it."
exit 1
fi
platformPath="${BASE_DIR}/${packageName}"
packageFolderPath="${platformPath}/deploy/olm-catalog/${packageName}"
CSV_FILE="${packageFolderPath}/${PACKAGE_VERSION}/${packageName}.v${PACKAGE_VERSION}.clusterserviceversion.yaml"
@ -105,7 +98,7 @@ EOF
createRpcCatalogSource() {
NAMESPACE=${1}
indexIp=${2}
cat <<EOF | oc apply -n "${NAMESPACE}" -f - || return $?
cat <<EOF | oc apply -n "${NAMESPACE}" -f - || return $?
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
@ -159,6 +152,7 @@ buildBundleImage() {
# ${OPM_BINARY} alpha bundle validate -t "${CATALOG_BUNDLE_IMAGE_NAME_LOCAL}" --image-builder "${imageTool}"
SKIP_TLS_VERIFY=""
if [ "${imageTool}" == "podman" ]; then
SKIP_TLS_VERIFY=" --tls-verify=false"
fi
@ -183,11 +177,14 @@ buildCatalogImage() {
imageTool=${3:-docker}
FROM_INDEX=${4}
if [ -n "${FROM_INDEX}" ]; then
FROM_INDEX=${4:-""}
BUILD_INDEX_IMAGE_ARG=""
if [ ! "${FROM_INDEX}" == "" ]; then
BUILD_INDEX_IMAGE_ARG=" --from-index ${FROM_INDEX}"
fi
SKIP_TLS_ARG=""
SKIP_TLS_VERIFY=""
if [ "${imageTool}" == "podman" ]; then
SKIP_TLS_ARG=" --skip-tls"
SKIP_TLS_VERIFY=" --tls-verify=false"
@ -300,10 +297,7 @@ installOperatorMarketPlace() {
}
subscribeToInstallation() {
CSV_NAME="${1}"
if [ -z "${CSV_NAME}" ]; then
CSV_NAME="${CSV}"
fi
CSV_NAME="${1-${CSV}}"
echo "Subscribing to version: ${CSV_NAME}"
@ -411,7 +405,7 @@ getBundleListFromCatalogSource() {
--image=docker.io/fullstorydev/grpcurl:v1.7.0 \
-- -plaintext "${CATALOG_IP}:${CATALOG_PORT}" api.Registry.ListBundles
)
LIST_BUNDLES=$(echo "${LIST_BUNDLES}" | head -n -1)
echo "${LIST_BUNDLES}"

View File

@ -59,12 +59,13 @@ do
esac
if [ -z "${QUAY_ECLIPSE_CHE_USERNAME}" ] || [ -z "${QUAY_ECLIPSE_CHE_PASSWORD}" ]
then
echo "#### ERROR: "
echo "You should have set ${QUAY_USERNAME_PLATFORM_VAR} and ${QUAY_PASSWORD_PLATFORM_VAR} environment variables"
echo "with a user that has write access to the following Quay.io namespace: ${quayNamespace}"
echo "or QUAY_ECLIPSE_CHE_USERNAME and QUAY_ECLIPSE_CHE_PASSWORD if the same user can access both namespaces 'eclipse-che-operator-kubernetes' and 'eclipse-che-operator-openshift'"
echo "[ERROR] Must set ${QUAY_USERNAME_PLATFORM_VAR} and ${QUAY_PASSWORD_PLATFORM_VAR} environment variables"
echo "[ERROR] with a user that has write access to the following Quay.io application namespace: ${quayNamespace}"
echo "[ERROR] or QUAY_ECLIPSE_CHE_USERNAME and QUAY_ECLIPSE_CHE_PASSWORD if the same user can access both "
echo "[ERROR] application namespaces 'eclipse-che-operator-kubernetes' and 'eclipse-che-operator-openshift'"
exit 1
fi
# echo "[DEBUG] Authenticating with: QUAY_ECLIPSE_CHE_USERNAME = ${QUAY_ECLIPSE_CHE_USERNAME}"
AUTH_TOKEN=$(curl -sH "Content-Type: application/json" -XPOST https://quay.io/cnr/api/v1/users/login -d '
{
"user": {
@ -72,7 +73,15 @@ do
"password": "'"${QUAY_ECLIPSE_CHE_PASSWORD}"'"
}
}' | jq -r '.token')
# if [[ ${AUTH_TOKEN} ]]; then echo "[DEBUG] Got token"; fi
# move all diff files away so we don't get warnings about invalid file names
find . -name "*.yaml.diff" -exec rm -f {} \; || true
# push new applications to quay.io/application/eclipse-che-operator-*
operator-courier push generated/flatten "${quayNamespace}" "${packageName}" "${applicationVersion}" "${AUTH_TOKEN}"
# now put them back
git checkout . || true
done
cd "${CURRENT_DIR}"

View File

@ -83,9 +83,7 @@ fi
# Assign catalog source image
CATALOG_SOURCE_IMAGE=$5
if [ -z "${IMAGE_REGISTRY_USER_NAME}" ]; then
IMAGE_REGISTRY_USER_NAME=eclipse
fi
IMAGE_REGISTRY_USER_NAME=${IMAGE_REGISTRY_USER_NAME:-eclipse}
echo "[INFO] Image 'IMAGE_REGISTRY_USER_NAME': ${IMAGE_REGISTRY_USER_NAME}"
init() {
@ -118,16 +116,15 @@ init() {
buildOLMImages() {
# Manage catalog source for every platform in part.
# 1. Kubernetes:
# 1. Kubernetes:
# a) Use Minikube cluster. Enable registry addon, build catalog source and olm bundle images, push them to embedded private registry.
# b) Provide image registry env variables to push images to the real public registry(docker.io, quay.io etc).
# 2. Openshift: build bundle image and push it using image stream. Launch deployment with custom grpc based catalog source image to install the latest bundle.
if [[ "${PLATFORM}" == "kubernetes" ]]
then
echo "[INFO]: Kubernetes platform detected"
# Build operator image
if [ -n "${OPERATOR_IMAGE}" ];then
if [ -n "${OPERATOR_IMAGE}" ];then
echo "[INFO]: Build operator image ${OPERATOR_IMAGE}..."
cd "${OPERATOR_REPO}" && docker build -t "${OPERATOR_IMAGE}" -f Dockerfile .
@ -150,101 +147,6 @@ buildOLMImages() {
fi
echo "[INFO]: Successfully created catalog source container image and enabled minikube ingress."
elif [[ "${PLATFORM}" == "openshift" ]]
then
if [ "${INSTALLATION_TYPE}" == "Marketplace" ];then
return
fi
echo "[INFO]: Starting to build catalog image and push to ImageStream."
echo "============"
echo "[INFO] Current user is $(oc whoami)"
echo "============"
oc new-project "${NAMESPACE}" || true
pull_user="puller"
pull_password="puller"
add_user "${pull_user}" "${pull_password}"
if [ -z "${KUBECONFIG}" ]; then
KUBECONFIG="${HOME}/.kube/config"
fi
TEMP_KUBE_CONFIG="/tmp/$pull_user.kubeconfig"
rm -rf "${TEMP_KUBE_CONFIG}"
cp "${KUBECONFIG}" "${TEMP_KUBE_CONFIG}"
sleep 180
loginLogFile="/tmp/login-log"
touch "${loginLogFile}"
loginCMD="oc login --kubeconfig=${TEMP_KUBE_CONFIG} --username=${pull_user} --password=${pull_password} > ${loginLogFile}"
timeout 900 bash -c "${loginCMD}" || echo "[ERROR] Login Fail"
echo "[INFO] $(cat "${loginLogFile}" || true)"
echo "[INFO] Applying policy registry-viewer to user '${pull_user}'..."
oc -n "$NAMESPACE" policy add-role-to-user registry-viewer "$pull_user"
echo "[INFO] Trying to retrieve user '${pull_user}' token..."
token=$(oc --kubeconfig=${TEMP_KUBE_CONFIG} whoami -t)
echo "[INFO] User '${pull_user}' token is: ${token}"
oc -n "${NAMESPACE}" new-build --binary --strategy=docker --name serverless-bundle
cp -rf "${PACKAGE_FOLDER_PATH}/bundle.Dockerfile" "${PACKAGE_FOLDER_PATH}/Dockerfile"
if oc -n "${NAMESPACE}" start-build serverless-bundle --from-dir "${PACKAGE_FOLDER_PATH}"; then
rm -rf "${PACKAGE_FOLDER_PATH}/Dockerfile"
else
rm -rf "${PACKAGE_FOLDER_PATH}/Dockerfile"
echo "[ERROR ]Failed to build bundle image."
exit 1
fi
cat <<EOF | oc apply -n "${NAMESPACE}" -f - || return $?
apiVersion: apps/v1
kind: Deployment
metadata:
name: catalog-source-app
spec:
selector:
matchLabels:
app: catalog-source-app
template:
metadata:
labels:
app: catalog-source-app
spec:
containers:
- name: registry
image: quay.io/openshift-knative/index
ports:
- containerPort: 50051
name: grpc
protocol: TCP
livenessProbe:
exec:
command:
- grpc_health_probe
- -addr=localhost:50051
readinessProbe:
exec:
command:
- grpc_health_probe
- -addr=localhost:50051
command:
- /bin/sh
- -c
- |-
podman login -u ${pull_user} -p ${token} image-registry.openshift-image-registry.svc:5000
/bin/opm registry add --container-tool=podman -d index.db --mode=semver -b image-registry.openshift-image-registry.svc:5000/${NAMESPACE}/serverless-bundle && \
/bin/opm registry serve -d index.db -p 50051
EOF
# Wait for the index pod to be up to avoid inconsistencies with the catalog source.
kubectl wait --for=condition=ready "pods" -l app=catalog-source-app --timeout=120s -n "${NAMESPACE}" || true
indexip="$(oc -n "$NAMESPACE" get pods -l app=catalog-source-app -o jsonpath='{.items[0].status.podIP}')"
# Install the catalogsource.
createRpcCatalogSource "${NAMESPACE}" "${indexip}"
else
echo "[ERROR]: Error to start olm tests. Invalid Platform"
printHelp
@ -257,7 +159,7 @@ run() {
if [ ! ${PLATFORM} == "openshift" ] && [ "${CHANNEL}" == "nightly" ]; then
forcePullingOlmImages "${CATALOG_BUNDLE_IMAGE}"
fi
installOperatorMarketPlace
subscribeToInstallation
@ -266,43 +168,6 @@ run() {
waitCheServerDeploy
}
function add_user {
name=$1
pass=$2
echo "Creating user $name:$pass"
PASSWD_TEMP_DIR="$(mktemp -q -d -t "passwd_XXXXXX" 2>/dev/null || mktemp -q -d)"
HT_PASSWD_FILE="${PASSWD_TEMP_DIR}/users.htpasswd"
touch "${HT_PASSWD_FILE}"
htpasswd -b "${HT_PASSWD_FILE}" "$name" "$pass"
echo "HTPASSWD content is:======================="
cat "${HT_PASSWD_FILE}"
echo "==================================="
if ! kubectl get secret htpass-secret -n openshift-config 2>/dev/null; then
kubectl create secret generic htpass-secret \
--from-file=htpasswd="${HT_PASSWD_FILE}" \
-n openshift-config
fi
cat <<EOF | oc apply -n "${NAMESPACE}" -f - || return $?
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: my_htpasswd_provider
mappingMethod: claim
type: HTPasswd
htpasswd:
fileData:
name: htpass-secret
EOF
}
init
buildOLMImages
run