Sha256: e2982ca3a87d68e1827e66b8b82a0d59e86a283ccf25c8b4d5bc6ab21a7cc7b8

Contents?: true

Size: 1.5 KB

Versions: 16

Compression:

Stored size: 1.5 KB

Contents

# encoding: UTF-8

require File.expand_path("helper", File.dirname(__FILE__))

class TestDistributed < Test::Unit::TestCase

  include Helper::Distributed

  def test_handle_multiple_servers
    @r = Redis::Distributed.new ["redis://localhost:#{PORT}/15", *NODES]

    100.times do |idx|
      @r.set(idx.to_s, "foo#{idx}")
    end

    100.times do |idx|
      assert_equal "foo#{idx}", @r.get(idx.to_s)
    end

    assert_equal "0", @r.keys("*").sort.first
    assert_equal "string", @r.type("1")
  end

  def test_add_nodes
    logger = Logger.new("/dev/null")

    @r = Redis::Distributed.new NODES, :logger => logger, :timeout => 10

    assert_equal "127.0.0.1", @r.nodes[0].client.host
    assert_equal PORT, @r.nodes[0].client.port
    assert_equal 15, @r.nodes[0].client.db
    assert_equal 10, @r.nodes[0].client.timeout
    assert_equal logger, @r.nodes[0].client.logger

    @r.add_node("redis://127.0.0.1:6380/14")

    assert_equal "127.0.0.1", @r.nodes[1].client.host
    assert_equal 6380, @r.nodes[1].client.port
    assert_equal 14, @r.nodes[1].client.db
    assert_equal 10, @r.nodes[1].client.timeout
    assert_equal logger, @r.nodes[1].client.logger
  end

  def test_pipelining_commands_cannot_be_distributed
    assert_raise Redis::Distributed::CannotDistribute do
      r.pipelined do
        r.lpush "foo", "s1"
        r.lpush "foo", "s2"
      end
    end
  end

  def test_unknown_commands_does_not_work_by_default
    assert_raise NoMethodError do
      r.not_yet_implemented_command
    end
  end
end

Version data entries

16 entries across 15 versions & 7 rubygems

Version Path
finsync_redis-3.3.5 test/distributed_test.rb
redis-3.3.5 test/distributed_test.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/redis-3.3.3/test/distributed_test.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/redis-3.3.3/test/distributed_test.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/redis-3.3.3/test/distributed_test.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/redis-3.3.3/test/distributed_test.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/redis-3.3.3/test/distributed_test.rb
redis-3.3.3 test/distributed_test.rb
abaci-0.3.0 vendor/bundle/gems/redis-3.3.2/test/distributed_test.rb
abaci-0.3.0 vendor/bundle/gems/redis-3.3.1/test/distributed_test.rb
redis-3.3.2 test/distributed_test.rb
redis-3.3.1 test/distributed_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/redis-3.3.0/test/distributed_test.rb
redis-3.3.0 test/distributed_test.rb
discourse-redis-3.2.2 test/distributed_test.rb
redis-3.2.2 test/distributed_test.rb