redis 3.3.1 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.travis/Gemfile +3 -1
  3. data/.travis.yml +36 -52
  4. data/CHANGELOG.md +32 -13
  5. data/Gemfile +0 -1
  6. data/README.md +31 -75
  7. data/benchmarking/logging.rb +1 -1
  8. data/bors.toml +14 -0
  9. data/lib/redis/client.rb +15 -11
  10. data/lib/redis/connection/command_helper.rb +2 -8
  11. data/lib/redis/connection/hiredis.rb +2 -2
  12. data/lib/redis/connection/ruby.rb +18 -20
  13. data/lib/redis/connection/synchrony.rb +12 -4
  14. data/lib/redis/connection.rb +2 -2
  15. data/lib/redis/distributed.rb +21 -8
  16. data/lib/redis/hash_ring.rb +20 -64
  17. data/lib/redis/pipeline.rb +0 -6
  18. data/lib/redis/version.rb +1 -1
  19. data/lib/redis.rb +102 -38
  20. data/makefile +42 -0
  21. data/redis.gemspec +7 -9
  22. data/test/bitpos_test.rb +13 -19
  23. data/test/blocking_commands_test.rb +3 -5
  24. data/test/client_test.rb +1 -1
  25. data/test/command_map_test.rb +3 -5
  26. data/test/commands_on_hashes_test.rb +2 -4
  27. data/test/commands_on_hyper_log_log_test.rb +3 -5
  28. data/test/commands_on_lists_test.rb +2 -4
  29. data/test/commands_on_sets_test.rb +2 -4
  30. data/test/commands_on_sorted_sets_test.rb +17 -4
  31. data/test/commands_on_strings_test.rb +3 -5
  32. data/test/commands_on_value_types_test.rb +44 -6
  33. data/test/connection_handling_test.rb +5 -7
  34. data/test/connection_test.rb +57 -0
  35. data/test/distributed_blocking_commands_test.rb +2 -4
  36. data/test/distributed_commands_on_hashes_test.rb +2 -4
  37. data/test/distributed_commands_on_hyper_log_log_test.rb +2 -4
  38. data/test/distributed_commands_on_lists_test.rb +2 -4
  39. data/test/distributed_commands_on_sets_test.rb +27 -4
  40. data/test/distributed_commands_on_sorted_sets_test.rb +2 -4
  41. data/test/distributed_commands_on_strings_test.rb +20 -10
  42. data/test/distributed_commands_on_value_types_test.rb +2 -4
  43. data/test/distributed_commands_requiring_clustering_test.rb +1 -3
  44. data/test/distributed_connection_handling_test.rb +1 -3
  45. data/test/distributed_internals_test.rb +8 -19
  46. data/test/distributed_key_tags_test.rb +4 -6
  47. data/test/distributed_persistence_control_commands_test.rb +1 -3
  48. data/test/distributed_publish_subscribe_test.rb +1 -3
  49. data/test/distributed_remote_server_control_commands_test.rb +1 -3
  50. data/test/distributed_scripting_test.rb +1 -3
  51. data/test/distributed_sorting_test.rb +1 -3
  52. data/test/distributed_test.rb +12 -14
  53. data/test/distributed_transactions_test.rb +1 -3
  54. data/test/encoding_test.rb +4 -8
  55. data/test/error_replies_test.rb +2 -4
  56. data/test/fork_safety_test.rb +1 -6
  57. data/test/helper.rb +10 -41
  58. data/test/helper_test.rb +1 -3
  59. data/test/internals_test.rb +27 -95
  60. data/test/lint/sets.rb +15 -0
  61. data/test/lint/strings.rb +6 -20
  62. data/test/lint/value_types.rb +8 -0
  63. data/test/persistence_control_commands_test.rb +1 -3
  64. data/test/pipelining_commands_test.rb +4 -8
  65. data/test/publish_subscribe_test.rb +1 -3
  66. data/test/remote_server_control_commands_test.rb +61 -4
  67. data/test/scanning_test.rb +1 -7
  68. data/test/scripting_test.rb +1 -3
  69. data/test/sentinel_command_test.rb +1 -3
  70. data/test/sentinel_test.rb +1 -3
  71. data/test/sorting_test.rb +1 -3
  72. data/test/ssl_test.rb +45 -42
  73. data/test/support/connection/hiredis.rb +1 -1
  74. data/test/support/connection/ruby.rb +1 -1
  75. data/test/support/connection/synchrony.rb +1 -1
  76. data/test/synchrony_driver.rb +6 -9
  77. data/test/thread_safety_test.rb +1 -3
  78. data/test/transactions_test.rb +1 -3
  79. data/test/unknown_commands_test.rb +1 -3
  80. data/test/url_param_test.rb +44 -46
  81. metadata +32 -16
  82. data/Rakefile +0 -87
