Sha256: 6dc7f1b5f7c9a05dbbd3d5768a762229a6480d1941ce11c3e17d7f6b3e19ebad

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

# encoding: UTF-8

require "helper"

class TestDistributedRemoteServerControlCommands < Test::Unit::TestCase

  include Helper::Distributed

  def test_info
    %w(last_save_time redis_version total_connections_received connected_clients total_commands_processed connected_slaves uptime_in_seconds used_memory uptime_in_days changes_since_last_save).each do |x|
      r.info.each do |info|
        assert info.keys.include?(x)
      end
    end
  end

  def test_info_commandstats
    return if version < "2.9.0"

    r.nodes.each { |n| n.config(:resetstat) }
    r.ping # Executed on every node

    r.info(:commandstats).each do |info|
      assert_equal "1", info["ping"]["calls"]
    end
  end

  def test_monitor
    begin
      r.monitor
    rescue Exception => ex
    ensure
      assert ex.kind_of?(NotImplementedError)
    end
  end

  def test_echo
    assert_equal ["foo bar baz\n"], r.echo("foo bar baz\n")
  end

  def test_time
    return if version < "2.5.4"

    # Test that the difference between the time that Ruby reports and the time
    # that Redis reports is minimal (prevents the test from being racy).
    r.time.each do |rv|
      redis_usec = rv[0] * 1_000_000 + rv[1]
      ruby_usec = Integer(Time.now.to_f * 1_000_000)

      assert 500_000 > (ruby_usec - redis_usec).abs
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redis-3.0.0 test/distributed_remote_server_control_commands_test.rb
redis-3.0.0.rc2 test/distributed_remote_server_control_commands_test.rb