Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the SocketTimeoutException is detected, restart testing #1130

Merged
merged 2 commits into from
Nov 29, 2024
Merged
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
53 changes: 29 additions & 24 deletions src/test/resources/ci/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ startIDE() {
echo -e "\n$(${currentTime[@]}): INFO: Waiting for the Intellij IDE to start..."
callLivenessEndpoint=(curl -s http://localhost:8082)
count=1
while ! ${callLivenessEndpoint[@]} | grep -qF 'Welcome to IntelliJ IDEA'; do
while ! ${callLivenessEndpoint[@]} | grep -qF 'div'; do # search for any amount of html from the IDE
if [ $count -eq 24 ]; then
echo -e "\n$(${currentTime[@]}): ERROR: Timed out waiting for the Intellij IDE Welcome Page to start. Output:"
echo -e "\n$(${currentTime[@]}): ERROR: Timed out waiting for the Intellij IDE to start. Output:"
gatherDebugData $(pwd)
exit 12
fi
Expand Down Expand Up @@ -190,30 +190,35 @@ main() {
fi

export JUNIT_OUTPUT_TXT="$currentLoc"/build/junit.out
startIDE
# Run the tests
echo -e "\n$(${currentTime[@]}): INFO: Running tests..."
set -o pipefail # using tee requires we use this setting to gather the rc of gradlew
./gradlew test -PuseLocal=$USE_LOCAL_PLUGIN | tee "$JUNIT_OUTPUT_TXT"
testRC=$? # gradlew test only returns 0 or 1, not the return code from JUnit
set +o pipefail # reset this option
grep -i "SocketTimeoutException" "$JUNIT_OUTPUT_TXT" && testRC=23
if [ "$testRC" -eq 23 ]; then
# rc = 23 means SocketTimeoutException detected, kill the IDE and try again
if [[ $OS == "MINGW64_NT"* ]]; then
kill -n 1 $IDE_PID
sleep 5
kill -n 9 $IDE_PID
sleep 5
ps -ef # display all user processes
for restartCount in {1..5}; do
startIDE
# Run the tests
echo -e "\n$(${currentTime[@]}): INFO: Running tests..."
set -o pipefail # using tee requires we use this setting to gather the rc of gradlew
./gradlew test -PuseLocal=$USE_LOCAL_PLUGIN | tee "$JUNIT_OUTPUT_TXT"
testRC=$? # gradlew test only returns 0 or 1, not the return code from JUnit
set +o pipefail # reset this option
grep -i "SocketTimeoutException" "$JUNIT_OUTPUT_TXT" && testRC=23
if [ "$testRC" -eq 23 ]; then
# rc = 23 means SocketTimeoutException detected, kill the IDE and try again
if [[ $OS == "MINGW64_NT"* ]]; then
kill -n 1 $IDE_PID
sleep 5
kill -n 9 $IDE_PID
sleep 5
ps -ef # display all user processes
else
kill -1 $IDE_PID # SIGHUP (hang up the phone)
sleep 5
kill -9 $IDE_PID # SIGKILL, in case the SIGHUP did not work
sleep 5
ps -f $IDE_PID # display whether the process is still there
fi
else
kill -1 $IDE_PID # SIGHUP (hang up the phone)
sleep 5
kill -9 $IDE_PID # SIGKILL, in case the SIGHUP did not work
sleep 5
ps -f $IDE_PID # display whether the process is still there
# Success or failure, if it is not SocketTimeoutException then exit and report results
break;
fi
fi
done

# If there were any errors, gather some debug data before exiting.
if [ "$testRC" -ne 0 ]; then
Expand Down