@@ -1,13 +1,26 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/sorted_sets"
1
+ require_relative "helper"
2
+ require_relative "lint/sorted_sets"
5
3
 
6
4
  class TestCommandsOnSortedSets < Test::Unit::TestCase
7
5
 
8
6
  include Helper::Client
9
7
  include Lint::SortedSets
10
8
 
9
+ def test_zlexcount
10
+ target_version "2.8.9" do
11
+ r.zadd "foo", 0, "aaren"
12
+ r.zadd "foo", 0, "abagael"
13
+ r.zadd "foo", 0, "abby"
14
+ r.zadd "foo", 0, "abbygail"
15
+
16
+ assert_equal 4, r.zlexcount("foo", "[a", "[a\xff")
17
+ assert_equal 4, r.zlexcount("foo", "[aa", "[ab\xff")
18
+ assert_equal 3, r.zlexcount("foo", "(aaren", "[ab\xff")
19
+ assert_equal 2, r.zlexcount("foo", "[aba", "(abbygail")
20
+ assert_equal 1, r.zlexcount("foo", "(aaren", "(abby")
21
+ end
22
+ end
23
+
11
24
  def test_zrangebylex
12
25
  target_version "2.8.9" do
13
26
  r.zadd "foo", 0, "aaren"
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/strings"
1
+ require_relative "helper"
2
+ require_relative "lint/strings"
5
3
 
6
4
  class TestCommandsOnStrings < Test::Unit::TestCase
7
5
 
@@ -82,7 +80,7 @@ class TestCommandsOnStrings < Test::Unit::TestCase
82
80
  end
83
81
 
84
82
  def test_bitop
85
- try_encoding("UTF-8") do
83
+ with_external_encoding("UTF-8") do
86
84
  target_version "2.5.10" do
87
85
  r.set("foo", "a")
88
86
  r.set("bar", "b")
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/value_types"
1
+ require_relative "helper"
2
+ require_relative "lint/value_types"
5
3
 
6
4
  class TestCommandsOnValueTypes < Test::Unit::TestCase
7
5
 
@@ -81,6 +79,7 @@ class TestCommandsOnValueTypes < Test::Unit::TestCase
81
79
  end
82
80
 
83
81
  def test_flushdb
82
+ # Test defaults
84
83
  r.set("foo", "s1")
85
84
  r.set("bar", "s2")
86
85
 
@@ -89,12 +88,51 @@ class TestCommandsOnValueTypes < Test::Unit::TestCase
89
88
  r.flushdb
90
89
 
91
90
  assert_equal 0, r.dbsize
91
+
92
+ # Test sync
93
+ r.set("foo", "s1")
94
+ r.set("bar", "s2")
95
+
96
+ assert_equal 2, r.dbsize
97
+
98
+ r.flushdb(:async => false)
99
+
100
+ assert_equal 0, r.dbsize
101
+
102
+ # Test async
103
+ target_version "3.9.101" do
104
+ r.set("foo", "s1")
105
+ r.set("bar", "s2")
106
+
107
+ assert_equal 2, r.dbsize
108
+
109
+ r.flushdb(:async => true)
110
+
111
+ assert_equal 0, r.dbsize
112
+
113
+ redis_mock(:flushdb => lambda { |args| "+FLUSHDB #{args.upcase}" }) do |redis|
114
+ assert_equal "FLUSHDB ASYNC", redis.flushdb(:async => true)
115
+ end
116
+ end
92
117
  end
