From 9b0819485c1921d5e95a8fbd73149f3403090d45 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Fri, 22 Oct 2021 11:47:29 +0300 Subject: [PATCH] Fix random ProcessManagerTest failures Skip the test in case of the following error: Warning: pcntl_fork(): Error 12 This happened when there was not enough memory to fork: https://stackoverflow.com/q/2420606/1839611 --- .../Indexer/Test/Unit/Model/ProcessManagerTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/code/Magento/Indexer/Test/Unit/Model/ProcessManagerTest.php b/app/code/Magento/Indexer/Test/Unit/Model/ProcessManagerTest.php index 9e9d2a5c81aba..8cc8bbd5f96b1 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/ProcessManagerTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/ProcessManagerTest.php @@ -35,6 +35,10 @@ public function testFailureInChildProcessHandleMultiThread(array $userFunctions, $processManager->execute($userFunctions); $this->fail('Exception was not handled'); } catch (\RuntimeException $exception) { + if (false !== strpos($exception->getMessage(), 'Warning: pcntl_fork(): Error 12')) { + $this->markTestSkipped('Cannot allocate memory during running pcntl_fork'); + } + $this->assertEquals('Fail in child process', $exception->getMessage()); } } @@ -117,6 +121,10 @@ public function testSuccessChildProcessHandleMultiThread(array $userFunctions, i try { $processManager->execute($userFunctions); } catch (\RuntimeException $exception) { + if (false !== strpos($exception->getMessage(), 'Warning: pcntl_fork(): Error 12')) { + $this->markTestSkipped('Cannot allocate memory during running pcntl_fork'); + } + $this->fail('Exception was not handled'); } }