From eb13814a3e88e8d22917ba6da7196402fe90dc28 Mon Sep 17 00:00:00 2001 From: Valeriy Svydenko Date: Wed, 27 Sep 2023 11:25:56 +0300 Subject: [PATCH] use custom editor in ci tests Signed-off-by: Valeriy Svydenko --- .ci/openshift-ci/common-functions.sh | 40 ++++++++-------------------- .ci/openshift-ci/smoke-test.sh | 5 ++-- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/.ci/openshift-ci/common-functions.sh b/.ci/openshift-ci/common-functions.sh index 20a399539d..9dce5b56ce 100755 --- a/.ci/openshift-ci/common-functions.sh +++ b/.ci/openshift-ci/common-functions.sh @@ -87,32 +87,6 @@ killProcessByPort() { fuser -k ${CHE_FORWARDED_PORT}/tcp } -requestFactoryResolverGitRepoUrl() { - GIT_REPO_URL=$1 - CLUSTER_ACCESS_TOKEN=$(oc whoami -t) - - curl -i -X 'POST' \ - http://localhost:${CHE_FORWARDED_PORT}/api/factory/resolver \ - -H 'accept: */*' \ - -H "Authorization: Bearer ${CLUSTER_ACCESS_TOKEN}" \ - -H 'Content-Type: application/json' \ - -d '{ - "url": "'"${GIT_REPO_URL}"'" - }' -} - -testFactoryResolver() { - PUBLIC_REPO_URL=$1 - - echo "[INFO] Check factory resolver for public repository" - if requestFactoryResolverGitRepoUrl "${PUBLIC_REPO_URL}" | grep "HTTP/1.1 200"; then - echo "[INFO] Factory resolver returned 'HTTP/1.1 200' status code." - else - echo "[ERROR] Factory resolver returned wrong status code. Expected: HTTP/1.1 200." - exit 1 - fi -} - requestProvisionNamespace() { CLUSTER_ACCESS_TOKEN=$(oc whoami -t) @@ -149,11 +123,17 @@ testProjectIsCloned() { fi } -runTestWorkspaceWithGitRepoUrl() { +runTestWorkspaceWithGitRepoUrlAndCustomEditor() { WS_NAME=$1 PROJECT_NAME=$2 GIT_REPO_URL=$3 OCP_USER_NAMESPACE=$4 + EDITOR_ID=$5 + + PLUGIN_REGISTRY_URL=$(oc get checlusters.org.eclipse.che -n "${CHE_NAMESPACE}" "${CHE_NAMESPACE}" -o=jsonpath='{.status.pluginRegistryURL}') + echo "[INFO] Plugin registry URL: ${PLUGIN_REGISTRY_URL}" + + EDITOR_URL=$PLUGIN_REGISTRY_URL/plugins/$EDITOR_ID/devfile.yaml oc project "${OCP_USER_NAMESPACE}" cat .ci/openshift-ci/devworkspace-test.yaml > devworkspace-test.yaml @@ -162,6 +142,7 @@ runTestWorkspaceWithGitRepoUrl() { sed -i "s#ws-name#${WS_NAME}#g" devworkspace-test.yaml sed -i "s#project-name#${PROJECT_NAME}#g" devworkspace-test.yaml sed -i "s#git-repo-url#${GIT_REPO_URL}#g" devworkspace-test.yaml + sed -i "s#editor-uri#${EDITOR_URL}#g" devworkspace-test.yaml cat devworkspace-test.yaml @@ -199,13 +180,14 @@ collectEclipseCheLogs() { oc get checluster -o yaml -n "$CHE_NAMESPACE" > "${ARTIFACTS_DIR}/che-cluster.yaml" } -testClonePublicRepoNoPatOAuth() { +testStartWorkspace() { WS_NAME=$1 PROJECT_NAME=$2 GIT_REPO_URL=$3 OCP_USER_NAMESPACE=$4 + EDITOR_ID=$5 - runTestWorkspaceWithGitRepoUrl "${WS_NAME}" "${PROJECT_NAME}" "${GIT_REPO_URL}" "${OCP_USER_NAMESPACE}" + runTestWorkspaceWithGitRepoUrlAndCustomEditor "${WS_NAME}" "${PROJECT_NAME}" "${GIT_REPO_URL}" "${OCP_USER_NAMESPACE}" "${EDITOR_ID}" echo "[INFO] Check the public repository is cloned" testProjectIsCloned "${PROJECT_NAME}" "${OCP_USER_NAMESPACE}" || \ { echo "[ERROR] Project file /projects/${PROJECT_NAME}/${YAML_FILE_NAME} should be present." && exit 1; } diff --git a/.ci/openshift-ci/smoke-test.sh b/.ci/openshift-ci/smoke-test.sh index 5936c98cae..be971a54ce 100755 --- a/.ci/openshift-ci/smoke-test.sh +++ b/.ci/openshift-ci/smoke-test.sh @@ -17,6 +17,7 @@ set -ex set -o pipefail export PUBLIC_REPO_URL=${PUBLIC_REPO_URL:-"https://github.com/chepullreq1/public-repo.git"} +export CHE_CODE_EDITOR_ID=che-incubator/che-code/latest # import common test functions SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" @@ -27,5 +28,5 @@ trap "catchFinish" EXIT SIGINT setupTestEnvironment "${OCP_NON_ADMIN_USER_NAME}" -testFactoryResolver "${PUBLIC_REPO_URL}" -testClonePublicRepoNoPatOAuth "${PUBLIC_REPO_WORKSPACE_NAME}" "${PUBLIC_PROJECT_NAME}" "${PUBLIC_REPO_URL}" "${USER_CHE_NAMESPACE}" +# test starting workspace with che-code editor +testStartWorkspace "${PUBLIC_REPO_WORKSPACE_NAME}" "${PUBLIC_PROJECT_NAME}" "${PUBLIC_REPO_URL}" "${USER_CHE_NAMESPACE}" "${CHE_CODE_EDITOR_ID}"