93
118
 
94
119
  def test_flushall
120
+ # Test defaults
95
121
  redis_mock(:flushall => lambda { "+FLUSHALL" }) do |redis|
96
122
  assert_equal "FLUSHALL", redis.flushall
97
123
  end
124
+
125
+ # Test sync
126
+ redis_mock(:flushall => lambda { "+FLUSHALL" }) do |redis|
127
+ assert_equal "FLUSHALL", redis.flushall(:async => false)
128
+ end
129
+
130
+ # Test async
131
+ target_version "3.9.101" do
132
+ redis_mock(:flushall => lambda { |args| "+FLUSHALL #{args.upcase}" }) do |redis|
133
+ assert_equal "FLUSHALL ASYNC", redis.flushall(:async => true)
134
+ end
135
+ end
98
136
  end
99
137
 
100
138
  def test_migrate
@@ -111,8 +149,8 @@ class TestCommandsOnValueTypes < Test::Unit::TestCase
111
149
  end
112
150
  assert ex.message =~ /port not specified/
113
151
 
114
- default_db = redis.client.db.to_i
115
- default_timeout = redis.client.timeout.to_i
152
+ default_db = redis._client.db.to_i
153
+ default_timeout = redis._client.timeout.to_i
116
154
 
117
155
  # Test defaults
118
156
  actual = redis.migrate("foo", options)
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestConnectionHandling < Test::Unit::TestCase
6
4
 
@@ -40,7 +38,7 @@ class TestConnectionHandling < Test::Unit::TestCase
40
38
  r.select 14
41
39
  assert_equal nil, r.get("foo")
42
40
 
43
- r.client.disconnect
41
+ r._client.disconnect
44
42
 
45
43
  assert_equal nil, r.get("foo")
46
44
  end
@@ -48,7 +46,7 @@ class TestConnectionHandling < Test::Unit::TestCase
48
46
  def test_quit
49
47
  r.quit
50
48
 
51
- assert !r.client.connected?
49
+ assert !r._client.connected?
52
50
  end
53
51
 
54
52
  def test_close
@@ -148,7 +146,7 @@ class TestConnectionHandling < Test::Unit::TestCase
148
146
  end
149
147
 
150
148
  assert_equal nil, result
151
- assert !redis.client.connected?
149
+ assert !redis._client.connected?
152
150
  end
153
151
  end
154
152
 
@@ -188,7 +186,7 @@ class TestConnectionHandling < Test::Unit::TestCase
188
186
  end
189
187
 
190
188
  assert_equal nil, result
191
- assert !redis.client.connected?
189
+ assert !redis._client.connected?
192
190
  end
193
191
  end
194
192
 
