Skip to content

Commit

Permalink
feat: use remote launch of DW happy path
Browse files Browse the repository at this point in the history
  • Loading branch information
sleshchenko committed Oct 19, 2021
1 parent 86893cd commit 8cb673e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 224 deletions.
63 changes: 0 additions & 63 deletions .ci/common.sh

This file was deleted.

83 changes: 8 additions & 75 deletions .ci/oci-dashboard-happy-path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,20 @@ set -u
# print each command before executing it
set -x

SCRIPT_DIR=$(dirname $(readlink -f "$0"))
source "${SCRIPT_DIR}"/common.sh

USER_NAMESPACE="user-che"
export CHE_REPO_BRANCH="main"
source <(curl -s https://raw.githubusercontent.com/eclipse/che/${CHE_REPO_BRANCH}/tests/devworkspace-happy-path/common.sh)

# Catch the finish of the job and write logs in artifacts.
function Catch_Finish() {
# grab devworkspace-controller namespace events after running e2e
bumpPodsInfo "devworkspace-controller"
bumpPodsInfo $USER_NAMESPACE
oc get devworkspaces -n $USER_NAMESPACE -o=yaml > $ARTIFACT_DIR/devworkspaces.yaml
oc get devworkspacerouting -n $USER_NAMESPACE -o=yaml > $ARTIFACT_DIR/devworkspace-routings.yaml
oc get devworkspacetemplate -n $USER_NAMESPACE -o=yaml > $ARTIFACT_DIR/devworkspace-templates.yaml
chectl server:logs --chenamespace=${NAMESPACE} --directory=${ARTIFACT_DIR} --telemetry=off
}
trap 'Catch_Finish $?' EXIT SIGINT
trap 'collectLogs $?' EXIT SIGINT

# ENV used by PROW ci
export CI="openshift"
export NAMESPACE="eclipse-che"
export HAPPY_PATH_POD_NAME=happy-path-che

# Pod created by openshift ci don't have user. Using this envs should avoid errors with git user.
export GIT_COMMITTER_NAME="CI BOT"
export GIT_COMMITTER_EMAIL="ci_bot@notused.com"
export HAPPY_PATH_TEST_PROJECT='https://github.com/che-samples/java-spring-petclinic/tree/devfilev2'

deployChe() {
cat > /tmp/che-cr-patch.yaml <<EOL
spec:
Expand All @@ -55,66 +44,10 @@ EOL

echo "INFO: Using the following Che Cluster CR"
cat /tmp/che-cr-patch.yaml

echo "----------------------------------"
# chectl is preinstalled in OpenShift CI image. See ./openshift-ci/Dockerfile
chectl server:deploy --che-operator-cr-patch-yaml=/tmp/che-cr-patch.yaml -p openshift --batch --telemetry=off --installer=operator
}

startHappyPathTest() {
# patch happy-path-che.yaml
ECLIPSE_CHE_URL=http://$(oc get route -n "${NAMESPACE}" che -o jsonpath='{.status.ingress[0].host}')
TS_SELENIUM_DEVWORKSPACE_URL="${ECLIPSE_CHE_URL}/#${HAPPY_PATH_TEST_PROJECT}"
HAPPY_PATH_POD_FILE=${SCRIPT_DIR}/resources/pod-che-happy-path.yaml
sed -i "s@CHE_URL@${ECLIPSE_CHE_URL}@g" ${HAPPY_PATH_POD_FILE}
sed -i "s@WORKSPACE_ROUTE@${TS_SELENIUM_DEVWORKSPACE_URL}@g" ${HAPPY_PATH_POD_FILE}
sed -i "s@CHE-NAMESPACE@${NAMESPACE}@g" ${HAPPY_PATH_POD_FILE}

echo "[INFO] Applying the following patched Che Happy Path Pod:"
cat ${HAPPY_PATH_POD_FILE}
echo "[INFO] --------------------------------------------------"
oc apply -f ${HAPPY_PATH_POD_FILE}
# wait for the pod to start
n=0
while [ $n -le 120 ]
do
PHASE=$(oc get pod -n ${NAMESPACE} ${HAPPY_PATH_POD_NAME} \
--template='{{ .status.phase }}')
if [[ ${PHASE} == "Running" ]]; then
echo "[INFO] Happy-path test started succesfully."
return
fi

sleep 5
n=$(( n+1 ))
done

echo "[ERROR] Failed to start happy-path test."
exit 1
}

runTest() {
deployChe

startHappyPathTest

# wait for the test to finish
oc logs -n ${NAMESPACE} ${HAPPY_PATH_POD_NAME} -c happy-path-test -f

# just to sleep
sleep 3

# download the test results
mkdir -p /tmp/e2e
oc rsync -n ${NAMESPACE} ${HAPPY_PATH_POD_NAME}:/tmp/e2e/report/ /tmp/e2e -c download-reports
oc exec -n ${NAMESPACE} ${HAPPY_PATH_POD_NAME} -c download-reports -- touch /tmp/done
cp -r /tmp/e2e ${ARTIFACT_DIR}

EXIT_CODE=$(oc logs -n ${NAMESPACE} ${HAPPY_PATH_POD_NAME} -c happy-path-test | grep EXIT_CODE)

if [[ ${EXIT_CODE} == "+ EXIT_CODE=1" ]]; then
echo "[ERROR] Happy-path test failed."
exit 1
fi
}
provisionOpenShiftOAuthUser
runTest
deployChe
bash <(curl -s https://raw.githubusercontent.com/eclipse/che/${CHE_REPO_BRANCH}/tests/devworkspace-happy-path/remote-launch.sh)
12 changes: 0 additions & 12 deletions .ci/resources/htpasswdProvider.yaml

This file was deleted.

73 changes: 0 additions & 73 deletions .ci/resources/pod-che-happy-path.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .ci/resources/users.htpasswd

This file was deleted.

0 comments on commit 8cb673e

Please sign in to comment.