Skip to content

Fix random fails during parallel SCD execution #22886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/internal/Magento/Framework/View/Asset/LockerProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(Filesystem $filesystem)
*/
public function lockProcess($lockName)
{
if ($this->getState()->getMode() == State::MODE_PRODUCTION) {
if ($this->getState()->getMode() === State::MODE_PRODUCTION || PHP_SAPI === 'cli') {
return;
}

Expand All @@ -78,11 +78,12 @@ public function lockProcess($lockName)

/**
* @inheritdoc
*
* @throws FileSystemException
*/
public function unlockProcess()
{
if ($this->getState()->getMode() == State::MODE_PRODUCTION) {
if ($this->getState()->getMode() === State::MODE_PRODUCTION || PHP_SAPI === 'cli') {
return;
}

Expand Down Expand Up @@ -115,9 +116,10 @@ private function isProcessLocked()
}

/**
* Get name of lock file
* Get path to lock file
*
* @param string $name
*
* @return string
*/
private function getFilePath($name)
Expand All @@ -126,7 +128,10 @@ private function getFilePath($name)
}

/**
* Get State object
*
* @return State
*
* @deprecated 100.1.1
*/
private function getState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,6 @@ protected function setUp()
);
}

/**
* Test for lockProcess method
*
* @param string $method
*
* @dataProvider dataProviderTestLockProcess
*/
public function testLockProcess($method)
{
$this->stateMock->expects(self::once())->method('getMode')->willReturn(State::MODE_DEVELOPER);
$this->filesystemMock->expects(self::once())
->method('getDirectoryWrite')
->with(DirectoryList::VAR_DIR)
->willReturn($this->$method());

$this->lockerProcess->lockProcess(self::LOCK_NAME);
}

public function testNotLockProcessInProductionMode()
{
$this->stateMock->expects(self::once())->method('getMode')->willReturn(State::MODE_PRODUCTION);
Expand All @@ -90,21 +72,6 @@ public function testNotLockProcessInProductionMode()
$this->lockerProcess->lockProcess(self::LOCK_NAME);
}

/**
* Test for unlockProcess method
*/
public function testUnlockProcess()
{
$this->stateMock->expects(self::exactly(2))->method('getMode')->willReturn(State::MODE_DEVELOPER);
$this->filesystemMock->expects(self::once())
->method('getDirectoryWrite')
->with(DirectoryList::VAR_DIR)
->willReturn($this->getTmpDirectoryMockFalse(1));

$this->lockerProcess->lockProcess(self::LOCK_NAME);
$this->lockerProcess->unlockProcess();
}

public function testNotUnlockProcessInProductionMode()
{
$this->stateMock->expects(self::exactly(2))->method('getMode')->willReturn(State::MODE_PRODUCTION);
Expand All @@ -114,17 +81,6 @@ public function testNotUnlockProcessInProductionMode()
$this->lockerProcess->unlockProcess();
}

/**
* @return array
*/
public function dataProviderTestLockProcess()
{
return [
['method' => 'getTmpDirectoryMockTrue'],
['method' => 'getTmpDirectoryMockFalse']
];
}

/**
* @return WriteInterface|\PHPUnit_Framework_MockObject_MockObject
*/
Expand Down