redis 4.0.1 → 4.1.0
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.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +38 -0
 - data/README.md +46 -1
 - data/lib/redis/client.rb +29 -12
 - data/lib/redis/cluster/command.rb +81 -0
 - data/lib/redis/cluster/command_loader.rb +34 -0
 - data/lib/redis/cluster/key_slot_converter.rb +72 -0
 - data/lib/redis/cluster/node.rb +104 -0
 - data/lib/redis/cluster/node_key.rb +35 -0
 - data/lib/redis/cluster/node_loader.rb +37 -0
 - data/lib/redis/cluster/option.rb +77 -0
 - data/lib/redis/cluster/slot.rb +69 -0
 - data/lib/redis/cluster/slot_loader.rb +49 -0
 - data/lib/redis/cluster.rb +286 -0
 - data/lib/redis/connection/ruby.rb +5 -2
 - data/lib/redis/distributed.rb +13 -6
 - data/lib/redis/errors.rb +46 -0
 - data/lib/redis/pipeline.rb +9 -1
 - data/lib/redis/version.rb +1 -1
 - data/lib/redis.rb +692 -25
 - metadata +27 -184
 - data/.gitignore +0 -16
 - data/.travis/Gemfile +0 -13
 - data/.travis.yml +0 -73
 - data/.yardopts +0 -3
 - data/Gemfile +0 -3
 - data/benchmarking/logging.rb +0 -71
 - data/benchmarking/pipeline.rb +0 -51
 - data/benchmarking/speed.rb +0 -21
 - data/benchmarking/suite.rb +0 -24
 - data/benchmarking/worker.rb +0 -71
 - data/bors.toml +0 -14
 - data/examples/basic.rb +0 -15
 - data/examples/consistency.rb +0 -114
 - data/examples/dist_redis.rb +0 -43
 - data/examples/incr-decr.rb +0 -17
 - data/examples/list.rb +0 -26
 - data/examples/pubsub.rb +0 -37
 - data/examples/sentinel/sentinel.conf +0 -9
 - data/examples/sentinel/start +0 -49
 - data/examples/sentinel.rb +0 -41
 - data/examples/sets.rb +0 -36
 - data/examples/unicorn/config.ru +0 -3
 - data/examples/unicorn/unicorn.rb +0 -20
 - data/makefile +0 -42
 - data/redis.gemspec +0 -42
 - data/test/bitpos_test.rb +0 -63
 - data/test/blocking_commands_test.rb +0 -40
 - data/test/client_test.rb +0 -59
 - data/test/command_map_test.rb +0 -28
 - data/test/commands_on_hashes_test.rb +0 -19
 - data/test/commands_on_hyper_log_log_test.rb +0 -19
 - data/test/commands_on_lists_test.rb +0 -18
 - data/test/commands_on_sets_test.rb +0 -75
 - data/test/commands_on_sorted_sets_test.rb +0 -150
 - data/test/commands_on_strings_test.rb +0 -99
 - data/test/commands_on_value_types_test.rb +0 -171
 - data/test/connection_handling_test.rb +0 -275
 - data/test/connection_test.rb +0 -57
 - data/test/db/.gitkeep +0 -0
 - data/test/distributed_blocking_commands_test.rb +0 -44
 - data/test/distributed_commands_on_hashes_test.rb +0 -8
 - data/test/distributed_commands_on_hyper_log_log_test.rb +0 -31
 - data/test/distributed_commands_on_lists_test.rb +0 -20
 - data/test/distributed_commands_on_sets_test.rb +0 -106
 - data/test/distributed_commands_on_sorted_sets_test.rb +0 -16
 - data/test/distributed_commands_on_strings_test.rb +0 -69
 - data/test/distributed_commands_on_value_types_test.rb +0 -93
 - data/test/distributed_commands_requiring_clustering_test.rb +0 -162
 - data/test/distributed_connection_handling_test.rb +0 -21
 - data/test/distributed_internals_test.rb +0 -68
 - data/test/distributed_key_tags_test.rb +0 -50
 - data/test/distributed_persistence_control_commands_test.rb +0 -24
 - data/test/distributed_publish_subscribe_test.rb +0 -90
 - data/test/distributed_remote_server_control_commands_test.rb +0 -64
 - data/test/distributed_scripting_test.rb +0 -100
 - data/test/distributed_sorting_test.rb +0 -18
 - data/test/distributed_test.rb +0 -56
 - data/test/distributed_transactions_test.rb +0 -30
 - data/test/encoding_test.rb +0 -14
 - data/test/error_replies_test.rb +0 -57
 - data/test/fork_safety_test.rb +0 -60
 - data/test/helper.rb +0 -201
 - data/test/helper_test.rb +0 -22
 - data/test/internals_test.rb +0 -389
 - data/test/lint/blocking_commands.rb +0 -150
 - data/test/lint/hashes.rb +0 -162
 - data/test/lint/hyper_log_log.rb +0 -60
 - data/test/lint/lists.rb +0 -143
 - data/test/lint/sets.rb +0 -140
 - data/test/lint/sorted_sets.rb +0 -316
 - data/test/lint/strings.rb +0 -246
 - data/test/lint/value_types.rb +0 -130
 - data/test/persistence_control_commands_test.rb +0 -24
 - data/test/pipelining_commands_test.rb +0 -238
 - data/test/publish_subscribe_test.rb +0 -280
 - data/test/remote_server_control_commands_test.rb +0 -175
 - data/test/scanning_test.rb +0 -407
 - data/test/scripting_test.rb +0 -76
 - data/test/sentinel_command_test.rb +0 -78
 - data/test/sentinel_test.rb +0 -253
 - data/test/sorting_test.rb +0 -57
 - data/test/ssl_test.rb +0 -69
 - data/test/support/connection/hiredis.rb +0 -1
 - data/test/support/connection/ruby.rb +0 -1
 - data/test/support/connection/synchrony.rb +0 -17
 - data/test/support/redis_mock.rb +0 -130
 - data/test/support/ssl/gen_certs.sh +0 -31
 - data/test/support/ssl/trusted-ca.crt +0 -25
 - data/test/support/ssl/trusted-ca.key +0 -27
 - data/test/support/ssl/trusted-cert.crt +0 -81
 - data/test/support/ssl/trusted-cert.key +0 -28
 - data/test/support/ssl/untrusted-ca.crt +0 -26
 - data/test/support/ssl/untrusted-ca.key +0 -27
 - data/test/support/ssl/untrusted-cert.crt +0 -82
 - data/test/support/ssl/untrusted-cert.key +0 -28
 - data/test/support/wire/synchrony.rb +0 -24
 - data/test/support/wire/thread.rb +0 -5
 - data/test/synchrony_driver.rb +0 -85
 - data/test/test.conf.erb +0 -9
 - data/test/thread_safety_test.rb +0 -60
 - data/test/transactions_test.rb +0 -262
 - data/test/unknown_commands_test.rb +0 -12
 - data/test/url_param_test.rb +0 -136
 
    
        data/test/scanning_test.rb
    DELETED
    
    | 
         @@ -1,407 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class TestScanning < Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              include Helper::Client
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              def test_scan_basic
         
     | 
