-
Notifications
You must be signed in to change notification settings - Fork 8.1k
ext/curl: speed up tests #23228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
ext/curl: speed up tests #23228
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -74,7 +74,10 @@ if ($process === false) { | |||||
| } | ||||||
| try { | ||||||
| // Give the server time to start | ||||||
| sleep(1); | ||||||
| for ($i = 0; $i < 100; $i++) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Maybe 50 is enough? Would match the previous 1s;
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, 50 (or even 10 or 20) would work. 100 is just a number that's high but not infinite. In normal operation this loop will only iterate a couple of times, and 50 or 100 is never reached. If you are worried about the time this test takes when the server fails to start, perhaps a better way is to get the server process status with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was just a nit; wouldn't over-complicate it personally. A server not starting would die out before we arrive here. It's rather for slower envs -- git history related to the server mentions some Travis CI (and other) edge cases. As you said, normally the max should not be hit -- since the 1s didn't flake 50ish is perhaps just fine. |
||||||
| if (@fsockopen('127.0.0.1', $port)) break; | ||||||
| usleep(20000); | ||||||
| } | ||||||
|
|
||||||
| echo "case 1: client cert and key from string\n"; | ||||||
| $ch = curl_init("https://127.0.0.1:$port/"); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,8 +15,8 @@ function curl_cli_server_start() { | |
| // First, wait for the dev server to declare itself ready. | ||
| $bound = null; | ||
| stream_set_blocking($pipes[2], false); | ||
| for ($i = 0; $i < 60; $i++) { | ||
| usleep(50000); // 50ms per try | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here both retry loops keep $i < 60 while the sleep goes 50ms → 20ms, so each wait budget quietly drops from 3s to 1.2s.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I thought that was fine when I made it, but when I looked some more into it I saw that #2304 specifically increased the timeout to 3 seconds, so I increased the loop count to 150 in this PR to keep the 3 second timeout. |
||
| for ($i = 0; $i < 150; $i++) { | ||
| usleep(20000); // 20ms per try | ||
| $status = proc_get_status($handle); | ||
| if (empty($status['running'])) { | ||
| echo "Server is not running\n"; | ||
|
|
@@ -44,8 +44,7 @@ function curl_cli_server_start() { | |
| // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' | ||
| // it might not be listening yet...need to wait until fsockopen() call returns | ||
| $error = "Unable to connect to server\n"; | ||
| for ($i=0; $i < 60; $i++) { | ||
| usleep(50000); // 50ms per try | ||
| for ($i=0; $i < 150; $i++) { | ||
| $status = proc_get_status($handle); | ||
| $fp = @fsockopen("tcp://$bound"); | ||
| // Failure, the server is no longer running | ||
|
|
@@ -58,6 +57,7 @@ function curl_cli_server_start() { | |
| $error = ''; | ||
| break; | ||
| } | ||
| usleep(20000); // 20ms per try | ||
| } | ||
|
|
||
| if ($fp) { | ||
|
|
@@ -74,12 +74,12 @@ function curl_cli_server_start() { | |
| function($handle) { | ||
| proc_terminate($handle); | ||
| /* Wait for server to shutdown */ | ||
| for ($i = 0; $i < 60; $i++) { | ||
| for ($i = 0; $i < 150; $i++) { | ||
| $status = proc_get_status($handle); | ||
| if (!($status && $status['running'])) { | ||
| break; | ||
| } | ||
| usleep(50000); | ||
| usleep(20000); | ||
| } | ||
| }, | ||
| $handle | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask where the 1 second delay come from?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expect 100-continue is a flow control mechanism that is apparently not supported by the PHP development server. Curl waits one second for a 100-continue response and then continues anyway.
https://everything.curl.dev/http/post/expect100.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP development server does not support Expect 100-continue flow control · Issue #23242 · php/php-src