diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index dad78c3..a5f5a41 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -131,6 +131,9 @@ jobs: sed -i "s/'db-password' => '123123q'/'db-password' => 'password'/" etc/install-config-mysql.php.dist sed -i "s/'elasticsearch-host' => 'localhost'/'elasticsearch-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist sed -i "s/'amqp-host' => 'localhost'/'amqp-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist + sed -i "s/'consumers-wait-for-messages' => '0'/'consumers-wait-for-messages' => '1'/" etc/install-config-mysql.php.dist + mkdir etc/di/preferences/cli + cp ../../../vendor/mage-os/mageos-async-events/Test/_files/ce.php ./etc/di/preferences/cli - run: ../../../vendor/bin/phpunit ../../../vendor/mage-os/mageos-async-events/Test/Integration working-directory: ../magento2/dev/tests/integration diff --git a/Test/Integration/EventRetryTest.php b/Test/Integration/EventRetryTest.php index 72a488a..92f01ed 100644 --- a/Test/Integration/EventRetryTest.php +++ b/Test/Integration/EventRetryTest.php @@ -22,12 +22,12 @@ class EventRetryTest extends TestCase /** @var PublisherInterface|null */ private ?PublisherInterface $publisher; - /** @var PublisherConsumerController|null */ - private ?PublisherConsumerController $publisherConsumerController; - /** @var Json|null */ private ?Json $json; + /** @var ResourceConnection|null */ + private ?ResourceConnection $connection; + protected function setUp(): void { Bootstrap::getObjectManager()->configure([ @@ -54,7 +54,6 @@ protected function setUp(): void * * @magentoDataFixture MageOS_AsyncEvents::Test/_files/http_async_events.php * @magentoDbIsolation disabled - * @magentoConfigFixture default/system/async_events/max_deaths 3 */ public function testRetry() { @@ -68,18 +67,23 @@ public function testRetry() ] ); - $this->publisherConsumerController = Bootstrap::getObjectManager()->create( + $consumerInitParams = Bootstrap::getInstance()->getAppInitParams(); + + $consumerInitParams['TESTS_BASE_DIR'] = INTEGRATION_TESTS_DIR; + $consumerInitParams['INTEGRATION_TESTS_CLI_AUTOLOADER'] = INTEGRATION_TESTS_DIR . '/framework/autoload.php'; + + $publisherConsumerController = Bootstrap::getObjectManager()->create( PublisherConsumerController::class, [ 'consumers' => ['event.trigger.consumer', 'event.retry.consumer'], 'logFilePath' => TESTS_TEMP_DIR . "/MessageQueueTestLog.txt", 'maxMessages' => 10, - 'appInitParams' => Bootstrap::getInstance()->getAppInitParams() + 'appInitParams' => $consumerInitParams ] ); try { - $this->publisherConsumerController->startConsumers(); + $publisherConsumerController->startConsumers(); sleep(16); } catch (EnvironmentPreconditionException $e) { $this->markTestSkipped($e->getMessage()); @@ -88,7 +92,7 @@ public function testRetry() $e->getMessage() ); } finally { - $this->publisherConsumerController->stopConsumers(); + $publisherConsumerController->stopConsumers(); } $table = $this->connection->getTableName('async_event_subscriber_log'); @@ -100,8 +104,10 @@ public function testRetry() $events = $connection->fetchAll($select); + $this->assertNotEmpty($events); + foreach ($events as $event) { - // An uuid batch should be retired for 3 times after the first attempt. 1 + 3 + // A batch should be retired for 3 times after the first attempt. 1 + 3 $this->assertEquals(4, $event['events']); } } diff --git a/Test/_files/ce.php b/Test/_files/ce.php new file mode 100644 index 0000000..665a33b --- /dev/null +++ b/Test/_files/ce.php @@ -0,0 +1,9 @@ + \MageOS\AsyncEvents\Test\Integration\TestConfig::class +]; diff --git a/Test/_files/http_async_events.php b/Test/_files/http_async_events.php index fc5896a..1d05bb8 100644 --- a/Test/_files/http_async_events.php +++ b/Test/_files/http_async_events.php @@ -11,7 +11,7 @@ $connection->insertOnDuplicate('async_event_subscriber', [ 'subscription_id' => 1, 'event_name' => 'example.event', - 'recipient_url' => 'https://mock.codes/500', + 'recipient_url' => 'https://mock.codes/503', 'status' => 1, 'metadata' => 'http', 'verification_token' => 'secret',