Skip to content

Commit c0d9e1a

Browse files
author
Bohdan Korablov
committed
MAGETWO-93161: Fix Problems with Consumer Runners on Cloud Clusters
1 parent 0a99a38 commit c0d9e1a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

dev/tests/integration/testsuite/Magento/MessageQueue/Model/Cron/ConsumersRunnerTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function testCheckThatPidFilesWasCreated()
130130
public function testSpecificConsumerAndRerun()
131131
{
132132
$specificConsumer = 'quoteItemCleaner';
133-
$pidFilePath = $specificConsumer . ConsumersRunner::PID_FILE_EXT;
133+
$pidFilePath = $this->getPidFileName($specificConsumer);
134134
$config = $this->config;
135135
$config['cron_consumers_runner'] = ['consumers' => [$specificConsumer], 'max_messages' => 0];
136136

@@ -228,7 +228,7 @@ private function writeConfig(array $config)
228228
private function getPidFileFullPath($consumerName)
229229
{
230230
$directoryList = $this->objectManager->get(DirectoryList::class);
231-
return $directoryList->getPath(DirectoryList::VAR_DIR) . '/' . $consumerName . ConsumersRunner::PID_FILE_EXT;
231+
return $directoryList->getPath(DirectoryList::VAR_DIR) . '/' . $this->getPidFileName($consumerName);
232232
}
233233

234234
/**
@@ -239,7 +239,7 @@ protected function tearDown()
239239
foreach ($this->consumerConfig->getConsumers() as $consumer) {
240240
$consumerName = $consumer->getName();
241241
$pidFileFullPath = $this->getPidFileFullPath($consumerName);
242-
$pidFilePath = $consumerName . ConsumersRunner::PID_FILE_EXT;
242+
$pidFilePath = $this->getPidFileName($consumerName);
243243
$pid = $this->pid->getPid($pidFilePath);
244244

245245
if ($pid && $this->pid->isRun($pidFilePath)) {
@@ -258,4 +258,15 @@ protected function tearDown()
258258
$this->writeConfig($this->config);
259259
$this->appConfig->reinit();
260260
}
261+
262+
/**
263+
* @param string $consumerName The consumers name
264+
* @return string The name to file with PID
265+
*/
266+
private function getPidFileName($consumerName)
267+
{
268+
$sanitizedHostname = preg_replace('/[^a-z0-9]/i', '', gethostname());
269+
270+
return $consumerName . '-' . $sanitizedHostname . ConsumersRunner::PID_FILE_EXT;
271+
}
261272
}

0 commit comments

Comments
 (0)