Skip to content

Commit b9ce5cf

Browse files
S-VINEETH-10anusreelakshmi934
authored andcommitted
Enhance: Fix intermittent failures in IntelliJ startup wait loop (OpenLiberty#1449)
1 parent ff7edd9 commit b9ce5cf

File tree

1 file changed

+22
-4
lines changed
  • src/test/resources/ci/scripts

1 file changed

+22
-4
lines changed

src/test/resources/ci/scripts/run.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

0 commit comments

Comments
 (0)