From 6d82fecce1d0356c4921742648e8ec8f5ec09691 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Thu, 21 Nov 2024 17:42:09 -0500 Subject: [PATCH 1/2] If a SocketTimeoutException occurs restart the IDE and run the tests Signed-off-by: Paul Gooderham --- src/test/resources/ci/scripts/run.sh | 49 +++++++++++++++------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/test/resources/ci/scripts/run.sh b/src/test/resources/ci/scripts/run.sh index 04c28acfc..390e8d1c5 100755 --- a/src/test/resources/ci/scripts/run.sh +++ b/src/test/resources/ci/scripts/run.sh @@ -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 From 0e1eafcaf29413b1173721f39525d392981d53a7 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Thu, 21 Nov 2024 18:15:57 -0500 Subject: [PATCH 2/2] Watch for IDE to start with project already loaded Signed-off-by: Paul Gooderham --- src/test/resources/ci/scripts/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/ci/scripts/run.sh b/src/test/resources/ci/scripts/run.sh index 390e8d1c5..4e3979477 100755 --- a/src/test/resources/ci/scripts/run.sh +++ b/src/test/resources/ci/scripts/run.sh @@ -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