Skip to content

Commit

Permalink
use custom editor in ci tests
Browse files Browse the repository at this point in the history
Signed-off-by: Valeriy Svydenko <[email protected]>
  • Loading branch information
svor committed Sep 27, 2023
1 parent 84edf9b commit eb13814
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 31 deletions.
40 changes: 11 additions & 29 deletions .ci/openshift-ci/common-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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; }
Expand Down
5 changes: 3 additions & 2 deletions .ci/openshift-ci/smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 )"
Expand All @@ -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}"

0 comments on commit eb13814

Please sign in to comment.