@@ -0,0 +1,57 @@
1
+ require_relative "helper"
2
+
3
+ class TestConnection < Test::Unit::TestCase
4
+
5
+ include Helper::Client
6
+
7
+ def test_provides_a_meaningful_inspect
8
+ assert_equal "#<Redis client v#{Redis::VERSION} for redis://127.0.0.1:#{PORT}/15>", r.inspect
9
+ end
10
+
11
+ def test_connection_information
12
+ assert_equal "127.0.0.1", r.connection.fetch(:host)
13
+ assert_equal 6381, r.connection.fetch(:port)
14
+ assert_equal 15, r.connection.fetch(:db)
15
+ assert_equal "127.0.0.1:6381", r.connection.fetch(:location)
16
+ assert_equal "redis://127.0.0.1:6381/15", r.connection.fetch(:id)
17
+ end
18
+
19
+ def test_default_id_with_host_and_port
20
+ redis = Redis.new(OPTIONS.merge(:host => "host", :port => "1234", :db => 0))
21
+ assert_equal "redis://host:1234/0", redis.connection.fetch(:id)
22
+ end
23
+
24
+ def test_default_id_with_host_and_port_and_explicit_scheme
25
+ redis = Redis.new(OPTIONS.merge(:host => "host", :port => "1234", :db => 0, :scheme => "foo"))
26
+ assert_equal "redis://host:1234/0", redis.connection.fetch(:id)
27
+ end
28
+
29
+ def test_default_id_with_path
30
+ redis = Redis.new(OPTIONS.merge(:path => "/tmp/redis.sock", :db => 0))
31
+ assert_equal "redis:///tmp/redis.sock/0", redis.connection.fetch(:id)
32
+ end
33
+
34
+ def test_default_id_with_path_and_explicit_scheme
35
+ redis = Redis.new(OPTIONS.merge(:path => "/tmp/redis.sock", :db => 0, :scheme => "foo"))
36
+ assert_equal "redis:///tmp/redis.sock/0", redis.connection.fetch(:id)
37
+ end
38
+
39
+ def test_override_id
40
+ redis = Redis.new(OPTIONS.merge(:id => "test"))
41
+ assert_equal "test", redis.connection.fetch(:id)
42
+ end
43
+
44
+ def test_id_inside_multi
45
+ redis = Redis.new(OPTIONS)
46
+ id = nil
47
+ connection_id = nil
48
+
49
+ redis.multi do
50
+ id = redis.id
51
+ connection_id = redis.connection.fetch(:id)
52
+ end
53
+
54
+ assert_equal "redis://127.0.0.1:6381/15", id
55
+ assert_equal "redis://127.0.0.1:6381/15", connection_id
56
+ end
57
+ end
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/blocking_commands"
1
+ require_relative "helper"
2
+ require_relative "lint/blocking_commands"
5
3
 
6
4
  class TestDistributedBlockingCommands < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/hashes"
1
+ require_relative "helper"
2
+ require_relative "lint/hashes"
5
3
 
6
4
  class TestDistributedCommandsOnHashes < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/hyper_log_log"
1
+ require_relative "helper"
2
+ require_relative "lint/hyper_log_log"
5
3
 
6
4
  class TestDistributedCommandsOnHyperLogLog < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/lists"
1
+ require_relative "helper"
2
+ require_relative "lint/lists"
5
3
 
6
4
  class TestDistributedCommandsOnLists < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/sets"
1
+ require_relative "helper"
2
+ require_relative "lint/sets"
5
3
 
6
4
  class TestDistributedCommandsOnSets < Test::Unit::TestCase
7
5
 
@@ -80,4 +78,29 @@ class TestDistributedCommandsOnSets < Test::Unit::TestCase
80
78
  r.sdiffstore("baz", "foo", "bar")
81
79
  end
82
80
  end
81
+
82
+ def test_sscan
83
+ assert_nothing_raised do
84
+ r.sadd "foo", "s1"
85
+ r.sadd "foo", "s2"
86
+ r.sadd "bar", "s2"
87
+ r.sadd "bar", "s3"
88
+
89
+ cursor, vals = r.sscan "foo", 0
90
+ assert_equal '0', cursor
91
+ assert_equal %w(s1 s2), vals.sort
92
+ end
93
+ end
94
+
95
+ def test_sscan_each
96
+ assert_nothing_raised do
97
+ r.sadd "foo", "s1"
98
+ r.sadd "foo", "s2"
99
+ r.sadd "bar", "s2"
100
+ r.sadd "bar", "s3"
101
+
102
+ vals = r.sscan_each("foo").to_a
103
+ assert_equal %w(s1 s2), vals.sort
104
+ end
105
+ end
83
106
  end
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/sorted_sets"
1
+ require_relative "helper"
2
+ require_relative "lint/sorted_sets"
5
3
 
6
4
  class TestDistributedCommandsOnSortedSets < Test::Unit::TestCase
