Skip to content

Commit 07cccee

Browse files
authored
Merge pull request #1153 from supercaracal/fix-cluster-test
Shrink cluster test cases guaranteed by redis-cluster-client and focus on behavior test for method interfaces
2 parents a3070af + d6cf651 commit 07cccee

File tree

4 files changed

+3
-138
lines changed

4 files changed

+3
-138
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Gemfile.lock
66
/.idea
77
/.yardoc
88
/.bundle
9+
/cluster/.bundle
910
/coverage/*
1011
/doc/
1112
/examples/sentinel/sentinel.conf

cluster/test/abnormal_state_test.rb

Lines changed: 0 additions & 57 deletions
This file was deleted.

cluster/test/client_replicas_test.rb

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,4 @@ def test_client_can_command_with_replica
1919
assert_equal i.to_s, r.get("key#{i}")
2020
end
2121
end
22-
23-
def test_client_can_flush_with_replica
24-
r = build_another_client(replica: true)
25-
26-
assert_equal 'OK', r.flushall
27-
assert_equal 'OK', r.flushdb
28-
end
29-
30-
def test_some_reference_commands_are_sent_to_slaves_if_needed
31-
skip("This test is very flaky") if ENV["CI"]
32-
r = build_another_client(replica: true)
33-
34-
5.times { |i| r.set("key#{i}", i) }
35-
36-
r.wait(1, TIMEOUT.to_i * 1000)
37-
38-
assert_equal %w[key0 key1 key2 key3 key4], r.keys
39-
assert_equal 5, r.dbsize
40-
end
4122
end

cluster/test/client_transactions_test.rb

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,9 @@
66
class TestClusterClientTransactions < Minitest::Test
77
include Helper::Cluster
88

9-
def test_transaction_with_hash_tag
10-
skip("redis-cluster-client doesn't support transaction")
11-
rc1 = redis
12-
rc2 = build_another_client
13-
14-
rc1.multi do |cli|
15-
100.times { |i| cli.set("{key}#{i}", i) }
16-
end
17-
18-
100.times { |i| assert_equal i.to_s, rc1.get("{key}#{i}") }
19-
100.times { |i| assert_equal i.to_s, rc2.get("{key}#{i}") }
20-
end
21-
22-
def test_transaction_without_hash_tag
23-
rc1 = redis
24-
rc2 = build_another_client
25-
9+
def test_cluster_client_does_not_support_transaction
2610
assert_raises(Redis::Cluster::AmbiguousNodeError) do
27-
rc1.multi do |cli|
28-
100.times { |i| cli.set("key#{i}", i) }
29-
end
30-
end
31-
32-
100.times { |i| assert_nil rc1.get("key#{i}") }
33-
100.times { |i| assert_nil rc2.get("key#{i}") }
34-
end
35-
36-
def test_transaction_with_replicas
37-
skip("redis-cluster-client doesn't support transaction")
38-
rc1 = build_another_client(replica: true)
39-
rc2 = build_another_client(replica: true)
40-
41-
rc1.multi do |cli|
42-
100.times { |i| cli.set("{key}#{i}", i) }
11+
redis.multi { |r| r.set('key', 'foo') }
4312
end
44-
45-
rc1.wait(1, TIMEOUT.to_i * 1000)
46-
47-
100.times { |i| assert_equal i.to_s, rc1.get("{key}#{i}") }
48-
100.times { |i| assert_equal i.to_s, rc2.get("{key}#{i}") }
49-
end
50-
51-
def test_transaction_with_watch
52-
skip("redis-cluster-client doesn't support transaction")
53-
rc1 = redis
54-
rc2 = build_another_client
55-
56-
rc1.set('{key}1', 100)
57-
rc1.watch('{key}1')
58-
59-
rc2.set('{key}1', 200)
60-
val = rc1.get('{key}1').to_i
61-
val += 1
62-
63-
rc1.multi do |cli|
64-
cli.set('{key}1', val)
65-
cli.set('{key}2', 300)
66-
end
67-
68-
assert_equal '200', rc1.get('{key}1')
69-
assert_equal '200', rc2.get('{key}1')
70-
71-
assert_nil rc1.get('{key}2')
72-
assert_nil rc2.get('{key}2')
7313
end
7414
end

0 commit comments

Comments
 (0)