Skip to content

Commit 8cbcaf4

Browse files
authored
test: resume resharding test for scale reading (#375)
1 parent 3c8d9ba commit 8cbcaf4

File tree

3 files changed

+98
-109
lines changed

3 files changed

+98
-109
lines changed

.github/workflows/test.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,34 @@ jobs:
2828
matrix:
2929
include:
3030
- {redis: '7.2', ruby: '3.3'}
31-
- {redis: '7.2', ruby: '3.3', compose: compose.valkey.yaml}
3231
- {redis: '7.2', ruby: '3.3', compose: compose.ssl.yaml}
3332
- {redis: '7.2', ruby: '3.3', driver: 'hiredis'}
3433
- {redis: '7.2', ruby: '3.3', driver: 'hiredis', compose: compose.ssl.yaml}
35-
- {redis: '7.2', ruby: '3.3', replica: '2', compose: compose.replica.yaml}
34+
- {redis: '7.2', ruby: '3.3', compose: compose.replica.yaml, replica: '2'}
35+
- {redis: '8', ruby: '3.3', compose: compose.valkey.yaml, replica: '2'}
36+
- {task: test_cluster_broken, redis: '7.2', restart: 'no', startup: '6'}
37+
- {task: test_cluster_broken, redis: '6.2', restart: 'no', startup: '6'}
38+
- {task: test_cluster_scale, redis: '7.2', compose: compose.scale.yaml, startup: '8'}
39+
- {task: test_cluster_scale, redis: '6.2', compose: compose.scale.yaml, startup: '8'}
3640
- {redis: '7.2', ruby: '3.2', compose: compose.auth.yaml}
3741
- {redis: '7.0', ruby: '3.1'}
3842
- {redis: '6.2', ruby: '3.0'}
3943
- {redis: '5.0', ruby: '2.7'}
44+
- {task: test_cluster_state, redis: '8', pattern: 'PrimaryOnly', compose: compose.valkey.yaml, replica: '2', startup: '9'}
45+
- {task: test_cluster_state, redis: '8', pattern: 'Pooled', compose: compose.valkey.yaml, replica: '2', startup: '9'}
46+
- {task: test_cluster_state, redis: '8', pattern: 'ScaleReadRandom', compose: compose.valkey.yaml, replica: '2', startup: '9'}
47+
- {task: test_cluster_state, redis: '8', pattern: 'ScaleReadRandomWithPrimary', compose: compose.valkey.yaml, replica: '2', startup: '9'}
48+
- {task: test_cluster_state, redis: '8', pattern: 'ScaleReadLatency', compose: compose.valkey.yaml, replica: '2', startup: '9'}
4049
- {ruby: 'jruby'}
4150
- {ruby: 'truffleruby'}
42-
- {task: test_cluster_state, redis: '7.2', replica: '2', compose: compose.replica.yaml, startup: '9'}
43-
- {task: test_cluster_state, redis: '6.2', replica: '2', compose: compose.replica.yaml, startup: '9'}
44-
- {task: test_cluster_broken, redis: '7.2', restart: 'no', startup: '6'}
45-
- {task: test_cluster_broken, redis: '6.2', restart: 'no', startup: '6'}
46-
- {task: test_cluster_scale, redis: '7.2', compose: compose.scale.yaml, startup: '8'}
47-
- {task: test_cluster_scale, redis: '6.2', compose: compose.scale.yaml, startup: '8'}
4851
env:
4952
REDIS_VERSION: ${{ matrix.redis || '7.2' }}
5053
DOCKER_COMPOSE_FILE: ${{ matrix.compose || 'compose.yaml' }}
5154
REDIS_CONNECTION_DRIVER: ${{ matrix.driver || 'ruby' }}
5255
REDIS_REPLICA_SIZE: ${{ matrix.replica || '1' }}
5356
RESTART_POLICY: ${{ matrix.restart || 'always' }}
5457
REDIS_CLIENT_MAX_STARTUP_SAMPLE: ${{ matrix.startup || '3' }}
58+
TEST_CLASS_PATTERN: ${{ matrix.pattern || '' }}
5559
steps:
5660
- name: Check out code
5761
uses: actions/checkout@v4

compose.valkey.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ services:
3838
<<: *node
3939
ports:
4040
- "6384:6379"
41+
node7:
42+
<<: *node
43+
ports:
44+
- "6385:6379"
45+
node8:
46+
<<: *node
47+
ports:
48+
- "6386:6379"
49+
node9:
50+
<<: *node
51+
ports:
52+
- "6387:6379"
4153
clustering:
4254
image: "valkey/valkey:${REDIS_VERSION:-7}"
4355
command: >
@@ -51,7 +63,10 @@ services:
5163
$$(dig node4 +short):6379
5264
$$(dig node5 +short):6379
5365
$$(dig node6 +short):6379
54-
--cluster-replicas 1"
66+
$$(dig node7 +short):6379
67+
$$(dig node8 +short):6379
68+
$$(dig node9 +short):6379
69+
--cluster-replicas 2"
5570
depends_on:
5671
node1:
5772
condition: service_healthy
@@ -65,6 +80,12 @@ services:
6580
condition: service_healthy
6681
node6:
6782
condition: service_healthy
83+
node7:
84+
condition: service_healthy
85+
node8:
86+
condition: service_healthy
87+
node9:
88+
condition: service_healthy
6889
ruby:
6990
image: "ruby:${RUBY_VERSION:-3}"
7091
restart: always

test/test_against_cluster_state.rb

Lines changed: 64 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require 'testing_helper'
44

5-
class TestAgainstClusterState < TestingWrapper
5+
module TestAgainstClusterState
66
SLOT_SIZE = 16_384
77

88
module Mixin
@@ -189,127 +189,91 @@ def do_resharding_test(number_of_keys: 1000)
189189
end
190190
end
191191

192-
class PrimaryOnly < TestingWrapper
193-
include Mixin
192+
PATTERN = ENV.fetch('TEST_CLASS_PATTERN', '')
194193

195-
private
196-
197-
def new_test_client
198-
::RedisClient.cluster(
199-
nodes: TEST_NODE_URIS,
200-
fixed_hostname: TEST_FIXED_HOSTNAME,
201-
**TEST_GENERIC_OPTIONS
202-
).new_client
203-
end
204-
end
205-
206-
class Pooled < TestingWrapper
207-
include Mixin
194+
if PATTERN == 'PrimaryOnly' || PATTERN.empty?
195+
class PrimaryOnly < TestingWrapper
196+
include Mixin
208197

209-
private
198+
private
210199

211-
def new_test_client
212-
::RedisClient.cluster(
213-
nodes: TEST_NODE_URIS,
214-
fixed_hostname: TEST_FIXED_HOSTNAME,
215-
**TEST_GENERIC_OPTIONS
216-
).new_pool(timeout: TEST_TIMEOUT_SEC, size: 2)
200+
def new_test_client
201+
::RedisClient.cluster(
202+
nodes: TEST_NODE_URIS,
203+
fixed_hostname: TEST_FIXED_HOSTNAME,
204+
**TEST_GENERIC_OPTIONS
205+
).new_client
206+
end
217207
end
218208
end
219209

220-
class ScaleReadRandom < TestingWrapper
221-
include Mixin
222-
223-
def test_the_state_of_cluster_resharding
224-
skip('https://github.com/redis/redis/issues/11312')
225-
end
226-
227-
def test_the_state_of_cluster_resharding_with_pipelining
228-
skip('https://github.com/redis/redis/issues/11312')
229-
end
230-
231-
def test_the_state_of_cluster_resharding_with_transaction
232-
skip('https://github.com/redis/redis/issues/11312')
233-
end
234-
235-
def test_the_state_of_cluster_resharding_with_transaction_and_watch
236-
skip('https://github.com/redis/redis/issues/11312')
237-
end
210+
if PATTERN == 'Pooled' || PATTERN.empty?
211+
class Pooled < TestingWrapper
212+
include Mixin
238213

239-
private
214+
private
240215

241-
def new_test_client
242-
::RedisClient.cluster(
243-
nodes: TEST_NODE_URIS,
244-
replica: true,
245-
replica_affinity: :random,
246-
fixed_hostname: TEST_FIXED_HOSTNAME,
247-
**TEST_GENERIC_OPTIONS
248-
).new_client
216+
def new_test_client
217+
::RedisClient.cluster(
218+
nodes: TEST_NODE_URIS,
219+
fixed_hostname: TEST_FIXED_HOSTNAME,
220+
**TEST_GENERIC_OPTIONS
221+
).new_pool(timeout: TEST_TIMEOUT_SEC, size: 2)
222+
end
249223
end
250224
end
251225

252-
class ScaleReadRandomWithPrimary < TestingWrapper
253-
include Mixin
226+
if PATTERN == 'ScaleReadRandom' || PATTERN.empty?
227+
class ScaleReadRandom < TestingWrapper
228+
include Mixin
254229

255-
def test_the_state_of_cluster_resharding
256-
skip('https://github.com/redis/redis/issues/11312')
257-
end
230+
private
258231

259-
def test_the_state_of_cluster_resharding_with_pipelining
260-
skip('https://github.com/redis/redis/issues/11312')
261-
end
262-
263-
def test_the_state_of_cluster_resharding_with_transaction
264-
skip('https://github.com/redis/redis/issues/11312')
265-
end
266-
267-
def test_the_state_of_cluster_resharding_with_transaction_and_watch
268-
skip('https://github.com/redis/redis/issues/11312')
269-
end
270-
271-
private
272-
273-
def new_test_client
274-
::RedisClient.cluster(
275-
nodes: TEST_NODE_URIS,
276-
replica: true,
277-
replica_affinity: :random_with_primary,
278-
fixed_hostname: TEST_FIXED_HOSTNAME,
279-
**TEST_GENERIC_OPTIONS
280-
).new_client
232+
def new_test_client
233+
::RedisClient.cluster(
234+
nodes: TEST_NODE_URIS,
235+
replica: true,
236+
replica_affinity: :random,
237+
fixed_hostname: TEST_FIXED_HOSTNAME,
238+
**TEST_GENERIC_OPTIONS
239+
).new_client
240+
end
281241
end
282242
end
283243

284-
class ScaleReadLatency < TestingWrapper
285-
include Mixin
244+
if PATTERN == 'ScaleReadRandomWithPrimary' || PATTERN.empty?
245+
class ScaleReadRandomWithPrimary < TestingWrapper
246+
include Mixin
286247

287-
def test_the_state_of_cluster_resharding
288-
skip('https://github.com/redis/redis/issues/11312')
289-
end
290-
291-
def test_the_state_of_cluster_resharding_with_pipelining
292-
skip('https://github.com/redis/redis/issues/11312')
293-
end
248+
private
294249

295-
def test_the_state_of_cluster_resharding_with_transaction
296-
skip('https://github.com/redis/redis/issues/11312')
250+
def new_test_client
251+
::RedisClient.cluster(
252+
nodes: TEST_NODE_URIS,
253+
replica: true,
254+
replica_affinity: :random_with_primary,
255+
fixed_hostname: TEST_FIXED_HOSTNAME,
256+
**TEST_GENERIC_OPTIONS
257+
).new_client
258+
end
297259
end
260+
end
298261

299-
def test_the_state_of_cluster_resharding_with_transaction_and_watch
300-
skip('https://github.com/redis/redis/issues/11312')
301-
end
262+
if PATTERN == 'ScaleReadLatency' || PATTERN.empty?
263+
class ScaleReadLatency < TestingWrapper
264+
include Mixin
302265

303-
private
266+
private
304267

305-
def new_test_client
306-
::RedisClient.cluster(
307-
nodes: TEST_NODE_URIS,
308-
replica: true,
309-
replica_affinity: :latency,
310-
fixed_hostname: TEST_FIXED_HOSTNAME,
311-
**TEST_GENERIC_OPTIONS
312-
).new_client
268+
def new_test_client
269+
::RedisClient.cluster(
270+
nodes: TEST_NODE_URIS,
271+
replica: true,
272+
replica_affinity: :latency,
273+
fixed_hostname: TEST_FIXED_HOSTNAME,
274+
**TEST_GENERIC_OPTIONS
275+
).new_client
276+
end
313277
end
314278
end
315279
end

0 commit comments

Comments
 (0)