| 
       8 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       9 
     | 
    
         
            -
                  r.debug :populate, 1000
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                  cursor = 0
         
     | 
| 
       12 
     | 
    
         
            -
                  all_keys   = []
         
     | 
| 
       13 
     | 
    
         
            -
                  loop {
         
     | 
| 
       14 
     | 
    
         
            -
                    cursor, keys = r.scan cursor
         
     | 
| 
       15 
     | 
    
         
            -
                    all_keys += keys
         
     | 
| 
       16 
     | 
    
         
            -
                    break if cursor == "0"
         
     | 
| 
       17 
     | 
    
         
            -
                  }
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  assert_equal 1000, all_keys.uniq.size
         
     | 
| 
       20 
     | 
    
         
            -
                end
         
     | 
| 
       21 
     | 
    
         
            -
              end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
              def test_scan_count
         
     | 
| 
       24 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       25 
     | 
    
         
            -
                  r.debug :populate, 1000
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                  cursor = 0
         
     | 
| 
       28 
     | 
    
         
            -
                  all_keys   = []
         
     | 
| 
       29 
     | 
    
         
            -
                  loop {
         
     | 
| 
       30 
     | 
    
         
            -
                    cursor, keys = r.scan cursor, :count => 5
         
     | 
| 
       31 
     | 
    
         
            -
                    all_keys += keys
         
     | 
| 
       32 
     | 
    
         
            -
                    break if cursor == "0"
         
     | 
| 
       33 
     | 
    
         
            -
                  }
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                  assert_equal 1000, all_keys.uniq.size
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
              def test_scan_match
         
     | 
| 
       40 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       41 
     | 
    
         
            -
                  r.debug :populate, 1000
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                  cursor = 0
         
     | 
| 
       44 
     | 
    
         
            -
                  all_keys   = []
         
     | 
| 
       45 
     | 
    
         
            -
                  loop {
         
     | 
| 
       46 
     | 
    
         
            -
                    cursor, keys = r.scan cursor, :match => "key:1??"
         
     | 
| 
       47 
     | 
    
         
            -
                    all_keys += keys
         
     | 
| 
       48 
     | 
    
         
            -
                    break if cursor == "0"
         
     | 
| 
       49 
     | 
    
         
            -
                  }
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                  assert_equal 100, all_keys.uniq.size
         
     | 
| 
       52 
     | 
    
         
            -
                end
         
     | 
| 
       53 
     | 
    
         
            -
              end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
              def test_scan_each_enumerator
         
     | 
| 
       56 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                  r.debug :populate, 1000
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                  scan_enumerator = r.scan_each
         
     | 
| 
       61 
     | 
    
         
            -
                  assert_equal true, scan_enumerator.is_a?(::Enumerator)
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                  keys_from_scan = scan_enumerator.to_a.uniq
         
     | 
| 
       64 
     | 
    
         
            -
                  all_keys = r.keys "*"
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.sort
         
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
       68 
     | 
    
         
            -
              end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
              def test_scan_each_enumerator_match
         
     | 
| 
       71 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                  r.debug :populate, 1000
         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                  keys_from_scan = r.scan_each(:match => "key:1??").to_a.uniq
         
     | 
| 
       76 
     | 
    
         
            -
                  all_keys = r.keys "key:1??"
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.sort
         
     | 
| 
       79 
     | 
    
         
            -
                end
         
     | 
| 
       80 
     | 
    
         
            -
              end
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
              def test_scan_each_block
         
     | 
| 
       83 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
                  r.debug :populate, 100
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
                  keys_from_scan   = []
         
     | 
| 
       88 
     | 
    
         
            -
                  r.scan_each {|key|
         
     | 
| 
       89 
     | 
    
         
            -
                    keys_from_scan << key
         
     | 
| 
       90 
     | 
    
         
            -
                  }
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
                  all_keys = r.keys "*"
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.uniq.sort
         
     | 
