Skip to content

Commit 79a4f33

Browse files
authored
Fix smoke test timeout detection to work again (#1985)
.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. This is a port of #1963 to master.
1 parent 29505f6 commit 79a4f33

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
@@ -213,17 +213,26 @@ function doCommand() {
213213
"${dotnetCmd}" $newArgs --no-restore >> "$logFile" 2>&1
214214
fi
215215
elif [[ "$1" == "run" && "$proj" =~ ^(web|mvc|webapi|razor|blazorwasm|blazorserver)$ ]]; then
216+
# A separate log file that we will over-write all the time.
217+
exitLogFile="$testingDir/exitLogFile"
218+
echo > $exitLogFile
219+
# Run an application in the background and redirect its
220+
# stdout+stderr to a separate process (tee). The tee process
221+
# writes its input to 2 files:
222+
# - Either the normal log or stdout
223+
# - A log that's only used to find out when it's safe to kill
224+
# the application.
216225
if [ "$projectOutput" == "true" ]; then
217-
"${dotnetCmd}" $1 &
226+
"${dotnetCmd}" $1 2>&1 > >(tee -a "$exitLogFile") &
218227
else
219-
"${dotnetCmd}" $1 >> "$logFile" 2>&1 &
228+
"${dotnetCmd}" $1 2>&1 > >(tee -a "$logFile" "$exitLogFile" >/dev/null) &
220229
fi
221230
webPid=$!
222231
killCommand="pkill -SIGTERM -P $webPid"
223232
echo " waiting up to 30 seconds for web project with pid $webPid..."
224233
echo " to clean up manually after an interactive cancellation, run: $killCommand"
225234
for seconds in $(seq 30); do
226-
if [ "$(tail -n 1 "$logFile")" = 'Application started. Press Ctrl+C to shut down.' ]; then
235+
if grep 'Application started. Press Ctrl+C to shut down.' "$exitLogFile"; then
227236
echo " app ready for shutdown after $seconds seconds"
228237
break
229238
fi

0 commit comments

Comments
 (0)