Skip to content

Commit 2738146

Browse files
committed
MC-19250: The stuck deployment on the Cloud because of consumers
1 parent b2dc8c5 commit 2738146

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

dev/tests/integration/testsuite/Magento/Framework/MessageQueue/UseCase/QueueTestCaseAbstract.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,22 @@ class QueueTestCaseAbstract extends \PHPUnit\Framework\TestCase
4747
*/
4848
protected $publisherConsumerController;
4949

50+
/**
51+
* @inheritdoc
52+
*/
5053
protected function setUp()
5154
{
5255
$this->objectManager = Bootstrap::getObjectManager();
5356
$this->logFilePath = TESTS_TEMP_DIR . "/MessageQueueTestLog.txt";
54-
$this->publisherConsumerController = $this->objectManager->create(PublisherConsumerController::class, [
55-
'consumers' => $this->consumers,
56-
'logFilePath' => $this->logFilePath,
57-
'maxMessages' => $this->maxMessages,
58-
'appInitParams' => \Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppInitParams()
59-
]);
57+
$this->publisherConsumerController = $this->objectManager->create(
58+
PublisherConsumerController::class,
59+
[
60+
'consumers' => $this->consumers,
61+
'logFilePath' => $this->logFilePath,
62+
'maxMessages' => $this->maxMessages,
63+
'appInitParams' => \Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppInitParams()
64+
]
65+
);
6066

6167
try {
6268
$this->publisherConsumerController->initialize();
@@ -70,6 +76,9 @@ protected function setUp()
7076
$this->publisher = $this->publisherConsumerController->getPublisher();
7177
}
7278

79+
/**
80+
* @inheritdoc
81+
*/
7382
protected function tearDown()
7483
{
7584
$this->publisherConsumerController->stopConsumers();
@@ -85,24 +94,32 @@ protected function waitForAsynchronousResult($expectedLinesCount, $logFilePath)
8594
{
8695
try {
8796
//$expectedLinesCount, $logFilePath
88-
$this->publisherConsumerController->waitForAsynchronousResult([$this, 'checkLogsExists'], [
89-
$expectedLinesCount, $logFilePath
90-
]);
97+
$this->publisherConsumerController->waitForAsynchronousResult(
98+
[$this, 'checkLogsExists'],
99+
[$expectedLinesCount, $logFilePath]
100+
);
91101
} catch (PreconditionFailedException $e) {
92102
$this->fail($e->getMessage());
93103
}
94104
}
95105

106+
/**
107+
* Checks that logs exist
108+
*
109+
* @param int $expectedLinesCount
110+
* @return bool
111+
*/
96112
public function checkLogsExists($expectedLinesCount)
97113
{
114+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
98115
$actualCount = file_exists($this->logFilePath) ? count(file($this->logFilePath)) : 0;
99116
return $expectedLinesCount === $actualCount;
100117
}
101118

102119
/**
103120
* Workaround for https://bugs.php.net/bug.php?id=72286
104121
*/
105-
public static function tearDownAfterClass()
122+
public function tearDownAfterClass()
106123
{
107124
if (version_compare(phpversion(), '7') == -1) {
108125
$closeConnection = new \ReflectionMethod(\Magento\Amqp\Model\Config::class, 'closeConnection');

dev/tests/integration/testsuite/Magento/Framework/MessageQueue/UseCase/WaitAndNotWaitMessagesTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,13 @@ class WaitAndNotWaitMessagesTest extends QueueTestCaseAbstract
2323
*/
2424
private $filesystem;
2525

26-
/**
27-
* @var ConfigFilePool
28-
*/
29-
private $configFilePool;
30-
3126
/**
3227
* @var array
3328
*/
3429
private $config;
3530

3631
/**
37-
* @var \Magento\TestModuleAsyncAmqp\Model\AsyncTestData
32+
* @var AsyncTestData
3833
*/
3934
protected $msgObject;
4035

0 commit comments

Comments
 (0)