7
5
 
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/strings"
1
+ require_relative "helper"
2
+ require_relative "lint/strings"
5
3
 
6
4
  class TestDistributedCommandsOnStrings < Test::Unit::TestCase
7
5
 
@@ -9,15 +7,27 @@ class TestDistributedCommandsOnStrings < Test::Unit::TestCase
9
7
  include Lint::Strings
10
8
 
11
9
  def test_mget
12
- assert_raise Redis::Distributed::CannotDistribute do
13
- r.mget("foo", "bar")
14
- end
10
+ r.set("foo", "s1")
11
+ r.set("bar", "s2")
12
+
13
+ assert_equal ["s1", "s2"] , r.mget("foo", "bar")
14
+ assert_equal ["s1", "s2", nil], r.mget("foo", "bar", "baz")
15
15
  end
16
16
 
17
17
  def test_mget_mapped
18
- assert_raise Redis::Distributed::CannotDistribute do
19
- r.mapped_mget("foo", "bar")
20
- end
18
+ r.set("foo", "s1")
19
+ r.set("bar", "s2")
20
+
21
+ response = r.mapped_mget("foo", "bar")
22
+
23
+ assert_equal "s1", response["foo"]
24
+ assert_equal "s2", response["bar"]
25
+
26
+ response = r.mapped_mget("foo", "bar", "baz")
27
+
28
+ assert_equal "s1", response["foo"]
29
+ assert_equal "s2", response["bar"]
30
+ assert_equal nil , response["baz"]
21
31
  end
22
32
 
23
33
  def test_mset
@@ -1,7 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
4
- require "lint/value_types"
1
+ require_relative "helper"
2
+ require_relative "lint/value_types"
5
3
 
6
4
  class TestDistributedCommandsOnValueTypes < Test::Unit::TestCase
7
5
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedCommandsRequiringClustering < Test::Unit::TestCase
6
4
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedConnectionHandling < Test::Unit::TestCase
6
4
 
@@ -1,41 +1,39 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedInternals < Test::Unit::TestCase
6
4
 
7
5
  include Helper::Distributed
8
6
 
9
7
  def test_provides_a_meaningful_inspect
10
- nodes = ["redis://localhost:#{PORT}/15", *NODES]
8
+ nodes = ["redis://127.0.0.1:#{PORT}/15", *NODES]
11
9
  redis = Redis::Distributed.new nodes
12
10
 
13
11
  assert_equal "#<Redis client v#{Redis::VERSION} for #{redis.nodes.map(&:id).join(', ')}>", redis.inspect
14
12
  end
15
13
 
16
14
  def test_default_as_urls
17
- nodes = ["redis://localhost:#{PORT}/15", *NODES]
15
+ nodes = ["redis://127.0.0.1:#{PORT}/15", *NODES]
18
16
  redis = Redis::Distributed.new nodes
19
- assert_equal ["redis://localhost:#{PORT}/15", *NODES], redis.nodes.map { |node| node.client.id}
17
+ assert_equal ["redis://127.0.0.1:#{PORT}/15", *NODES], redis.nodes.map { |node| node._client.id }
20
18
  end
21
19
 
22
20
  def test_default_as_config_hashes
23
21
  nodes = [OPTIONS.merge(:host => '127.0.0.1'), OPTIONS.merge(:host => 'somehost', :port => PORT.next)]
24
22
  redis = Redis::Distributed.new nodes
25
- assert_equal ["redis://127.0.0.1:#{PORT}/15","redis://somehost:#{PORT.next}/15"], redis.nodes.map { |node| node.client.id }
23
+ assert_equal ["redis://127.0.0.1:#{PORT}/15","redis://somehost:#{PORT.next}/15"], redis.nodes.map { |node| node._client.id }
26
24
  end
27
25
 
28
26
  def test_as_mix_and_match
29
27
  nodes = ["redis://127.0.0.1:7389/15", OPTIONS.merge(:host => 'somehost'), OPTIONS.merge(:host => 'somehost', :port => PORT.next)]