| 
       95 
     | 
    
         
            -
                end
         
     | 
| 
       96 
     | 
    
         
            -
              end
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
              def test_scan_each_block_match
         
     | 
| 
       99 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
                  r.debug :populate, 100
         
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
                  keys_from_scan   = []
         
     | 
| 
       104 
     | 
    
         
            -
                  r.scan_each(:match => "key:1?") {|key|
         
     | 
| 
       105 
     | 
    
         
            -
                    keys_from_scan << key
         
     | 
| 
       106 
     | 
    
         
            -
                  }
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
                  all_keys = r.keys "key:1?"
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.uniq.sort
         
     | 
| 
       111 
     | 
    
         
            -
                end
         
     | 
| 
       112 
     | 
    
         
            -
              end
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
              def test_sscan_with_encoding
         
     | 
| 
       115 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       116 
     | 
    
         
            -
                  [:intset, :hashtable].each do |enc|
         
     | 
| 
       117 
     | 
    
         
            -
                    r.del "set"
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
                    prefix = ""
         
     | 
| 
       120 
     | 
    
         
            -
                    prefix = "ele:" if enc == :hashtable
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
                    elements = []
         
     | 
| 
       123 
     | 
    
         
            -
                    100.times { |j| elements << "#{prefix}#{j}" }
         
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
                    r.sadd "set", elements
         
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
                    assert_equal enc.to_s, r.object("encoding", "set")
         
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
                    cursor = 0
         
     | 
| 
       130 
     | 
    
         
            -
                    all_keys   = []
         
     | 
| 
       131 
     | 
    
         
            -
                    loop {
         
     | 
| 
       132 
     | 
    
         
            -
                      cursor, keys = r.sscan "set", cursor
         
     | 
| 
       133 
     | 
    
         
            -
                      all_keys += keys
         
     | 
| 
       134 
     | 
    
         
            -
                      break if cursor == "0"
         
     | 
| 
       135 
     | 
    
         
            -
                    }
         
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
                    assert_equal 100, all_keys.uniq.size
         
     | 
| 
       138 
     | 
    
         
            -
                  end
         
     | 
| 
       139 
     | 
    
         
            -
                end
         
     | 
| 
       140 
     | 
    
         
            -
              end
         
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
              def test_sscan_each_enumerator
         
     | 
| 
       143 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       144 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       145 
     | 
    
         
            -
                  100.times { |j| elements << "ele:#{j}" }
         
     | 
| 
       146 
     | 
    
         
            -
                  r.sadd "set", elements
         
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
                  scan_enumerator = r.sscan_each("set")
         
     | 
| 
       149 
     | 
    
         
            -
                  assert_equal true, scan_enumerator.is_a?(::Enumerator)
         
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
                  keys_from_scan = scan_enumerator.to_a.uniq
         
     | 
| 
       152 
     | 
    
         
            -
                  all_keys = r.smembers("set")
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.sort
         
     | 
| 
       155 
     | 
    
         
            -
                end
         
     | 
| 
       156 
     | 
    
         
            -
              end
         
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
              def test_sscan_each_enumerator_match
         
     | 
| 
       159 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       160 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       161 
     | 
    
         
            -
                  100.times { |j| elements << "ele:#{j}" }
         
     | 
| 
       162 
     | 
    
         
            -
                  r.sadd "set", elements
         
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
                  keys_from_scan = r.sscan_each("set", :match => "ele:1?").to_a.uniq
         
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
                  all_keys = r.smembers("set").grep(/^ele:1.$/)
         
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.sort
         
     | 
| 
       169 
     | 
    
         
            -
                end
         
     | 
| 
       170 
     | 
    
         
            -
              end
         
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
       172 
     | 
    
         
            -
              def test_sscan_each_enumerator_block
         
     | 
| 
       173 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       174 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       175 
     | 
    
         
            -
                  100.times { |j| elements << "ele:#{j}" }
         
     | 
| 
       176 
     | 
    
         
            -
                  r.sadd "set", elements
         
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
       178 
     | 
    
         
            -
                  keys_from_scan = []
         
     | 
| 
       179 
     | 
    
         
            -
                  r.sscan_each("set") do |key|
         
     | 
| 
       180 
     | 
    
         
            -
                    keys_from_scan << key
         
     | 
| 
       181 
     | 
    
         
            -
                  end
         
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
     | 
    
         
            -
                  all_keys = r.smembers("set")
         
     | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
       185 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.uniq.sort
         
     | 
| 
       186 
     | 
    
         
            -
                end
         
     | 
| 
       187 
     | 
    
         
            -
              end
         
     | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
       189 
     | 
    
         
            -
              def test_sscan_each_enumerator_block_match
         
     | 
| 
       190 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       191 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       192 
     | 
    
         
            -
                  100.times { |j| elements << "ele:#{j}" }
         
     | 
| 
       193 
     | 
    
         
            -
                  r.sadd "set", elements
         
     | 
| 
       194 
     | 
    
         
            -
             
     | 
| 
       195 
     | 
    
         
            -
                  keys_from_scan = []
         
     | 
| 
       196 
     | 
    
         
            -
                  r.sscan_each("set", :match => "ele:1?") do |key|
         
     | 
| 
       197 
     | 
    
         
            -
                    keys_from_scan << key
         
     | 
| 
       198 
     | 
    
         
            -
                  end
         
     | 
| 
       199 
     | 
    
         
            -
             
     | 
