#57306 closed defect (bug) (fixed)
External HTTP test failures
Reported by: | SergeyBiryukov | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.2 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | dev-feedback has-patch has-unit-tests fixed-major |
Focuses: | Cc: |
Description (last modified by )
Some external HTTP tests have recently started failing on all core commits
There were 2 failures: 1) Tests_HTTP_curl::test_multiple_location_headers Failed asserting that 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1&redirected=one' is of type "array". /var/www/tests/phpunit/tests/http/base.php:453 phpvfscomposer:///var/www/vendor/phpunit/phpunit/phpunit:60 2) Tests_HTTP_streams::test_multiple_location_headers Failed asserting that 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1&redirected=one' is of type "array". /var/www/tests/phpunit/tests/http/base.php:453 phpvfscomposer:///var/www/vendor/phpunit/phpunit/phpunit:60
The tests send a request to http://api.wordpress.org/core/tests/1.0/redirection.php and try to verify that multiple redirects are handled correctly. Some history here:
- [342/tests] added the initial tests.
- [874/tests] switch to running the redirection script from api.wordpress.org.
- [1329/tests] introduced the affected test.
I don't see any recent core changes that could cause those failures. The first failure was on [54949]. It appears that something has changed on the dotorg side that could have affected this, might have to do with updating nginx to 1.23.2 around the time of the first failure.
When running the tests locally, it looks like the redirection script on api.wordpress.org no longer sends the second header it's supposed to send:
if ( ! isset( $_GET['redirected'] ) ) { header( "Location: $url?multiple-location-headers=1&redirected=one", false ); header( "Location: $url?multiple-location-headers=1&redirected=two", false ); exit; }
This assertion fails because the result is now a string with only the first redirect, not an array with both of them:
$this->assertIsArray( wp_remote_retrieve_header( $res, 'location' ) ); ... Failed asserting that 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1&redirected=one' is of type "array".
I have confirmed that the redirection script returns multiple Location
headers when run locally, but only one on api.wordpress.org. I suppose we can disable the affected test for now, but it will also fail on older branches, so the disabling will need to be backported all the way to 4.1.
Attachments (1)
Change History (64)
This ticket was mentioned in Slack in #meta by sergey. View the logs.
21 months ago
#4
in reply to:
↑ 3
@
21 months ago
Replying to costdev:
Would it be possible to disable the affected test on
trunk
for now, and leave it a few days or so before backporting to the older branches in case we get a fix on the dotorg side?
Yes, that makes sense to me. Thanks for the patch!
#7
follow-ups:
↓ 8
↓ 11
@
21 months ago
Is it possible to test the method directly rather than rely on wordpress.org?
It's pretty rough but I am thinking of something like this with the test moved out of the external-http group.
<?php public function test_multiple_location_headers() { // Filter the response made by WP_HTTP::handle_redirects(). add_filter( 'pre_http_request', function( $response, $args, $url ) { // Assert the redirect URL is correct. $this->assertSame( $url, 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1&redirected=two' ); return array( 'headers' => array(), 'body' => 'PASS', 'response' => array( 'code' => 200, 'message' => 'OK', ), 'cookies' => array(), 'filename' => null, ); }, 10, 3 ); $args = array( 'timeout' => 30, '_redirection' => 3, 'redirection' => 2, 'method' => 'GET', ); $headers = array( 'server' => 'nginx', 'date' => 'Sun, 11 Dec 2022 23:11:22 GMT', 'content-type' => 'text/html; charset=utf-8', 'location' => array( 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1&redirected=one', 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1&redirected=two', ), ); // Test the tests: ensure multiple locations are passed to WP_HTTP::handle_redirects(). $this->assertIsArray( $headers['location'] ); $this->assertCount( 2, $headers['location'] ); $response = WP_HTTP::handle_redirects( 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1', $args, array( 'headers' => $headers, 'body' => '', 'cookies' => array (), 'filename' => NULL, 'response' => array ( 'code' => 302, 'message' => 'Found', ), ) ); $this->assertSame( 'PASS', wp_remote_retrieve_body( $response ) ); }
It would still need to be backported.
#8
in reply to:
↑ 7
@
21 months ago
Replying to peterwilsoncc:
Is it possible to test the method directly rather than rely on wordpress.org?
This would be my preference too, even if it has to be back-ported.
As for the cause of the API starting to return differently, this was likely caused by the upgrade of nginx as noted, the nginx changelog lists multiple header-combining changes in 1.23.0.
This ticket was mentioned in PR #3738 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#9
- Keywords has-patch has-unit-tests added
#10
@
21 months ago
In the linked pull request
- test moved to
tests/phpunit/tests/http/http.php
- Largely the code above with a few coding standards fixes
- URLs changed to be more readable given the filter preempts the HTTP request
- Added an assertion to ensure the preempting filter runs
- It now only covers the WP_Http method, it does not cover wp_remote_verb function independently.
It looks like a few paths in the method are currently untested but I've not concerned myself with that as the purpose of the PR is to get the exiting test passing and validating the multiple location headers use-case without needing an external HTTP request.
#11
in reply to:
↑ 7
@
21 months ago
Replying to peterwilsoncc:
Is it possible to test the method directly rather than rely on wordpress.org?
Yeah, that was my thinking too. Thanks for the PR!
Replying to dd32:
As for the cause of the API starting to return differently, this was likely caused by the upgrade of nginx as noted, the nginx changelog lists multiple header-combining changes in 1.23.0.
Indeed, this one appears to be the most relevant here:
Changes with nginx 1.23.0 21 Jun 2022 ... *) Change: now nginx combines arbitrary header lines with identical names when sending to FastCGI, SCGI, and uwsgi backends, in the $r->header_in() method of the ngx_http_perl_module, and during lookup of the "$http_...", "$sent_http_...", "$sent_trailer_...", "$upstream_http_...", and "$upstream_trailer_..." variables.
This ticket was mentioned in Slack in #core by sergey. View the logs.
21 months ago
#14
@
21 months ago
- Keywords fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for backporting to all the branches.
@peterwilsoncc commented on PR #3738:
21 months ago
#15
This ticket was mentioned in Slack in #core by sergey. View the logs.
21 months ago
This ticket was mentioned in PR #3750 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#17
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
Trac ticket:
This ticket was mentioned in PR #3751 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#18
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
Trac ticket:
This ticket was mentioned in PR #3752 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#19
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
Trac ticket:
This ticket was mentioned in PR #3751 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#20
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
Trac ticket:
This ticket was mentioned in PR #3761 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#21
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
# tests/phpunit/tests/http/http.php
Trac ticket:
This ticket was mentioned in PR #3762 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#22
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
# tests/phpunit/tests/http/http.php
Trac ticket:
This ticket was mentioned in PR #3763 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#23
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
# tests/phpunit/tests/http/http.php
Trac ticket:
This ticket was mentioned in PR #3764 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#24
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
# tests/phpunit/tests/http/http.php
Trac ticket:
This ticket was mentioned in PR #3765 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#25
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
# tests/phpunit/tests/http/http.php
Trac ticket:
This ticket was mentioned in PR #3766 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#26
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
# tests/phpunit/tests/http/http.php
Trac ticket:
This ticket was mentioned in PR #3767 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#27
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
# tests/phpunit/tests/http/http.php
Trac ticket:
This ticket was mentioned in PR #3768 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#28
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
Trac ticket:
This ticket was mentioned in PR #3769 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#29
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
Trac ticket:
This ticket was mentioned in PR #3770 on WordPress/wordpress-develop by @peterwilsoncc.
21 months ago
#30
Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects()
.
This refactors and reenables an existing test to call the WP_HTTP::handle_redirects()
method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
# Conflicts:
# tests/phpunit/tests/http/base.php
Trac ticket:
@peterwilsoncc commented on PR #3770:
21 months ago
#31
Merged to 6.1.
@peterwilsoncc commented on PR #3769:
21 months ago
#33
Merged to 6.0.
@peterwilsoncc commented on PR #3768:
21 months ago
#34
Merged to 5.9.
@peterwilsoncc commented on PR #3767:
21 months ago
#36
Merged to 5.8.
@peterwilsoncc commented on PR #3766:
21 months ago
#38
Merged to 5.7.
@peterwilsoncc commented on PR #3765:
21 months ago
#40
Merged to 5.6.
@peterwilsoncc commented on PR #3764:
21 months ago
#42
Merged to 5.5.
@peterwilsoncc commented on PR #3763:
21 months ago
#44
Merged to 5.4.
@peterwilsoncc commented on PR #3762:
21 months ago
#46
Merged to 5.3.
@peterwilsoncc commented on PR #3761:
21 months ago
#48
Merged to 5.2.
@peterwilsoncc commented on PR #3752:
21 months ago
#58
Merged to 4.3.
@peterwilsoncc commented on PR #3751:
21 months ago
#60
Merged to 4.2.
@peterwilsoncc commented on PR #3750:
21 months ago
#62
Merged to 4.1.
As we don't have confirmation on the exact cause yet, disabling the affected test seems appropriate so that builds/PRs pass CI.
Would it be possible to disable the affected test on
trunk
for now, and leave it a few days or so before backporting to the older branches in case we get a fix on the dotorg side?