Sha256: fadc2929bbc0f1230101e555ace516aa013217a1d827ff7e3d6227bb193b0cd7

Contents?: true

Size: 1.16 KB

Versions: 55

Compression:

Stored size: 1.16 KB

Contents

# encoding: UTF-8

require File.expand_path("./helper", File.dirname(__FILE__))
require "redis/distributed"

setup do
  log = StringIO.new
  init Redis::Distributed.new(NODES, :logger => ::Logger.new(log))
end

test "BLPOP" do |r|
  r.lpush("foo", "s1")
  r.lpush("foo", "s2")

  wire = Wire.new do
    redis = Redis::Distributed.new(NODES)
    Wire.sleep 0.3
    redis.lpush("foo", "s3")
  end

  assert ["foo", "s2"] == r.blpop("foo", 1)
  assert ["foo", "s1"] == r.blpop("foo", 1)
  assert ["foo", "s3"] == r.blpop("foo", 1)

  wire.join
end

test "BRPOP" do |r|
  r.rpush("foo", "s1")
  r.rpush("foo", "s2")

  wire = Wire.new do
    redis = Redis::Distributed.new(NODES)
    Wire.sleep 0.3
    redis.rpush("foo", "s3")
  end

  assert ["foo", "s2"] == r.brpop("foo", 1)
  assert ["foo", "s1"] == r.brpop("foo", 1)
  assert ["foo", "s3"] == r.brpop("foo", 1)

  wire.join
end

test "BRPOP should unset a configured socket timeout" do |r|
  r = Redis::Distributed.new(NODES, :timeout => 1)

  assert_nothing_raised do
    r.brpop("foo", 2)
  end # Errno::EAGAIN raised if socket times out before redis command times out

  assert r.nodes.all? { |node| node.client.timeout == 1 }
end

Version data entries

55 entries across 55 versions & 7 rubygems

Version Path
classiccms-0.5.14 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.13 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.12 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.11 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.10 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.9 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.8 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.7 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.6 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.5 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.2 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.1 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.5.0 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.4.2 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.4.1 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.4.0 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.3.9 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.3.8 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.3.7 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb
classiccms-0.3.6 vendor/bundle/gems/redis-2.2.2/test/distributed_blocking_commands_test.rb