| 
       200 
     | 
    
         
            -
                  all_keys = r.smembers("set").grep(/^ele:1.$/)
         
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.uniq.sort
         
     | 
| 
       203 
     | 
    
         
            -
                end
         
     | 
| 
       204 
     | 
    
         
            -
              end
         
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
              def test_hscan_with_encoding
         
     | 
| 
       207 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       208 
     | 
    
         
            -
                  [:ziplist, :hashtable].each do |enc|
         
     | 
| 
       209 
     | 
    
         
            -
                    r.del "set"
         
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
       211 
     | 
    
         
            -
                    count = 1000
         
     | 
| 
       212 
     | 
    
         
            -
                    count = 30 if enc == :ziplist
         
     | 
| 
       213 
     | 
    
         
            -
             
     | 
| 
       214 
     | 
    
         
            -
                    elements = []
         
     | 
| 
       215 
     | 
    
         
            -
                    count.times { |j| elements << "key:#{j}" << j.to_s }
         
     | 
| 
       216 
     | 
    
         
            -
             
     | 
| 
       217 
     | 
    
         
            -
                    r.hmset "hash", *elements
         
     | 
| 
       218 
     | 
    
         
            -
             
     | 
| 
       219 
     | 
    
         
            -
                    assert_equal enc.to_s, r.object("encoding", "hash")
         
     | 
| 
       220 
     | 
    
         
            -
             
     | 
| 
       221 
     | 
    
         
            -
                    cursor = 0
         
     | 
| 
       222 
     | 
    
         
            -
                    all_key_values   = []
         
     | 
| 
       223 
     | 
    
         
            -
                    loop {
         
     | 
| 
       224 
     | 
    
         
            -
                      cursor, key_values = r.hscan "hash", cursor
         
     | 
| 
       225 
     | 
    
         
            -
                      all_key_values.concat key_values
         
     | 
| 
       226 
     | 
    
         
            -
                      break if cursor == "0"
         
     | 
| 
       227 
     | 
    
         
            -
                    }
         
     | 
| 
       228 
     | 
    
         
            -
             
     | 
| 
       229 
     | 
    
         
            -
                    keys2 = []
         
     | 
| 
       230 
     | 
    
         
            -
                    all_key_values.each do |k, v|
         
     | 
| 
       231 
     | 
    
         
            -
                      assert_equal "key:#{v}", k
         
     | 
| 
       232 
     | 
    
         
            -
                      keys2 << k
         
     | 
| 
       233 
     | 
    
         
            -
                    end
         
     | 
| 
       234 
     | 
    
         
            -
             
     | 
| 
       235 
     | 
    
         
            -
                    assert_equal count, keys2.uniq.size
         
     | 
| 
       236 
     | 
    
         
            -
                  end
         
     | 
| 
       237 
     | 
    
         
            -
                end
         
     | 
| 
       238 
     | 
    
         
            -
              end
         
     | 
| 
       239 
     | 
    
         
            -
             
     | 
| 
       240 
     | 
    
         
            -
              def test_hscan_each_enumerator
         
     | 
| 
       241 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       242 
     | 
    
         
            -
                  count = 1000
         
     | 
| 
       243 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       244 
     | 
    
         
            -
                  count.times { |j| elements << "key:#{j}" << j.to_s }
         
     | 
| 
       245 
     | 
    
         
            -
                  r.hmset "hash", *elements
         
     | 
| 
       246 
     | 
    
         
            -
             
     | 
| 
       247 
     | 
    
         
            -
                  scan_enumerator = r.hscan_each("hash")
         
     | 
| 
       248 
     | 
    
         
            -
                  assert_equal true, scan_enumerator.is_a?(::Enumerator)
         
     | 
| 
       249 
     | 
    
         
            -
             
     | 
| 
       250 
     | 
    
         
            -
                  keys_from_scan = scan_enumerator.to_a.uniq
         
     | 
| 
       251 
     | 
    
         
            -
                  all_keys = r.hgetall("hash").to_a
         
     | 
| 
       252 
     | 
    
         
            -
             
     | 
| 
       253 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.sort
         
     | 
| 
       254 
     | 
    
         
            -
                end
         
     | 
| 
       255 
     | 
    
         
            -
              end
         
     | 
| 
       256 
     | 
    
         
            -
             
     | 
| 
       257 
     | 
    
         
            -
              def test_hscan_each_enumerator_match
         
     | 
| 
       258 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       259 
     | 
    
         
            -
                  count = 100
         
     | 
| 
       260 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       261 
     | 
    
         
            -
                  count.times { |j| elements << "key:#{j}" << j.to_s }
         
     | 
| 
       262 
     | 
    
         
            -
                  r.hmset "hash", *elements
         
     | 
| 
       263 
     | 
    
         
            -
             
     | 
| 
       264 
     | 
    
         
            -
                  keys_from_scan = r.hscan_each("hash", :match => "key:1?").to_a.uniq
         
     | 
| 
       265 
     | 
    
         
            -
                  all_keys = r.hgetall("hash").to_a.select{|k,v| k =~ /^key:1.$/}
         
     | 
| 
       266 
     | 
    
         
            -
             
     | 
| 
       267 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.sort
         
     | 
| 
       268 
     | 
    
         
            -
                end
         
     | 
| 
       269 
     | 
    
         
            -
              end
         
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
              def test_hscan_each_block
         
     | 
| 
       272 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       273 
     | 
    
         
            -
                  count = 1000
         
     | 
| 
       274 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       275 
     | 
    
         
            -
                  count.times { |j| elements << "key:#{j}" << j.to_s }
         
     | 
