diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 469b129c..c34cca5b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -28,23 +28,26 @@ jobs: matrix: include: - {redis: '7.2', ruby: '3.3'} - - {redis: '7.2', ruby: '3.3', compose: compose.valkey.yaml} - {redis: '7.2', ruby: '3.3', compose: compose.ssl.yaml} - {redis: '7.2', ruby: '3.3', driver: 'hiredis'} - {redis: '7.2', ruby: '3.3', driver: 'hiredis', compose: compose.ssl.yaml} - - {redis: '7.2', ruby: '3.3', replica: '2', compose: compose.replica.yaml} + - {redis: '7.2', ruby: '3.3', compose: compose.replica.yaml, replica: '2'} + - {redis: '8', ruby: '3.3', compose: compose.valkey.yaml, replica: '2'} + - {task: test_cluster_broken, redis: '7.2', restart: 'no', startup: '6'} + - {task: test_cluster_broken, redis: '6.2', restart: 'no', startup: '6'} + - {task: test_cluster_scale, redis: '7.2', compose: compose.scale.yaml, startup: '8'} + - {task: test_cluster_scale, redis: '6.2', compose: compose.scale.yaml, startup: '8'} - {redis: '7.2', ruby: '3.2', compose: compose.auth.yaml} - {redis: '7.0', ruby: '3.1'} - {redis: '6.2', ruby: '3.0'} - {redis: '5.0', ruby: '2.7'} + - {task: test_cluster_state, redis: '8', pattern: 'PrimaryOnly', compose: compose.valkey.yaml, replica: '2', startup: '9'} + - {task: test_cluster_state, redis: '8', pattern: 'Pooled', compose: compose.valkey.yaml, replica: '2', startup: '9'} + - {task: test_cluster_state, redis: '8', pattern: 'ScaleReadRandom', compose: compose.valkey.yaml, replica: '2', startup: '9'} + - {task: test_cluster_state, redis: '8', pattern: 'ScaleReadRandomWithPrimary', compose: compose.valkey.yaml, replica: '2', startup: '9'} + - {task: test_cluster_state, redis: '8', pattern: 'ScaleReadLatency', compose: compose.valkey.yaml, replica: '2', startup: '9'} - {ruby: 'jruby'} - {ruby: 'truffleruby'} - - {task: test_cluster_state, redis: '7.2', replica: '2', compose: compose.replica.yaml, startup: '9'} - - {task: test_cluster_state, redis: '6.2', replica: '2', compose: compose.replica.yaml, startup: '9'} - - {task: test_cluster_broken, redis: '7.2', restart: 'no', startup: '6'} - - {task: test_cluster_broken, redis: '6.2', restart: 'no', startup: '6'} - - {task: test_cluster_scale, redis: '7.2', compose: compose.scale.yaml, startup: '8'} - - {task: test_cluster_scale, redis: '6.2', compose: compose.scale.yaml, startup: '8'} env: REDIS_VERSION: ${{ matrix.redis || '7.2' }} DOCKER_COMPOSE_FILE: ${{ matrix.compose || 'compose.yaml' }} @@ -52,6 +55,7 @@ jobs: REDIS_REPLICA_SIZE: ${{ matrix.replica || '1' }} RESTART_POLICY: ${{ matrix.restart || 'always' }} REDIS_CLIENT_MAX_STARTUP_SAMPLE: ${{ matrix.startup || '3' }} + TEST_CLASS_PATTERN: ${{ matrix.pattern || '' }} steps: - name: Check out code uses: actions/checkout@v4 diff --git a/compose.valkey.yaml b/compose.valkey.yaml index fedb8815..5a5a3d78 100644 --- a/compose.valkey.yaml +++ b/compose.valkey.yaml @@ -38,6 +38,18 @@ services: <<: *node ports: - "6384:6379" + node7: + <<: *node + ports: + - "6385:6379" + node8: + <<: *node + ports: + - "6386:6379" + node9: + <<: *node + ports: + - "6387:6379" clustering: image: "valkey/valkey:${REDIS_VERSION:-7}" command: > @@ -51,7 +63,10 @@ services: $$(dig node4 +short):6379 $$(dig node5 +short):6379 $$(dig node6 +short):6379 - --cluster-replicas 1" + $$(dig node7 +short):6379 + $$(dig node8 +short):6379 + $$(dig node9 +short):6379 + --cluster-replicas 2" depends_on: node1: condition: service_healthy @@ -65,6 +80,12 @@ services: condition: service_healthy node6: condition: service_healthy + node7: + condition: service_healthy + node8: + condition: service_healthy + node9: + condition: service_healthy ruby: image: "ruby:${RUBY_VERSION:-3}" restart: always diff --git a/test/test_against_cluster_state.rb b/test/test_against_cluster_state.rb index cc35f208..f0769e7a 100644 --- a/test/test_against_cluster_state.rb +++ b/test/test_against_cluster_state.rb @@ -2,7 +2,7 @@ require 'testing_helper' -class TestAgainstClusterState < TestingWrapper +module TestAgainstClusterState SLOT_SIZE = 16_384 module Mixin @@ -189,127 +189,91 @@ def do_resharding_test(number_of_keys: 1000) end end - class PrimaryOnly < TestingWrapper - include Mixin + PATTERN = ENV.fetch('TEST_CLASS_PATTERN', '') - private - - def new_test_client - ::RedisClient.cluster( - nodes: TEST_NODE_URIS, - fixed_hostname: TEST_FIXED_HOSTNAME, - **TEST_GENERIC_OPTIONS - ).new_client - end - end - - class Pooled < TestingWrapper - include Mixin + if PATTERN == 'PrimaryOnly' || PATTERN.empty? + class PrimaryOnly < TestingWrapper + include Mixin - private + private - def new_test_client - ::RedisClient.cluster( - nodes: TEST_NODE_URIS, - fixed_hostname: TEST_FIXED_HOSTNAME, - **TEST_GENERIC_OPTIONS - ).new_pool(timeout: TEST_TIMEOUT_SEC, size: 2) + def new_test_client + ::RedisClient.cluster( + nodes: TEST_NODE_URIS, + fixed_hostname: TEST_FIXED_HOSTNAME, + **TEST_GENERIC_OPTIONS + ).new_client + end end end - class ScaleReadRandom < TestingWrapper - include Mixin - - def test_the_state_of_cluster_resharding - skip('https://github.com/redis/redis/issues/11312') - end - - def test_the_state_of_cluster_resharding_with_pipelining - skip('https://github.com/redis/redis/issues/11312') - end - - def test_the_state_of_cluster_resharding_with_transaction - skip('https://github.com/redis/redis/issues/11312') - end - - def test_the_state_of_cluster_resharding_with_transaction_and_watch - skip('https://github.com/redis/redis/issues/11312') - end + if PATTERN == 'Pooled' || PATTERN.empty? + class Pooled < TestingWrapper + include Mixin - private + private - def new_test_client - ::RedisClient.cluster( - nodes: TEST_NODE_URIS, - replica: true, - replica_affinity: :random, - fixed_hostname: TEST_FIXED_HOSTNAME, - **TEST_GENERIC_OPTIONS - ).new_client + def new_test_client + ::RedisClient.cluster( + nodes: TEST_NODE_URIS, + fixed_hostname: TEST_FIXED_HOSTNAME, + **TEST_GENERIC_OPTIONS + ).new_pool(timeout: TEST_TIMEOUT_SEC, size: 2) + end end end - class ScaleReadRandomWithPrimary < TestingWrapper - include Mixin + if PATTERN == 'ScaleReadRandom' || PATTERN.empty? + class ScaleReadRandom < TestingWrapper + include Mixin - def test_the_state_of_cluster_resharding - skip('https://github.com/redis/redis/issues/11312') - end + private - def test_the_state_of_cluster_resharding_with_pipelining - skip('https://github.com/redis/redis/issues/11312') - end - - def test_the_state_of_cluster_resharding_with_transaction - skip('https://github.com/redis/redis/issues/11312') - end - - def test_the_state_of_cluster_resharding_with_transaction_and_watch - skip('https://github.com/redis/redis/issues/11312') - end - - private - - def new_test_client - ::RedisClient.cluster( - nodes: TEST_NODE_URIS, - replica: true, - replica_affinity: :random_with_primary, - fixed_hostname: TEST_FIXED_HOSTNAME, - **TEST_GENERIC_OPTIONS - ).new_client + def new_test_client + ::RedisClient.cluster( + nodes: TEST_NODE_URIS, + replica: true, + replica_affinity: :random, + fixed_hostname: TEST_FIXED_HOSTNAME, + **TEST_GENERIC_OPTIONS + ).new_client + end end end - class ScaleReadLatency < TestingWrapper - include Mixin + if PATTERN == 'ScaleReadRandomWithPrimary' || PATTERN.empty? + class ScaleReadRandomWithPrimary < TestingWrapper + include Mixin - def test_the_state_of_cluster_resharding - skip('https://github.com/redis/redis/issues/11312') - end - - def test_the_state_of_cluster_resharding_with_pipelining - skip('https://github.com/redis/redis/issues/11312') - end + private - def test_the_state_of_cluster_resharding_with_transaction - skip('https://github.com/redis/redis/issues/11312') + def new_test_client + ::RedisClient.cluster( + nodes: TEST_NODE_URIS, + replica: true, + replica_affinity: :random_with_primary, + fixed_hostname: TEST_FIXED_HOSTNAME, + **TEST_GENERIC_OPTIONS + ).new_client + end end + end - def test_the_state_of_cluster_resharding_with_transaction_and_watch - skip('https://github.com/redis/redis/issues/11312') - end + if PATTERN == 'ScaleReadLatency' || PATTERN.empty? + class ScaleReadLatency < TestingWrapper + include Mixin - private + private - def new_test_client - ::RedisClient.cluster( - nodes: TEST_NODE_URIS, - replica: true, - replica_affinity: :latency, - fixed_hostname: TEST_FIXED_HOSTNAME, - **TEST_GENERIC_OPTIONS - ).new_client + def new_test_client + ::RedisClient.cluster( + nodes: TEST_NODE_URIS, + replica: true, + replica_affinity: :latency, + fixed_hostname: TEST_FIXED_HOSTNAME, + **TEST_GENERIC_OPTIONS + ).new_client + end end end end