test/dispatcher_test.rb in dynflow-1.0.5 vs test/dispatcher_test.rb in dynflow-1.1.0

- old
+ new

@@ -74,14 +74,43 @@ ping_response = client_world.ping(executor_world.id, 0.5) ping_response.wait assert ping_response.success? end + it 'succeeds when the world is available without cache' do + ping_response = client_world.ping_without_cache(executor_world.id, 0.5) + ping_response.wait + assert ping_response.success? + end + it 'time-outs when the world is not responding' do executor_world.terminate.wait ping_response = client_world.ping(executor_world.id, 0.5) ping_response.wait assert ping_response.failed? + end + + it 'time-outs when the world is not responding without cache' do + executor_world.terminate.wait + ping_response = client_world.ping_without_cache(executor_world.id, 0.5) + ping_response.wait + assert ping_response.failed? + end + + it 'caches the pings and pongs' do + # Spawn the worlds + client_world + executor_world + + ping_cache = Dynflow::Dispatcher::ClientDispatcher::PingCache.new(executor_world) + + # Records are fresh because of the heartbeat + assert ping_cache.fresh_record?(client_world.id) + assert ping_cache.fresh_record?(executor_world.id) + + # Expire the record + ping_cache.add_record(executor_world.id, Time.now - 1000) + refute ping_cache.fresh_record?(executor_world.id) end end end def self.handles_no_executor_available