| 
       276 
     | 
    
         
            -
                  r.hmset "hash", *elements
         
     | 
| 
       277 
     | 
    
         
            -
             
     | 
| 
       278 
     | 
    
         
            -
                  keys_from_scan = []
         
     | 
| 
       279 
     | 
    
         
            -
                  r.hscan_each("hash") do |field, value|
         
     | 
| 
       280 
     | 
    
         
            -
                    keys_from_scan << [field, value]
         
     | 
| 
       281 
     | 
    
         
            -
                  end
         
     | 
| 
       282 
     | 
    
         
            -
                  all_keys = r.hgetall("hash").to_a
         
     | 
| 
       283 
     | 
    
         
            -
             
     | 
| 
       284 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.uniq.sort
         
     | 
| 
       285 
     | 
    
         
            -
                end
         
     | 
| 
       286 
     | 
    
         
            -
              end
         
     | 
| 
       287 
     | 
    
         
            -
             
     | 
| 
       288 
     | 
    
         
            -
              def test_hscan_each_block_match
         
     | 
| 
       289 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       290 
     | 
    
         
            -
                  count = 1000
         
     | 
| 
       291 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       292 
     | 
    
         
            -
                  count.times { |j| elements << "key:#{j}" << j.to_s }
         
     | 
| 
       293 
     | 
    
         
            -
                  r.hmset "hash", *elements
         
     | 
| 
       294 
     | 
    
         
            -
             
     | 
| 
       295 
     | 
    
         
            -
                  keys_from_scan = []
         
     | 
| 
       296 
     | 
    
         
            -
                  r.hscan_each("hash", :match => "key:1?") do |field, value|
         
     | 
| 
       297 
     | 
    
         
            -
                    keys_from_scan << [field, value]
         
     | 
| 
       298 
     | 
    
         
            -
                  end
         
     | 
| 
       299 
     | 
    
         
            -
                  all_keys = r.hgetall("hash").to_a.select{|k,v| k =~ /^key:1.$/}
         
     | 
| 
       300 
     | 
    
         
            -
             
     | 
| 
       301 
     | 
    
         
            -
                  assert all_keys.sort == keys_from_scan.uniq.sort
         
     | 
| 
       302 
     | 
    
         
            -
                end
         
     | 
| 
       303 
     | 
    
         
            -
              end
         
     | 
| 
       304 
     | 
    
         
            -
             
     | 
| 
       305 
     | 
    
         
            -
              def test_zscan_with_encoding
         
     | 
| 
       306 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       307 
     | 
    
         
            -
                  [:ziplist, :skiplist].each do |enc|
         
     | 
| 
       308 
     | 
    
         
            -
                    r.del "zset"
         
     | 
| 
       309 
     | 
    
         
            -
             
     | 
| 
       310 
     | 
    
         
            -
                    count = 1000
         
     | 
| 
       311 
     | 
    
         
            -
                    count = 30 if enc == :ziplist
         
     | 
| 
       312 
     | 
    
         
            -
             
     | 
| 
       313 
     | 
    
         
            -
                    elements = []
         
     | 
| 
       314 
     | 
    
         
            -
                    count.times { |j| elements << j << "key:#{j}" }
         
     | 
| 
       315 
     | 
    
         
            -
             
     | 
| 
       316 
     | 
    
         
            -
                    r.zadd "zset", elements
         
     | 
| 
       317 
     | 
    
         
            -
             
     | 
| 
       318 
     | 
    
         
            -
                    assert_equal enc.to_s, r.object("encoding", "zset")
         
     | 
| 
       319 
     | 
    
         
            -
             
     | 
| 
       320 
     | 
    
         
            -
                    cursor = 0
         
     | 
| 
       321 
     | 
    
         
            -
                    all_key_scores   = []
         
     | 
| 
       322 
     | 
    
         
            -
                    loop {
         
     | 
| 
       323 
     | 
    
         
            -
                      cursor, key_scores = r.zscan "zset", cursor
         
     | 
| 
       324 
     | 
    
         
            -
                      all_key_scores.concat  key_scores
         
     | 
| 
       325 
     | 
    
         
            -
                      break if cursor == "0"
         
     | 
| 
       326 
     | 
    
         
            -
                    }
         
     | 
| 
       327 
     | 
    
         
            -
             
     | 
| 
       328 
     | 
    
         
            -
                    keys2 = []
         
     | 
| 
       329 
     | 
    
         
            -
                    all_key_scores.each do |k, v|
         
     | 
| 
       330 
     | 
    
         
            -
                      assert_equal true, v.is_a?(Float)
         
     | 
| 
       331 
     | 
    
         
            -
                      assert_equal "key:#{Integer(v)}", k
         
     | 
| 
       332 
     | 
    
         
            -
                      keys2 << k
         
     | 
| 
       333 
     | 
    
         
            -
                    end
         
     | 
| 
       334 
     | 
    
         
            -
             
     | 
| 
       335 
     | 
    
         
            -
                    assert_equal count, keys2.uniq.size
         
     | 
| 
       336 
     | 
    
         
            -
                  end
         
     | 
| 
       337 
     | 
    
         
            -
                end
         
     | 
| 
       338 
     | 
    
         
            -
              end
         
     | 
| 
       339 
     | 
    
         
            -
             
     | 
| 
       340 
     | 
    
         
            -
              def test_zscan_each_enumerator
         
     | 
| 
       341 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       342 
     | 
    
         
            -
                  count = 1000
         
     | 
