Sha256: 262a67c32e46332f0fbeede55bc8ff7dcd030780a09e863d31320c0b05ee8148
Contents?: true
Size: 1.59 KB
Versions: 28
Compression:
Stored size: 1.59 KB
Contents
require 'spec_helper' module RedisFailover class LightNodeManager def initialize @node_states = {} end def notify_state(node, state) @node_states[node] = state end def state_for(node) @node_states[node] end end describe NodeWatcher do let(:node_manager) { LightNodeManager.new } let(:node) { Node.new(:host => 'host', :port => 123).extend(RedisStubSupport) } describe '#watch' do context 'node is not syncing with master' do it 'properly informs manager of unavailable node' do watcher = NodeWatcher.new(node_manager, node, 1) watcher.watch sleep(3) node.redis.make_unavailable! sleep(3) watcher.shutdown node_manager.state_for(node).should == :unavailable end it 'properly informs manager of available node' do node_manager.notify_state(node, :unavailable) watcher = NodeWatcher.new(node_manager, node, 1) watcher.watch sleep(3) watcher.shutdown node_manager.state_for(node).should == :available end end context 'node is syncing with master' do it 'properly informs manager of syncing node' do node_manager.notify_state(node, :unavailable) node.redis.slaveof('masterhost', 9876) node.redis.force_sync_with_master(true) watcher = NodeWatcher.new(node_manager, node, 1) watcher.watch sleep(3) watcher.shutdown node_manager.state_for(node).should == :syncing end end end end end
Version data entries
28 entries across 28 versions & 2 rubygems