30
28
  redis = Redis::Distributed.new nodes
31
- assert_equal ["redis://127.0.0.1:7389/15", "redis://somehost:#{PORT}/15", "redis://somehost:#{PORT.next}/15"], redis.nodes.map { |node| node.client.id }
29
+ assert_equal ["redis://127.0.0.1:7389/15", "redis://somehost:#{PORT}/15", "redis://somehost:#{PORT.next}/15"], redis.nodes.map { |node| node._client.id }
32
30
  end
33
31
 
34
32
  def test_override_id
35
33
  nodes = [OPTIONS.merge(:host => '127.0.0.1', :id => "test"), OPTIONS.merge( :host => 'somehost', :port => PORT.next, :id => "test1")]
36
34
  redis = Redis::Distributed.new nodes
37
- assert_equal redis.nodes.first.client.id, "test"
38
- assert_equal redis.nodes.last.client.id, "test1"
35
+ assert_equal redis.nodes.first._client.id, "test"
36
+ assert_equal redis.nodes.last._client.id, "test1"
39
37
  assert_equal "#<Redis client v#{Redis::VERSION} for #{redis.nodes.map(&:id).join(', ')}>", redis.inspect
40
38
  end
41
39
 
@@ -67,13 +65,4 @@ class TestDistributedInternals < Test::Unit::TestCase
67
65
 
68
66
  assert_equal [], r2.sinter("baz:foo", "baz:bar")
69
67
  end
70
-
71
- def test_colliding_node_ids
72
- nodes = ["redis://localhost:#{PORT}/15", "redis://localhost:#{PORT}/15", *NODES]
73
-
74
- assert_raise(RuntimeError) do
75
- Redis::Distributed.new nodes
76
- end
77
- end
78
-
79
68
  end
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedKeyTags < Test::Unit::TestCase
6
4
 
@@ -8,9 +6,9 @@ class TestDistributedKeyTags < Test::Unit::TestCase
8
6
  include Helper::Distributed
9
7
 
10
8
  def test_hashes_consistently
11
- r1 = Redis::Distributed.new ["redis://localhost:#{PORT}/15", *NODES]
12
- r2 = Redis::Distributed.new ["redis://localhost:#{PORT}/15", *NODES]
13
- r3 = Redis::Distributed.new ["redis://localhost:#{PORT}/15", *NODES]
9
+ r1 = Redis::Distributed.new ["redis://127.0.0.1:#{PORT}/15", *NODES]
10
+ r2 = Redis::Distributed.new ["redis://127.0.0.1:#{PORT}/15", *NODES]
11
+ r3 = Redis::Distributed.new ["redis://127.0.0.1:#{PORT}/15", *NODES]
14
12
 
15
13
  assert_equal r1.node_for("foo").id, r2.node_for("foo").id
16
14
  assert_equal r1.node_for("foo").id, r3.node_for("foo").id
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedPersistenceControlCommands < Test::Unit::TestCase
6
4
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedPublishSubscribe < Test::Unit::TestCase
6
4
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedRemoteServerControlCommands < Test::Unit::TestCase
6
4
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedScripting < Test::Unit::TestCase
6
4
 
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedSorting < Test::Unit::TestCase
6
4
 
@@ -1,13 +1,11 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributed < Test::Unit::TestCase
6
4
 
7
5
  include Helper::Distributed
8
6
 
9
7
  def test_handle_multiple_servers
10
- @r = Redis::Distributed.new ["redis://localhost:#{PORT}/15", *NODES]
8
+ @r = Redis::Distributed.new ["redis://127.0.0.1:#{PORT}/15", *NODES]
11
9
 
12
10
  100.times do |idx|
13
11
  @r.set(idx.to_s, "foo#{idx}")
@@ -26,19 +24,19 @@ class TestDistributed < Test::Unit::TestCase
26
24
 
27
25
  @r = Redis::Distributed.new NODES, :logger => logger, :timeout => 10
