Skip to content

Commit eb25bb1

Browse files
committed
Fix smoke test timeout detection to work again
.NET Core 2.1 and 3.1 use separate strings of text to indicate that the application is running. Both include this text, though: Application started. Press Ctrl+C to shut down. Update the timeout detection logic to be more flexible and catch this line of text anywhere in the output, not just in the last line. This brings the timeout for some of these test runs down from 30 seconds to 2 or 3 seconds. Fixes: #1655
1 parent d896918 commit eb25bb1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

smoke-test.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,26 @@ function doCommand() {
212212
"${dotnetCmd}" $newArgs --no-restore >> "$logFile" 2>&1
213213
fi
214214
elif [[ "$1" == "run" && "$proj" =~ ^(web|mvc|webapi|razor)$ ]]; then
215+
# A separate log file that we will over-write all the time.
216+
exitLogFile="$testingDir/exitLogFile"
217+
echo > $exitLogFile
218+
# Run an application in the background and redirect its
219+
# stdout+stderr to a separate process (tee). The tee process
220+
# writes its input to 2 files:
221+
# - Either the normal log or stdout
222+
# - A log that's only used to find out when it's safe to kill
223+
# the application.
215224
if [ "$projectOutput" == "true" ]; then
216-
"${dotnetCmd}" $1 &
225+
"${dotnetCmd}" $1 2>&1 > >(tee -a "$exitLogFile") &
217226
else
218-
"${dotnetCmd}" $1 >> "$logFile" 2>&1 &
227+
"${dotnetCmd}" $1 2>&1 > >(tee -a "$logFile" "$exitLogFile" >/dev/null) &
219228
fi
220229
webPid=$!
221230
killCommand="pkill -SIGTERM -P $webPid"
222231
echo " waiting up to 30 seconds for web project with pid $webPid..."
223232
echo " to clean up manually after an interactive cancellation, run: $killCommand"
224233
for seconds in $(seq 30); do
225-
if [ "$(tail -n 1 "$logFile")" = 'Application started. Press Ctrl+C to shut down.' ]; then
234+
if grep 'Application started. Press Ctrl+C to shut down.' "$exitLogFile"; then
226235
echo " app ready for shutdown after $seconds seconds"
227236
break
228237
fi

0 commit comments

Comments
 (0)