aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStephan Orbaugh <62374139+sorbaugh@users.noreply.github.com>2023-12-22 10:43:04 +0100
committerGitHub <noreply@github.com>2023-12-22 10:43:04 +0100
commit7d8741c53f7be7e77139f124e441e2ba10e66bf2 (patch)
treeb79d05323a5c1a573cafd30b4fbd9bdf51750c49 /tests
parent728dfa6799c9ee2eb3694e84a03363f58c5b799b (diff)
parentff62154a79498b16e5c4b617e073aea03afc2a84 (diff)
downloadnextcloud-server-7d8741c53f7be7e77139f124e441e2ba10e66bf2.tar.gz
nextcloud-server-7d8741c53f7be7e77139f124e441e2ba10e66bf2.zip
Merge pull request #37469 from nextcloud/lock-restore-ttl
restore shared lock ttl to previous value when releasing
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Lock/MemcacheLockingProviderTest.php4
-rw-r--r--tests/lib/Memcache/RedisTest.php21
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'));
+ }
}