| 
       343 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       344 
     | 
    
         
            -
                  count.times { |j| elements << j << "key:#{j}" }
         
     | 
| 
       345 
     | 
    
         
            -
                  r.zadd "zset", elements
         
     | 
| 
       346 
     | 
    
         
            -
             
     | 
| 
       347 
     | 
    
         
            -
                  scan_enumerator = r.zscan_each "zset"
         
     | 
| 
       348 
     | 
    
         
            -
                  assert_equal true, scan_enumerator.is_a?(::Enumerator)
         
     | 
| 
       349 
     | 
    
         
            -
             
     | 
| 
       350 
     | 
    
         
            -
                  scores_from_scan = scan_enumerator.to_a.uniq
         
     | 
| 
       351 
     | 
    
         
            -
                  member_scores = r.zrange("zset", 0, -1, :with_scores => true)
         
     | 
| 
       352 
     | 
    
         
            -
             
     | 
| 
       353 
     | 
    
         
            -
                  assert member_scores.sort == scores_from_scan.sort
         
     | 
| 
       354 
     | 
    
         
            -
                end
         
     | 
| 
       355 
     | 
    
         
            -
              end
         
     | 
| 
       356 
     | 
    
         
            -
             
     | 
| 
       357 
     | 
    
         
            -
              def test_zscan_each_enumerator_match
         
     | 
| 
       358 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       359 
     | 
    
         
            -
                  count = 1000
         
     | 
| 
       360 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       361 
     | 
    
         
            -
                  count.times { |j| elements << j << "key:#{j}" }
         
     | 
| 
       362 
     | 
    
         
            -
                  r.zadd "zset", elements
         
     | 
| 
       363 
     | 
    
         
            -
             
     | 
| 
       364 
     | 
    
         
            -
                  scores_from_scan = r.zscan_each("zset", :match => "key:1??").to_a.uniq
         
     | 
| 
       365 
     | 
    
         
            -
                  member_scores = r.zrange("zset", 0, -1, :with_scores => true)
         
     | 
| 
       366 
     | 
    
         
            -
                  filtered_members = member_scores.select{|k,s| k =~ /^key:1..$/}
         
     | 
| 
       367 
     | 
    
         
            -
             
     | 
| 
       368 
     | 
    
         
            -
                  assert filtered_members.sort == scores_from_scan.sort
         
     | 
| 
       369 
     | 
    
         
            -
                end
         
     | 
| 
       370 
     | 
    
         
            -
              end
         
     | 
| 
       371 
     | 
    
         
            -
             
     | 
| 
       372 
     | 
    
         
            -
              def test_zscan_each_block
         
     | 
| 
       373 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       374 
     | 
    
         
            -
                  count = 1000
         
     | 
| 
       375 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       376 
     | 
    
         
            -
                  count.times { |j| elements << j << "key:#{j}" }
         
     | 
| 
       377 
     | 
    
         
            -
                  r.zadd "zset", elements
         
     | 
| 
       378 
     | 
    
         
            -
             
     | 
| 
       379 
     | 
    
         
            -
                  scores_from_scan = []
         
     | 
| 
       380 
     | 
    
         
            -
                  r.zscan_each("zset") do |member, score|
         
     | 
| 
       381 
     | 
    
         
            -
                    scores_from_scan << [member, score]
         
     | 
| 
       382 
     | 
    
         
            -
                  end
         
     | 
| 
       383 
     | 
    
         
            -
                  member_scores = r.zrange("zset", 0, -1, :with_scores => true)
         
     | 
| 
       384 
     | 
    
         
            -
             
     | 
| 
       385 
     | 
    
         
            -
                  assert member_scores.sort == scores_from_scan.sort
         
     | 
| 
       386 
     | 
    
         
            -
                end
         
     | 
| 
       387 
     | 
    
         
            -
              end
         
     | 
| 
       388 
     | 
    
         
            -
             
     | 
| 
       389 
     | 
    
         
            -
              def test_zscan_each_block_match
         
     | 
| 
       390 
     | 
    
         
            -
                target_version "2.7.105" do
         
     | 
| 
       391 
     | 
    
         
            -
                  count = 1000
         
     | 
| 
       392 
     | 
    
         
            -
                  elements = []
         
     | 
| 
       393 
     | 
    
         
            -
                  count.times { |j| elements << j << "key:#{j}" }
         
     | 
| 
       394 
     | 
    
         
            -
                  r.zadd "zset", elements
         
     | 
| 
       395 
     | 
    
         
            -
             
     | 
| 
       396 
     | 
    
         
            -
                  scores_from_scan = []
         
     | 
| 
       397 
     | 
    
         
            -
                  r.zscan_each("zset", :match => "key:1??") do |member, score|
         
     | 
| 
       398 
     | 
    
         
            -
                    scores_from_scan << [member, score]
         
     | 
| 
       399 
     | 
    
         
            -
                  end
         
     | 
| 
       400 
     | 
    
         
            -
                  member_scores = r.zrange("zset", 0, -1, :with_scores => true)
         
     | 
| 
       401 
     | 
    
         
            -
                  filtered_members = member_scores.select{|k,s| k =~ /^key:1..$/}
         
     | 
| 
       402 
     | 
    
         
            -
             
     | 
| 
       403 
     | 
    
         
            -
                  assert filtered_members.sort == scores_from_scan.sort
         
     | 
| 
       404 
     | 
    
         
            -
                end
         
     | 
| 
       405 
     | 
    
         
            -
              end
         
     | 
