Skip to content

Commit 19df1cd

Browse files
Copilottorosent
andcommitted
Fix DTS emulator connectivity with proper health check loop
Replace fixed 10-second sleep with a robust health check that: - Actively polls port 4001 using nc until the emulator is ready - Allows up to 60 seconds for the emulator to start - Provides better error diagnostics if startup fails - Adds 5 extra seconds after port is open for gRPC initialization Co-authored-by: torosent <[email protected]>
1 parent 5080337 commit 19df1cd

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

.github/workflows/build-validation.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,29 @@ jobs:
8181
run: docker run --name durabletask-emulator -p 4001:8080 -d mcr.microsoft.com/dts/dts-emulator:latest
8282

8383
- name: Display Durable Task Emulator Logs
84-
run: nohup docker logs --since=0 durabletask-emulator > durabletask-emulator.log 2>&1 &
84+
run: nohup docker logs -f durabletask-emulator > durabletask-emulator.log 2>&1 &
8585

86-
# wait for 10 seconds, so sidecar container can be fully up, this will avoid intermittent failing issues for integration tests causing by failed to connect to sidecar
87-
- name: Wait for 10 seconds
88-
run: sleep 10
86+
- name: Wait for Durable Task Emulator to be ready
87+
run: |
88+
echo "Waiting for Durable Task Emulator to be ready on port 4001..."
89+
max_attempts=60
90+
attempt=0
91+
while ! nc -z localhost 4001 2>/dev/null; do
92+
attempt=$((attempt + 1))
93+
if [ $attempt -ge $max_attempts ]; then
94+
echo "ERROR: Emulator not ready after $max_attempts seconds"
95+
echo "Docker container status:"
96+
docker ps -a
97+
echo "Container logs:"
98+
docker logs durabletask-emulator 2>&1 | tail -50
99+
exit 1
100+
fi
101+
echo "Attempt $attempt/$max_attempts - waiting for emulator..."
102+
sleep 1
103+
done
104+
echo "Durable Task Emulator is ready on port 4001"
105+
# Give additional time for gRPC service to fully initialize after port is open
106+
sleep 5
89107
90108
- name: Integration Tests with Gradle
91109
run: |

0 commit comments

Comments
 (0)