From cd776fe0cfec482e421d41af2ed1dcd477f9fe18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Tue, 9 Feb 2021 10:07:38 +0100 Subject: [PATCH] Add tries when CronHelpes ping ends with timeout [MAILPOET-3413] --- tests/integration/Cron/CronHelperTest.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/integration/Cron/CronHelperTest.php b/tests/integration/Cron/CronHelperTest.php index eccf760780..99e30e67c1 100644 --- a/tests/integration/Cron/CronHelperTest.php +++ b/tests/integration/Cron/CronHelperTest.php @@ -317,8 +317,17 @@ class CronHelperTest extends \MailPoetTest { public function testItPingsDaemon() { if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped(); + + $pingResponse = null; + // because sometimes wp_remote_post ends with timeout we want to try three times + for ($i = 1; $i <= 3; $i++) { + $pingResponse = $this->cronHelper->pingDaemon(); + if (strpos('cURL error 28', $pingResponse) !== false) { + break; + } + } // raw response is returned - expect($this->cronHelper->pingDaemon())->equals(DaemonHttpRunner::PING_SUCCESS_RESPONSE); + expect($pingResponse)->equals(DaemonHttpRunner::PING_SUCCESS_RESPONSE); } public function testItValidatesPingResponse() {