Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion devfiles/devfiles.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
https://registry.devfile.io/devfiles/nodejs
https://registry.devfile.io/devfiles/java-quarkus
https://registry.devfile.io/devfiles/go
https://registry.devfile.io/devfiles/php-laravel
https://registry.devfile.io/devfiles/python
46 changes: 29 additions & 17 deletions dw-auto-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ while getopts "vfdhs:p:" o; do
echo -e "${RED}Error:${NC} Invalid scenario '${SCENARIO}'. Valid options are: sshd, jetbrains, vscode." >&2
exit 1
fi
echo "Using scenario '${SCENARIO}'."
echo "Using '${SCENARIO}' scenario."
;;
p)
PR_NUMBER="${OPTARG}"
Expand All @@ -51,7 +51,14 @@ while getopts "vfdhs:p:" o; do
echo -e "Using che-code image from PR #${PR_NUMBER}."
;;
h)
echo "Help: This script accepts -v for verbose mode, -d for debug mode, -f for full images test, -s <scenario> to skip scenario choice (sshd|jetbrains|vscode), -p <PR_NUMBER> to test a che-code PR image (e.g. from che-incubator/che-code) and -h for help."
echo -e "Usage: $0 [OPTIONS]\n"
echo -e "Options:"
echo -e " -v\t\t\tVerbose mode"
echo -e " -d\t\t\tDebug mode (verbose + keep resources, single test only)"
echo -e " -f\t\t\tFull test matrix (all images)"
echo -e " -s <scenario>\t\tSkip scenario prompt (sshd|jetbrains|vscode)"
echo -e " -p <PR_NUMBER>\tTest a che-code PR image (from che-incubator/che-code)"
echo -e " -h\t\t\tShow this help message"
exit 0
;;
\?)
Expand All @@ -69,25 +76,25 @@ done

log() {
if [ ${VERBOSE} -eq 1 ]; then
echo ${@}
echo -e "${@}"
fi
}

# Resolves the pod name and main container name for the current DevWorkspace.
# Sets global variables: podName, mainContainerName
# Returns 1 if pod or container cannot be found.
resolve_devworkspace_pod() {
podNameAndDWName=$(oc get pods -o 'jsonpath={range .items[*]}{.metadata.name}{","}{.metadata.labels.controller\.devfile\.io/devworkspace_name}{end}')
log "podNameAndDWName: ${podNameAndDWName}"
podName=$(echo ${podNameAndDWName} | grep ${DEVWORKSPACE_NAME} | cut -d, -f1)
log "podName: ${podName}"
podNameAndDWName=$(oc get pods -o 'jsonpath={range .items[*]}{.metadata.name}{","}{.metadata.labels.controller\.devfile\.io/devworkspace_name}{"\n"}{end}')
log "${YELLOW}podNameAndDWName: \n${NC}${podNameAndDWName}"
podName=$(echo "${podNameAndDWName}" | grep ${DEVWORKSPACE_NAME} | cut -d, -f1)
log "${YELLOW}podName: \n${NC}${podName}"
mainContainerName=$(oc get devworkspace ${DEVWORKSPACE_NAME} -o json | jq -r '[.spec.template.components[] | select(.container) | .name] | first')
log "mainContainerName: ${mainContainerName}"
log "${YELLOW}mainContainerName: \n${NC}${mainContainerName}"
if [ -z "${podName}" ] || [ -z "${mainContainerName}" ]; then
log "Could not find pod/container matching ${DEVWORKSPACE_NAME}"
return 1
fi
log "Found ${mainContainerName} container in ${podName} pod"
log "${GREEN}Found ${YELLOW}${mainContainerName}${NC} container in ${YELLOW}${podName}${NC} pod"
return 0
}

Expand Down Expand Up @@ -260,19 +267,24 @@ total_count=0
START_TIME=$SECONDS

