[php-src] PHP-8.4: CI: Fix flacky ext\curl\tests\curl_setopt_ssl.phpt (#23944)
| From: | Weilin Du via GitHub | Date: | Mon, 28 Sep 2026 16:24:39 +0000 |
| Subject: | [php-src] PHP-8.4: CI: Fix flacky ext\curl\tests\curl_setopt_ssl.phpt (#23944) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141630@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-09-29T00:24:36+08:00
Commit: https://github.com/php/php-src/commit/1f1790940a4d45ed1f9d3d91a92046c2e45d3345
Raw diff: https://github.com/php/php-src/commit/1f1790940a4d45ed1f9d3d91a92046c2e45d3345.diff
CI: Fix flacky ext\curl\tests\curl_setopt_ssl.phpt (#23944)
Sometimes, 1 sec in not enough for the service to start.
This test is flacky because of this in my server, also in gh CI:
https://github.com/php/php-src/actions/runs/36204765497/job/108298870351
Changed paths:
M ext/curl/tests/curl_setopt_ssl.phpt
Diff:
diff --git a/ext/curl/tests/curl_setopt_ssl.phpt b/ext/curl/tests/curl_setopt_ssl.phpt
index e3b97a3ea732..cc152c9f4f1b 100644
--- a/ext/curl/tests/curl_setopt_ssl.phpt
+++ b/ext/curl/tests/curl_setopt_ssl.phpt
@@ -73,8 +73,24 @@ if ($process === false) {
die('failed to start server');
}
try {
- // Give the server time to start
- sleep(1);
+ // Wait until OpenSSL is actually listening before making the first request.
+ $ready = false;
+ for ($i = 0; $i < 100; $i++) {
+ $connection = @stream_socket_client("tcp://127.0.0.1:$port", $errno, $errstr,
0.05);
+ if ($connection !== false) {
+ fclose($connection);
+ $ready = true;
+ break;
+ }
+ if (!proc_get_status($process)['running']) {
+ break;
+ }
+ usleep(50000);
+ }
+ if (!$ready) {
+ stream_set_blocking($pipes[2], false);
+ throw new RuntimeException('OpenSSL server did not start: ' .
trim(stream_get_contents($pipes[2])));
+ }
echo "case 1: client cert and key from string\n";
$ch = curl_init("https://127.0.0.1:$port/");