28
26
 
29
- assert_equal "127.0.0.1", @r.nodes[0].client.host
30
- assert_equal PORT, @r.nodes[0].client.port
31
- assert_equal 15, @r.nodes[0].client.db
32
- assert_equal 10, @r.nodes[0].client.timeout
33
- assert_equal logger, @r.nodes[0].client.logger
27
+ assert_equal "127.0.0.1", @r.nodes[0]._client.host
28
+ assert_equal PORT, @r.nodes[0]._client.port
29
+ assert_equal 15, @r.nodes[0]._client.db
30
+ assert_equal 10, @r.nodes[0]._client.timeout
31
+ assert_equal logger, @r.nodes[0]._client.logger
34
32
 
35
33
  @r.add_node("redis://127.0.0.1:6380/14")
36
34
 
37
- assert_equal "127.0.0.1", @r.nodes[1].client.host
38
- assert_equal 6380, @r.nodes[1].client.port
39
- assert_equal 14, @r.nodes[1].client.db
40
- assert_equal 10, @r.nodes[1].client.timeout
41
- assert_equal logger, @r.nodes[1].client.logger
35
+ assert_equal "127.0.0.1", @r.nodes[1]._client.host
36
+ assert_equal 6380, @r.nodes[1]._client.port
37
+ assert_equal 14, @r.nodes[1]._client.db
38
+ assert_equal 10, @r.nodes[1]._client.timeout
39
+ assert_equal logger, @r.nodes[1]._client.logger
42
40
  end
43
41
 
44
42
  def test_pipelining_commands_cannot_be_distributed
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestDistributedTransactions < Test::Unit::TestCase
6
4
 
@@ -1,18 +1,14 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestEncoding < Test::Unit::TestCase
6
4
 
7
5
  include Helper::Client
8
6
 
9
7
  def test_returns_properly_encoded_strings
10
- if defined?(Encoding)
11
- with_external_encoding("UTF-8") do
12
- r.set "foo", "שלום"
8
+ with_external_encoding("UTF-8") do
9
+ r.set "foo", "שלום"
13
10
 
14
- assert_equal "Shalom שלום", "Shalom " + r.get("foo")
15
- end
11
+ assert_equal "Shalom שלום", "Shalom " + r.get("foo")
16
12
  end
17
13
  end
18
14
  end
@@ -1,6 +1,4 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestErrorReplies < Test::Unit::TestCase
6
4
 
@@ -47,7 +45,7 @@ class TestErrorReplies < Test::Unit::TestCase
47
45
  def test_recover_from_raise_in__call_loop
48
46
  with_reconnection_check do
49
47
  begin
50
- r.client.call_loop([:invalid_monitor]) do
48
+ r._client.call_loop([:invalid_monitor]) do
51
49
  assert false # Should never be executed
52
50
  end
53
51
  rescue => ex
@@ -1,11 +1,8 @@
1
- # encoding: UTF-8
2
-
3
- require File.expand_path("helper", File.dirname(__FILE__))
1
+ require_relative "helper"
4
2
 
5
3
  class TestForkSafety < Test::Unit::TestCase
6
4
 
7
5
  include Helper::Client
8
- include Helper::Skipable
9
6
 
10
7
  driver(:ruby, :hiredis) do
11
8
  def test_fork_safety
@@ -32,7 +29,6 @@ class TestForkSafety < Test::Unit::TestCase
32
29
 
33
30
  rescue NotImplementedError => error
34
31
  raise unless error.message =~ /fork is not available/
35
- return skip(error.message)
36
32
  end
37
33
 
38
34
  def test_fork_safety_with_enabled_inherited_socket
@@ -59,7 +55,6 @@ class TestForkSafety < Test::Unit::TestCase
59
55
 
60
56
  rescue NotImplementedError => error
61
57
  raise unless error.message =~ /fork is not available/
62
- return skip(error.message)
63
58
  end
64
59
  end
65
60
  end