diff options
author | Robin Appelman <robin@icewind.nl> | 2024-01-02 14:50:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-02 14:50:14 +0100 |
commit | f516e9599b262d802ad342ab06f271ed4055731a (patch) | |
tree | 3c96f125aa6bd12da203f1b00b023e940577444c /tests | |
parent | 4443e5cf560e04af0a7dc81bc0353fcec323f9b1 (diff) | |
parent | 2078ad79bdc996494f0de49fcd04d56457296c47 (diff) | |
download | nextcloud-server-f516e9599b262d802ad342ab06f271ed4055731a.tar.gz nextcloud-server-f516e9599b262d802ad342ab06f271ed4055731a.zip |
Merge pull request #42450 from nextcloud/backport/37469/stable28
[stable28] restore shared lock ttl to previous value when releasing
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Lock/MemcacheLockingProviderTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Memcache/RedisTest.php | 21 |
2 files changed, 24 insertions, 1 deletions
diff --git a/tests/lib/Lock/MemcacheLockingProviderTest.php b/tests/lib/Lock/MemcacheLockingProviderTest.php index b67be799d59..95001ec03a3 100644 --- a/tests/lib/Lock/MemcacheLockingProviderTest.php +++ b/tests/lib/Lock/MemcacheLockingProviderTest.php @@ -22,6 +22,7 @@ namespace Test\Lock; use OC\Memcache\ArrayCache; +use OCP\AppFramework\Utility\ITimeFactory; class MemcacheLockingProviderTest extends LockingProvider { /** @@ -34,7 +35,8 @@ class MemcacheLockingProviderTest extends LockingProvider { */ protected function getInstance() { $this->memcache = new ArrayCache(); - return new \OC\Lock\MemcacheLockingProvider($this->memcache); + $timeProvider = \OC::$server->get(ITimeFactory::class); + return new \OC\Lock\MemcacheLockingProvider($this->memcache, $timeProvider); } protected function tearDown(): void { diff --git a/tests/lib/Memcache/RedisTest.php b/tests/lib/Memcache/RedisTest.php index b94b69a5e6a..27c6fc11ee8 100644 --- a/tests/lib/Memcache/RedisTest.php +++ b/tests/lib/Memcache/RedisTest.php @@ -9,11 +9,18 @@ namespace Test\Memcache; +use OC\Memcache\Redis; + /** * @group Memcache * @group Redis */ class RedisTest extends Cache { + /** + * @var Redis cache; + */ + protected $instance; + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -62,4 +69,18 @@ class RedisTest extends Cache { $this->assertEquals(sha1($script[0]), $script[1]); } } + + public function testCasTtlNotChanged() { + $this->instance->set('foo', 'bar', 50); + $this->assertTrue($this->instance->compareSetTTL('foo', 'bar', 100)); + // allow for 1s of inaccuracy due to time moving forward + $this->assertLessThan(1, 100 - $this->instance->getTTL('foo')); + } + + public function testCasTtlChanged() { + $this->instance->set('foo', 'bar1', 50); + $this->assertFalse($this->instance->compareSetTTL('foo', 'bar', 100)); + // allow for 1s of inaccuracy due to time moving forward + $this->assertLessThan(1, 50 - $this->instance->getTTL('foo')); + } } |