Skip to content
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

Add a retry logic on some flaky tests that rely on httpbin #713

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/phpunit/helper-functions/GetFileOpenedAsBinaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public function test_file_opened_as_binary() {

$fh = edac_get_file_opened_as_binary( $file );

// since this external service can be flaky we try again if it fails.
if ( ! $fh ) {
$fh = edac_get_file_opened_as_binary( $file );
}

$this->assertNotFalse( $fh );
fclose( $fh );
}
Expand Down
9 changes: 7 additions & 2 deletions tests/phpunit/helper-functions/UrlExistsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ class UrlExistsTest extends WP_UnitTestCase {
* @group external-http
*/
public function test_url_exists() {
$url = 'https://httpbin.org/status/200';
$this->assertTrue( edac_url_exists( $url, 20 ) );
$url = 'https://httpbin.org/status/200';
$url_exists = edac_url_exists( $url, 10 );
// this test url is flaky, so we try again one extra time if it fails.
if ( ! $url_exists ) {
$url_exists = edac_url_exists( $url, 20 );
}
$this->assertTrue( $url_exists );
}

/**
Expand Down
Loading