Skip to content

Commit 495f0e4

Browse files
committed
ci(showcase): replace hardcoded sleep 2 with deterministic Bash /dev/tcp readiness polling loop
1 parent 7f53653 commit 495f0e4

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

.github/workflows/showcase.yaml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@ jobs:
6565
./gapic-showcase run &
6666
# Start secure TLS showcase server on port 7470 for PQC TLS integration tests
6767
./gapic-showcase run --port 7470 --tls --ca-cert-output-file /tmp/showcase-ca.pem &
68-
sleep 2
68+
# Wait deterministically for both background showcase servers to finish binding ports 7469/7470
69+
# and writing /tmp/showcase-ca.pem. Starting TLS requires RSA key generation and disk I/O,
70+
# which can cause race conditions if tests start before /tmp/showcase-ca.pem is created.
71+
for i in $(seq 1 30); do
72+
if (echo > /dev/tcp/127.0.0.1/7469) 2>/dev/null && \
73+
(echo > /dev/tcp/127.0.0.1/7470) 2>/dev/null && \
74+
[ -f /tmp/showcase-ca.pem ]; then
75+
echo "Showcase servers (ports 7469, 7470) and CA cert ready in attempt $i."
76+
break
77+
fi
78+
sleep 0.2
79+
done
6980
cd -
7081
- name: Showcase integration tests
7182
working-directory: java-showcase
@@ -174,7 +185,18 @@ jobs:
174185
./gapic-showcase run &
175186
# Start secure TLS showcase server on port 7470 for PQC TLS integration tests
176187
./gapic-showcase run --port 7470 --tls --ca-cert-output-file /tmp/showcase-ca.pem &
177-
sleep 2
188+
# Wait deterministically for both background showcase servers to finish binding ports 7469/7470
189+
# and writing /tmp/showcase-ca.pem. Starting TLS requires RSA key generation and disk I/O,
190+
# which can cause race conditions if tests start before /tmp/showcase-ca.pem is created.
191+
for i in $(seq 1 30); do
192+
if (echo > /dev/tcp/127.0.0.1/7469) 2>/dev/null && \
193+
(echo > /dev/tcp/127.0.0.1/7470) 2>/dev/null && \
194+
[ -f /tmp/showcase-ca.pem ]; then
195+
echo "Showcase servers (ports 7469, 7470) and CA cert ready in attempt $i."
196+
break
197+
fi
198+
sleep 0.2
199+
done
178200
cd -
179201
- name: Showcase integration tests
180202
working-directory: java-showcase

0 commit comments

Comments
 (0)