@@ -172,16 +172,34 @@ startIDE() {
172172 # Wait for the IDE to come up.
173173 echo -e " \n$( ${currentTime[@]} ) : INFO: Waiting for the Intellij IDE to start..."
174174 callLivenessEndpoint=(curl -s http://localhost:8082)
175+ # Initialize counters and configuration
175176 count=1
176- while ! ${callLivenessEndpoint[@]} | grep -qF ' div' ; do # search for any amount of html from the IDE
177- if [ $count -eq 24 ]; then
177+ sleepInterval=5 # Wait interval (in seconds) between retries
178+ maxRetries=24 # Maximum number of attempts before timing out (24 retries × 5 seconds = 2 minutes total wait time)
179+
180+ # Keep checking IntelliJ's liveness endpoint until it responds successfully
181+ while ! ${callLivenessEndpoint[@]} | grep -qF ' div' ; do
182+ # If the maximum number of retries has been reached, handle timeout
183+ if [ $count -eq $maxRetries ]; then
178184 echo -e " \n$( ${currentTime[@]} ) : ERROR: Timed out waiting for the Intellij IDE to start. Output:"
179185 gatherDebugData $( pwd)
180186 cleanupCustomWLPDir
181187 exit 12
182188 fi
183- count=` expr $count + 1`
184- echo -e " \n$( ${currentTime[@]} ) : INFO: Continue waiting for the Intellij IDE to start..." && sleep 5
189+ # Increment attempt counter
190+ count=$(( count + 1 ))
191+ echo -e " \n$( ${currentTime[@]} ) : INFO: Continue waiting for IntelliJ IDE to start... (Attempt: $count /$maxRetries )"
192+
193+ # Dynamically extend timeout if downloads are detected in the log
194+ if tail -n 50 remoteServer.log | grep -qiE " (downloading|download.*from)" ; then
195+ if [ $maxRetries -lt 60 ]; then # Prevent extending timeout beyond 60 retries (5 minutes total)
196+ echo -e " $( ${currentTime[@]} ) : INFO: IntelliJ is downloading dependencies... extending wait time by 4 retries."
197+ maxRetries=$(( maxRetries + 4 )) # Extending timeout: +4 retries × 5s each = +20 seconds total wait time
198+ fi
199+ fi
200+
201+ # Wait before the next retry
202+ sleep $sleepInterval
185203 done
186204 if [[ $OS == " MINGW64_NT" * ]]; then
187205 # On Windows ps -ef only shows the processes for the current user (i.e. 3-4 processes)
@@ -240,9 +258,15 @@ main() {
240258 for restartCount in {1..5}; do
241259 startIDE
242260 # Run the tests
243- echo -e " \n$( ${currentTime[@]} ) : INFO: Running tests..."
244261 set -o pipefail # using tee requires we use this setting to gather the rc of gradlew
245- ./gradlew test -PuseLocal=$USE_LOCAL_PLUGIN | tee " $JUNIT_OUTPUT_TXT "
262+ if [ -n " $TEST_CLASS " ]; then
263+ echo -e " \n$( ${currentTime[@]} ) : INFO: Running specific test class: $TEST_CLASS "
264+ test_args=(--tests " $TEST_CLASS " )
265+ else
266+ echo -e " \n$( ${currentTime[@]} ) : INFO: Running all tests..."
267+ test_args=()
268+ fi
269+ ./gradlew test " ${test_args[@]} " -PuseLocal=" $USE_LOCAL_PLUGIN " | tee " $JUNIT_OUTPUT_TXT "
246270 testRC=$? # gradlew test only returns 0 or 1, not the return code from JUnit
247271 set +o pipefail # reset this option
248272 grep -i " SocketTimeoutException" " $JUNIT_OUTPUT_TXT " && testRC=23
0 commit comments