Skip to content

Commit e7a723a

Browse files
committed
MAGETWO-98151: Add support ZooKeeper locks
1 parent cefd38c commit e7a723a

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function testLockAndUnlock()
7474

7575
$this->assertTrue($this->model->lock($name));
7676
$this->assertTrue($this->model->isLocked($name));
77+
$this->assertFalse($this->model->lock($name, 2));
7778

7879
$this->assertTrue($this->model->unlock($name));
7980
$this->assertFalse($this->model->isLocked($name));

lib/internal/Magento/Framework/Lock/LockBackendFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function create(): LockManagerInterface
9090
$config = $this->deploymentConfig->get('lock/config', []);
9191

9292
if (!isset($this->lockers[$provider])) {
93-
throw new RuntimeException(new Phrase('Unknown locks provider.'));
93+
throw new RuntimeException(new Phrase('Unknown locks provider: %1', [$provider]));
9494
}
9595

9696
if (self::LOCK_ZOOKEEPER === $provider && !extension_loaded(self::LOCK_ZOOKEEPER)) {

lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313

1414
class ZookeeperTest extends TestCase
1515
{
16-
/**
17-
* @var \Zookeeper|MockObject
18-
*/
19-
private $zookeeperMock;
20-
2116
/**
2217
* @var ZookeeperProvider
2318
*/
@@ -41,15 +36,23 @@ protected function setUp()
4136
if (!extension_loaded('zookeeper')) {
4237
$this->markTestSkipped('Test was skipped because php extension Zookeeper is not installed.');
4338
}
44-
$this->zookeeperProvider = new ZookeeperProvider($this->host, '/some/path/');
4539
}
4640

4741
/**
4842
* @expectedException \Magento\Framework\Exception\RuntimeException
4943
* @expectedExceptionMessage The path needs to be a non-empty string.
44+
* @return void
5045
*/
5146
public function testConstructionWithException()
5247
{
53-
$this->zookeeperProvider = new ZookeeperProvider('some host', '');
48+
$this->zookeeperProvider = new ZookeeperProvider($this->host, '');
49+
}
50+
51+
/**
52+
* @return void
53+
*/
54+
public function testConstructionWithoutException()
55+
{
56+
$this->zookeeperProvider = new ZookeeperProvider($this->host, $this->path);
5457
}
5558
}

lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function setUp()
4646

4747
/**
4848
* @expectedException \Magento\Framework\Exception\RuntimeException
49-
* @expectedExceptionMessage Unknown locks provider.
49+
* @expectedExceptionMessage Unknown locks provider: someProvider
5050
*/
5151
public function testCreateWithException()
5252
{

setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ private function validateZookeeperConfig(array $options, DeploymentConfig $deplo
210210
$errors[] = 'php extension Zookeeper is not installed.';
211211
}
212212

213-
$host = (string) $options[self::INPUT_KEY_LOCK_ZOOKEEPER_HOST]
213+
$host = $options[self::INPUT_KEY_LOCK_ZOOKEEPER_HOST]
214214
?? $deploymentConfig->get(
215215
self::CONFIG_PATH_LOCK_ZOOKEEPER_HOST,
216216
$this->getDefaultValue(self::INPUT_KEY_LOCK_ZOOKEEPER_HOST)
217217
);
218-
$path = (string) $options[self::INPUT_KEY_LOCK_ZOOKEEPER_PATH]
218+
$path = $options[self::INPUT_KEY_LOCK_ZOOKEEPER_PATH]
219219
?? $deploymentConfig->get(
220220
self::CONFIG_PATH_LOCK_ZOOKEEPER_PATH,
221221
$this->getDefaultValue(self::INPUT_KEY_LOCK_ZOOKEEPER_PATH)

0 commit comments

Comments
 (0)