| 
       406 
     | 
    
         
            -
             
     | 
| 
       407 
     | 
    
         
            -
            end
         
     | 
    
        data/test/scripting_test.rb
    DELETED
    
    | 
         @@ -1,76 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class TestScripting < Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              include Helper::Client
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              def to_sha(script)
         
     | 
| 
       8 
     | 
    
         
            -
                r.script(:load, script)
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              def test_script_exists
         
     | 
| 
       12 
     | 
    
         
            -
                target_version "2.5.9" do # 2.6-rc1
         
     | 
| 
       13 
     | 
    
         
            -
                  a = to_sha("return 1")
         
     | 
| 
       14 
     | 
    
         
            -
                  b = a.succ
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  assert_equal true, r.script(:exists, a)
         
     | 
| 
       17 
     | 
    
         
            -
                  assert_equal false, r.script(:exists, b)
         
     | 
| 
       18 
     | 
    
         
            -
                  assert_equal [true], r.script(:exists, [a])
         
     | 
| 
       19 
     | 
    
         
            -
                  assert_equal [false], r.script(:exists, [b])
         
     | 
| 
       20 
     | 
    
         
            -
                  assert_equal [true, false], r.script(:exists, [a, b])
         
     | 
| 
       21 
     | 
    
         
            -
                end
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              def test_script_flush
         
     | 
| 
       25 
     | 
    
         
            -
                target_version "2.5.9" do # 2.6-rc1
         
     | 
| 
       26 
     | 
    
         
            -
                  sha = to_sha("return 1")
         
     | 
| 
       27 
     | 
    
         
            -
                  assert r.script(:exists, sha)
         
     | 
| 
       28 
     | 
    
         
            -
                  assert_equal "OK", r.script(:flush)
         
     | 
| 
       29 
     | 
    
         
            -
                  assert !r.script(:exists, sha)
         
     | 
| 
       30 
     | 
    
         
            -
                end
         
     | 
| 
       31 
     | 
    
         
            -
              end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
              def test_script_kill
         
     | 
| 
       34 
     | 
    
         
            -
                target_version "2.5.9" do # 2.6-rc1
         
     | 
| 
       35 
     | 
    
         
            -
                  redis_mock(:script => lambda { |arg| "+#{arg.upcase}" }) do |redis|
         
     | 
| 
       36 
     | 
    
         
            -
                    assert_equal "KILL", redis.script(:kill)
         
     | 
| 
       37 
     | 
    
         
            -
                  end
         
     | 
| 
       38 
     | 
    
         
            -
                end
         
     | 
| 
       39 
     | 
    
         
            -
              end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
              def test_eval
         
     | 
| 
       42 
     | 
    
         
            -
                target_version "2.5.9" do # 2.6-rc1
         
     | 
| 
       43 
     | 
    
         
            -
                  assert_equal 0, r.eval("return #KEYS")
         
     | 
| 
       44 
     | 
    
         
            -
                  assert_equal 0, r.eval("return #ARGV")
         
     | 
| 
       45 
     | 
    
         
            -
                  assert_equal ["k1", "k2"], r.eval("return KEYS", ["k1", "k2"])
         
     | 
| 
       46 
     | 
    
         
            -
                  assert_equal ["a1", "a2"], r.eval("return ARGV", [], ["a1", "a2"])
         
     | 
| 
       47 
     | 
    
         
            -
                end
         
     | 
| 
       48 
     | 
    
         
            -
              end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
              def test_eval_with_options_hash
         
     | 
| 
       51 
     | 
    
         
            -
                target_version "2.5.9" do # 2.6-rc1
         
     | 
| 
       52 
     | 
    
         
            -
                  assert_equal 0, r.eval("return #KEYS", {})
         
     | 
| 
       53 
     | 
    
         
            -
                  assert_equal 0, r.eval("return #ARGV", {})
         
     | 
| 
       54 
     | 
    
         
            -
                  assert_equal ["k1", "k2"], r.eval("return KEYS", { :keys => ["k1", "k2"] })
         
     | 
| 
       55 
     | 
    
         
            -
                  assert_equal ["a1", "a2"], r.eval("return ARGV", { :argv => ["a1", "a2"] })
         
     | 
| 
       56 
     | 
    
         
            -
                end
         
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
              def test_evalsha
         
     | 
| 
       60 
     | 
    
         
            -
                target_version "2.5.9" do # 2.6-rc1
         
     | 
| 
       61 
     | 
    
         
            -
                  assert_equal 0, r.evalsha(to_sha("return #KEYS"))
         
     | 
| 
       62 
     | 
    
         
            -
                  assert_equal 0, r.evalsha(to_sha("return #ARGV"))
         
     | 
| 
       63 
     | 
    
         
            -
                  assert_equal ["k1", "k2"], r.evalsha(to_sha("return KEYS"), ["k1", "k2"])
         
     | 
| 
       64 
     | 
    
         
            -
                  assert_equal ["a1", "a2"], r.evalsha(to_sha("return ARGV"), [], ["a1", "a2"])
         
     | 
| 
       65 
     | 
    
         
            -
                end
         
     | 
| 
       66 
     | 
    
         
            -
              end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
              def test_evalsha_with_options_hash
         
     | 
| 
       69 
     | 
    
         
            -
                target_version "2.5.9" do # 2.6-rc1
         
     | 
| 
       70 
     | 
    
         
            -
                  assert_equal 0, r.evalsha(to_sha("return #KEYS"), {})
         
     | 