if [ ${DEBUG} -eq 0 ]; then
total_tests=$(( ${#DEVFILE_URL_LIST[@]} * ${#IMAGES_LIST[@]} ))
log "Iterating over ${#DEVFILE_URL_LIST[@]} Devfiles and ${#IMAGES_LIST[@]} Images"
else
log -e "${YELLOW}DEBUG MODE!${NC} Only first devfile and first image are used."
total_tests=1
log "${YELLOW}DEBUG MODE!${NC} Only first devfile and first image used."
fi

# echo numbers of tests that will be ran
echo -e "${BLUE}There will be ${total_tests} tests performed in total.${NC}"

for devfile_url in "${DEVFILE_URL_LIST[@]}"; do
curl -sL -o ${TMP_DEVFILE} ${devfile_url}
sed -i.tmp 's/^/ /' ${TMP_DEVFILE} && rm -f "${TMP_DEVFILE}.tmp"

for image in "${IMAGES_LIST[@]}"; do
#debug mode: stop after one iteration
[[ ${DEBUG} -eq 1 && ${total_count} == 1 ]] && continue
log -e "\n${BLUE}Begin test of ${devfile_url} with ${image}${NC}"
log "\n${BLUE}Begin test of ${devfile_url} with ${image}${NC}"
((total_count++))
# Modify DevWorkspace template
# Goal is to apply a devworkspace resource to the cluster,
Expand Down Expand Up @@ -311,20 +323,20 @@ for devfile_url in "${DEVFILE_URL_LIST[@]}"; do
count=$((count+1))
done
if [ ${state} == "Running" ]; then
log -e "\n${GREEN}${DEVWORKSPACE_NAME} is Running${NC}"
log "\n${GREEN}${DEVWORKSPACE_NAME} is Running${NC}"
else
log -e "\n${YELLOW}${DEVWORKSPACE_NAME} failed to start${NC}"
echo "TEST ${devfile_url} with ${image} FAILED ❌"
log "\n${YELLOW}${DEVWORKSPACE_NAME} failed to start${NC}"
echo "TEST [${total_count}/${total_tests}] ${devfile_url} with ${image} FAILED ❌"
failed_test+=("Devfile '$devfile_url' using image '$image'")
continue
fi
log "Validating ${DEVWORKSPACE_NAME} .."
validate_devworkspace ${devfile_url}
if [ $? -eq 0 ]; then
echo "TEST ${devfile_url} with ${image} PASSED ✅"
echo "TEST [${total_count}/${total_tests}] ${devfile_url} with ${image} PASSED ✅"
((success_count++))
else
echo "TEST ${devfile_url} with ${image} FAILED ❌"
echo "TEST [${total_count}/${total_tests}] ${devfile_url} with ${image} FAILED ❌"
failed_test+=("Devfile '$devfile_url' using image '$image'")
fi
sleep 1s
Expand Down Expand Up @@ -354,7 +366,7 @@ if [ ${DEBUG} -eq 0 ]; then
else
EXTRA_MSG=""
[ -n "${PR_NUMBER}" ] && EXTRA_MSG="\nTemporary editor definition file (${TMP_EDITOR_DEF}) not deleted\nTemporary devworkspace template file (${TMP_DWT}) not deleted\nRemote DevworkspaceTemplate (${EDITOR_DWT_NAME}) not deleted"
log -e "\n${YELLOW}Debug mode:${NC}\nRemote Devworkspace (${DEVWORKSPACE_NAME}) not deleted${DWT_MSG}\nTemporary devfile file ($TMP_DEVFILE) not deleted\nTemporary devworkspace file ($TMP_DEVWORKSPACE) not deleted${EXTRA_MSG}\nPlease delete remote workspaces if not needed anymore."
log "\n${YELLOW}Debug mode:${NC}\nRemote Devworkspace (${DEVWORKSPACE_NAME}) not deleted${DWT_MSG}\nTemporary devfile file ($TMP_DEVFILE) not deleted\nTemporary devworkspace file ($TMP_DEVWORKSPACE) not deleted${EXTRA_MSG}\nPlease delete remote Devworkspace if not needed anymore."
fi

# Calculate elapsed time
Expand Down
2 changes: 1 addition & 1 deletion samples/samples.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/che-samples/web-nodejs-sample.git
https://github.com/che-samples/web-nodejs-sample
26 changes: 22 additions & 4 deletions settings/settings-jetbrains.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,31 @@ validate_devworkspace() {

resolve_devworkspace_pod || return 1

log "Waiting for response .."
# Access the landing page
oc port-forward -n ${DEVWORKSPACE_NS} ${podName} ${LANDING_PAGE_PORT}:${LANDING_PAGE_PORT} &
sleep 3s
response=$(curl -s -o /dev/null -w "%{http_code}" "127.0.0.1:${LANDING_PAGE_PORT}")
if [ ${VERBOSE} -eq 0 ]; then
oc port-forward -n ${DEVWORKSPACE_NS} ${podName} ${LANDING_PAGE_PORT}:${LANDING_PAGE_PORT} &>/dev/null &
else
oc port-forward -n ${DEVWORKSPACE_NS} ${podName} ${LANDING_PAGE_PORT}:${LANDING_PAGE_PORT} &
fi
PORT_FORWARD_PID=$!

response="000"
count=0
while [ "${response}" != "200" ] && [ ${count} -lt ${TIMEOUT} ]; do
Copy link
Copy Markdown
Contributor

@adietish adietish Jun 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, good improvement: it keeps trying unless response is 200.
But then, if I get this right, it would also do 120 attemps: TIMEOUT is 120, comment says it's seconds. The check counts the attempts though and turns false once count TIMEOUT.
Wrong?

Copy link
Copy Markdown
Collaborator Author

@sbouchet sbouchet Jun 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it will attempt 120 times before failling. i'm using the same timeout as for waiting on the pod to be in running state.
notice the sleep time ( 1s ) so 120 attempts is indeed nearly that amount of time :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, still a bit odd to read "do while the number of attempts is lower than the timeout in seconds" 😄
This complaint is more in the realm of nitpicks anyhow.

sleep 1s
response=$(curl -s -o /dev/null -w "%{http_code}" "127.0.0.1:${LANDING_PAGE_PORT}")
count=$((count+1))
[ "${response}" != "000" ] && break
log -n "."
done
log "response: ${response}"

# Terminate oc-port-forward
kill "%1"
kill ${PORT_FORWARD_PID} 2>/dev/null
wait ${PORT_FORWARD_PID} 2>/dev/null
sleep 1s

if [ "${response}" == "200" ]; then
# pass
return 0
Expand Down
2 changes: 1 addition & 1 deletion verify_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ while IFS= read -r image; do
((total_count++))
echo "Checking [$total_count]: $image"

if skopeo inspect --retry-times 2 "docker://$image" > /dev/null 2>&1; then
if skopeo inspect --no-tags --retry-times 2 "docker://$image" > /dev/null 2>&1; then
((success_count++))
else
failed_images+=("$image")
Expand Down