From f73ca1b77fd1b961181e2a0086a688ffac19603c Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 2 May 2017 18:08:43 -0300 Subject: [PATCH 1/3] Add redis cluster tests to our CI jobs Signed-off-by: Morris Jobke --- .drone.yml | 17 +++++++++++++++++ autotest.sh | 2 ++ tests/redis-cluster.config.php | 20 ++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/redis-cluster.config.php diff --git a/.drone.yml b/.drone.yml index e5fda39f4ee..b313760a5d2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -526,6 +526,16 @@ pipeline: when: matrix: TEST: memcache-memcached + memcache-redis-cluster: + image: nextcloudci/php7.0:php7.0-7 + commands: + - ./autotest.sh sqlite tests/lib/Memcache/RedisTest.php + - wget https://codecov.io/bash -O codecov.sh + - sh -c "if [ '$DRONE_BUILD_EVENT' = 'pull_request' ]; then bash codecov.sh -B $DRONE_BRANCH -C $DRONE_COMMIT -P $DRONE_PULL_REQUEST -t 117641e2-a9e8-4b7b-984b-ae872d9b05f5 -f tests/autotest-clover-sqlite.xml; fi" + - sh -c "if [ '$DRONE_BUILD_EVENT' != 'pull_request' ]; then bash codecov.sh -B $DRONE_BRANCH -C $DRONE_COMMIT -t 117641e2-a9e8-4b7b-984b-ae872d9b05f5 -f tests/autotest-clover-sqlite.xml; fi" + when: + matrix: + TEST: memcache-redis-cluster matrix: include: - TESTS: checkers @@ -582,6 +592,8 @@ matrix: - TESTS: sqlite-php7.0-samba-native - TESTS: sqlite-php7.0-samba-non-native - TEST: memcache-memcached + - TEST: memcache-redis-cluster + ENABLE_REDIS_CLUSTER: true - TESTS: sqlite-php7.0-webdav-apache ENABLE_REDIS: true - DB: NODB @@ -618,6 +630,11 @@ services: when: matrix: ENABLE_REDIS: true + cache-cluster: + image: grokzen/redis-cluster + when: + matrix: + ENABLE_REDIS_CLUSTER: true postgres: image: postgres environment: diff --git a/autotest.sh b/autotest.sh index b00946d0c02..069488a3346 100755 --- a/autotest.sh +++ b/autotest.sh @@ -184,6 +184,8 @@ function execute_tests { if [ "$ENABLE_REDIS" == "true" ] ; then cp tests/redis.config.php config/redis.config.php + elif [ "$ENABLE_REDIS_CLUSTER" == "true" ] ; then + cp tests/redis-cluster.config.php config/redis.config.php fi _DB=$DB diff --git a/tests/redis-cluster.config.php b/tests/redis-cluster.config.php new file mode 100644 index 00000000000..c7df2a91854 --- /dev/null +++ b/tests/redis-cluster.config.php @@ -0,0 +1,20 @@ + '\\OC\\Memcache\\Redis', + 'memcache.distributed' => '\\OC\\Memcache\\Redis', + 'memcache.locking' => '\\OC\\Memcache\\Redis', + 'redis.cluster' => [ + 'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required + 'localhost:7000', + 'localhost:7001', + 'localhost:7002', + 'localhost:7003', + 'localhost:7004', + 'localhost:7005' + ], + 'timeout' => 0.0, + 'read_timeout' => 0.0, + 'failover_mode' => \RedisCluster::FAILOVER_ERROR + ], +]; From fe5a4dd4995fcf6fdb3546dab103a5eb84d28f72 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 3 May 2017 17:31:09 -0300 Subject: [PATCH 2/3] Make cache tests a bit more clear Signed-off-by: Morris Jobke --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index b313760a5d2..589d67f8f29 100644 --- a/.drone.yml +++ b/.drone.yml @@ -529,6 +529,7 @@ pipeline: memcache-redis-cluster: image: nextcloudci/php7.0:php7.0-7 commands: + - sleep 10 - ./autotest.sh sqlite tests/lib/Memcache/RedisTest.php - wget https://codecov.io/bash -O codecov.sh - sh -c "if [ '$DRONE_BUILD_EVENT' = 'pull_request' ]; then bash codecov.sh -B $DRONE_BRANCH -C $DRONE_COMMIT -P $DRONE_PULL_REQUEST -t 117641e2-a9e8-4b7b-984b-ae872d9b05f5 -f tests/autotest-clover-sqlite.xml; fi" From 0e66c2a38aa86df2b6a1273b0cf4ad95485ce6e7 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 16 May 2017 09:52:05 +0200 Subject: [PATCH 3/3] Do not scan for keys just get all the keys (with prefix) Apparently scan leads to some issues sometimes on cluster. So just use the get function to fetch the keys. Signed-off-by: Roeland Jago Douma --- lib/private/Memcache/Redis.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/private/Memcache/Redis.php b/lib/private/Memcache/Redis.php index a154d08deca..dd7e929a828 100644 --- a/lib/private/Memcache/Redis.php +++ b/lib/private/Memcache/Redis.php @@ -79,12 +79,10 @@ class Redis extends Cache implements IMemcacheTTL { public function clear($prefix = '') { $prefix = $this->getNameSpace() . $prefix . '*'; - $it = null; - self::$cache->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY); - while ($keys = self::$cache->scan($it, $prefix)) { - self::$cache->del($keys); - } - return true; + $keys = self::$cache->keys($prefix); + $deleted = self::$cache->del($keys); + + return count($keys) === $deleted; } /**