| 
       71 
     | 
    
         
            -
                  assert_equal 0, r.evalsha(to_sha("return #ARGV"), {})
         
     | 
| 
       72 
     | 
    
         
            -
                  assert_equal ["k1", "k2"], r.evalsha(to_sha("return KEYS"), { :keys => ["k1", "k2"] })
         
     | 
| 
       73 
     | 
    
         
            -
                  assert_equal ["a1", "a2"], r.evalsha(to_sha("return ARGV"), { :argv => ["a1", "a2"] })
         
     | 
| 
       74 
     | 
    
         
            -
                end
         
     | 
| 
       75 
     | 
    
         
            -
              end
         
     | 
| 
       76 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,78 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class SentinelCommandsTest < Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              include Helper::Client
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              def test_sentinel_command_master
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                handler = lambda do |id|
         
     | 
| 
       10 
     | 
    
         
            -
                  {
         
     | 
| 
       11 
     | 
    
         
            -
                    :sentinel => lambda do |command, *args|
         
     | 
| 
       12 
     | 
    
         
            -
                      ["name", "master1", "ip", "127.0.0.1"]
         
     | 
| 
       13 
     | 
    
         
            -
                    end
         
     | 
| 
       14 
     | 
    
         
            -
                  }
         
     | 
| 
       15 
     | 
    
         
            -
                end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                RedisMock.start(handler.call(:s1)) do |port|
         
     | 
| 
       18 
     | 
    
         
            -
                  redis = Redis.new(:host => "127.0.0.1", :port => port)
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                  result = redis.sentinel('master', 'master1')
         
     | 
| 
       21 
     | 
    
         
            -
                  assert_equal result, { "name" => "master1", "ip" => "127.0.0.1" }
         
     | 
| 
       22 
     | 
    
         
            -
                end
         
     | 
| 
       23 
     | 
    
         
            -
              end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
              def test_sentinel_command_masters
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                handler = lambda do |id|
         
     | 
| 
       28 
     | 
    
         
            -
                  {
         
     | 
| 
       29 
     | 
    
         
            -
                    :sentinel => lambda do |command, *args|
         
     | 
| 
       30 
     | 
    
         
            -
                      [%w[name master1 ip 127.0.0.1 port 6381], %w[name master1 ip 127.0.0.1 port 6382]]
         
     | 
| 
       31 
     | 
    
         
            -
                    end
         
     | 
| 
       32 
     | 
    
         
            -
                  }
         
     | 
| 
       33 
     | 
    
         
            -
                end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                RedisMock.start(handler.call(:s1)) do |port|
         
     | 
| 
       36 
     | 
    
         
            -
                  redis = Redis.new(:host => "127.0.0.1", :port => port)
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                  result = redis.sentinel('masters')
         
     | 
| 
       39 
     | 
    
         
            -
                  assert_equal result[0], { "name" => "master1", "ip" => "127.0.0.1", "port" => "6381" }
         
     | 
| 
       40 
     | 
    
         
            -
                  assert_equal result[1], { "name" => "master1", "ip" => "127.0.0.1", "port" => "6382" }
         
     | 
| 
       41 
     | 
    
         
            -
                end
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
              def test_sentinel_command_get_master_by_name
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                handler = lambda do |id|
         
     | 
| 
       47 
     | 
    
         
            -
                  {
         
     | 
| 
       48 
     | 
    
         
            -
                    :sentinel => lambda do |command, *args|
         
     | 
| 
       49 
     | 
    
         
            -
                      ["127.0.0.1", "6381"]
         
     | 
| 
       50 
     | 
    
         
            -
                    end
         
     | 
| 
       51 
     | 
    
         
            -
                  }
         
     | 
| 
       52 
     | 
    
         
            -
                end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                RedisMock.start(handler.call(:s1)) do |port|
         
     | 
| 
       55 
     | 
    
         
            -
                  redis = Redis.new(:host => "127.0.0.1", :port => port)
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                  result = redis.sentinel('get-master-addr-by-name', 'master1')
         
     | 
| 
       58 
     | 
    
         
            -
                  assert_equal result, ["127.0.0.1", "6381"]
         
     | 
| 
       59 
     | 
    
         
            -
                end
         
     | 
| 
       60 
     | 
    
         
            -
              end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
              def test_sentinel_command_ckquorum
         
     | 
| 
       63 
     | 
    
         
            -
                handler = lambda do |id|
         
     | 
| 
       64 
     | 
    
         
            -
                  {
         
     | 
| 
       65 
     | 
    
         
            -
                    :sentinel => lambda do |command, *args|
         
     | 
| 
       66 
     | 
    
         
            -
                      "+OK 2 usable Sentinels. Quorum and failover authorization can be reached"
         
     | 
| 
       67 
     | 
    
         
            -
                    end
         
     | 
| 
       68 
     | 
    
         
            -
                  }
         
     | 
| 
       69 
     | 
    
         
            -
                end
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                RedisMock.start(handler.call(:s1)) do |port|
         
     | 
| 
       72 
     | 
    
         
            -
                  redis = Redis.new(:host => "127.0.0.1", :port => port)
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                  result = redis.sentinel('ckquorum', 'master1')
         
     | 
| 
       75 
     | 
    
         
            -
                  assert_equal result, "OK 2 usable Sentinels. Quorum and failover authorization can be reached"
         
     | 
| 
       76 
     | 
    
         
            -
                end
         
     | 
| 
       77 
     | 
    
         
            -
              end
         
     | 
| 
       78 
     | 
    
         
            -
            end
         
     |