diff --git a/.ci/oci-devworkspace-happy-path.sh b/.ci/oci-devworkspace-happy-path.sh index 9d4cdfc29..8ef556a58 100755 --- a/.ci/oci-devworkspace-happy-path.sh +++ b/.ci/oci-devworkspace-happy-path.sh @@ -15,70 +15,14 @@ set -o pipefail # error on unset variables set -u -export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0"))); -export HAPPY_PATH_POD_NAME=happy-path-che -export HAPPY_PATH_TEST_PROJECT='https://github.com/che-samples/java-spring-petclinic/tree/devfilev2' -source "${OPERATOR_REPO}"/.github/bin/common.sh -source "${OPERATOR_REPO}"/.github/bin/oauth-provision.sh - -# Stop execution on any error -trap "Catch_Finish" EXIT SIGINT - -function bumpPodsInfo() { - NS=$1 - TARGET_DIR="${ARTIFACTS_DIR}/${NS}-info" - mkdir -p "$TARGET_DIR" - - oc get pods -n ${NS} - - for POD in $(oc get pods -o name -n ${NS}); do - for CONTAINER in $(oc get -n ${NS} ${POD} -o jsonpath="{.spec.containers[*].name}"); do - echo "" - echo "======== Getting logs from container $POD/$CONTAINER in $NS" - echo "" - # container name includes `pod/` prefix. remove it - LOGS_FILE=$TARGET_DIR/$(echo ${POD}-${CONTAINER}.log | sed 's|pod/||g') - oc logs ${POD} -c ${CONTAINER} -n ${NS} > $LOGS_FILE || true - done - done - echo "======== Bumping events -n ${NS} ========" - oc get events -n $NS -o=yaml > $TARGET_DIR/events.log || true -} - -function Catch_Finish() { - bumpPodsInfo "eclipse-che" - bumpPodsInfo "devworkspace-controller" - bumpPodsInfo "user-che" - # bump DW related CRs but do not fail when CRDs are not created yet - oc get devworkspace -n "user-che" -o=yaml > $ARTIFACTS_DIR/devworkspaces.yaml || true - oc get devworkspacetemplate -n "user-che" -o=yaml > $ARTIFACTS_DIR/devworkspace-templates.yaml || true - oc get devworkspacerouting -n "user-che" -o=yaml > $ARTIFACTS_DIR/devworkspace-routings.yaml || true - - collectLogs -} - -overrideDefaults() { - # CI_CHE_OPERATOR_IMAGE it is che operator image builded in openshift CI job workflow. More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates - export OPERATOR_IMAGE=${CI_CHE_OPERATOR_IMAGE:-"quay.io/eclipse/che-operator:next"} - echo ${OPERATOR_IMAGE} -} +export CHE_REPO_BRANCH="main" deployChe() { - cat > /tmp/che-cr-patch.yaml < /tmp/pod-che-happy-path.yaml - sed -i "s@CHE_URL@${ECLIPSE_CHE_URL}@g" /tmp/pod-che-happy-path.yaml - sed -i "s@WORKSPACE_ROUTE@${TS_SELENIUM_DEVWORKSPACE_URL}@g" /tmp/pod-che-happy-path.yaml - sed -i "s@CHE-NAMESPACE@${NAMESPACE}@g" /tmp/pod-che-happy-path.yaml - cat /tmp/pod-che-happy-path.yaml +source <(curl -s https://raw.githubusercontent.com/eclipse/che/${CHE_REPO_BRANCH}/tests/devworkspace-happy-path/common.sh) - oc apply -f /tmp/pod-che-happy-path.yaml - # 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 - - mkdir -p ${ARTIFACTS_DIR} - cp -r /tmp/e2e ${ARTIFACTS_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 -} +trap "collectLogs" EXIT SIGINT initDefaults initLatestTemplates -overrideDefaults -provisionOpenShiftOAuthUser -runTest +deployChe + +bash <(curl -s https://raw.githubusercontent.com/eclipse/che/${CHE_REPO_BRANCH}/tests/devworkspace-happy-path/remote-launch.sh) diff --git a/.ci/openshift-ci/happy-path-che.yaml b/.ci/openshift-ci/happy-path-che.yaml deleted file mode 100644 index d22a733c3..000000000 --- a/.ci/openshift-ci/happy-path-che.yaml +++ /dev/null @@ -1,73 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: happy-path-che - namespace: CHE-NAMESPACE -spec: - volumes: - - name: test-run-results - - name: dshm - emptyDir: - medium: Memory - containers: - # container containing the tests - - name: happy-path-test - image: quay.io/eclipse/che-e2e:next - imagePullPolicy: Always - env: - - name: TEST_SUITE - value: test-devworkspace-happy-path - - name: NODE_TLS_REJECT_UNAUTHORIZED - value: '0' - - name: TS_SELENIUM_BASE_URL - value: CHE_URL - - name: TS_SELENIUM_DEVWORKSPACE_URL - value: WORKSPACE_ROUTE - - name: TS_SELENIUM_MULTIUSER - value: 'true' - - name: TS_SELENIUM_LOG_LEVEL - value: TRACE - - name: TS_SELENIUM_OCP_USERNAME - value: 'user' - - name: TS_SELENIUM_OCP_PASSWORD - value: "user" - - name: TS_SELENIUM_VALUE_OPENSHIFT_OAUTH - value: 'true' - - name: TS_SELENIUM_USERNAME - value: "admin" - - name: TS_SELENIUM_PASSWORD - value: 'admin' - - name: TS_OCP_LOGIN_PAGE_PROVIDER_TITLE - value: "htpasswd" - - name: DELETE_WORKSPACE_ON_FAILED_TEST - value: "true" - - name: TS_SELENIUM_START_WORKSPACE_TIMEOUT - value: '540000' - - name: TS_IDE_LOAD_TIMEOUT - value: '40000' - volumeMounts: - - name: test-run-results - mountPath: /tmp/e2e/report/ - - mountPath: /dev/shm - name: dshm - resources: - requests: - memory: "3Gi" - cpu: "2" - limits: - memory: "4Gi" - cpu: "2" -# Download results - - name: download-reports - image: eeacms/rsync - imagePullPolicy: IfNotPresent - volumeMounts: - - name: test-run-results - mountPath: /tmp/e2e/report/ - command: ["sh"] - args: - [ - "-c", - "while true; if [[ -f /tmp/done ]]; then exit 0; fi; do sleep 1; done", - ] - restartPolicy: Never