Sha256: d834deaab493d01a6cdabdd1e700e539768d3229e49f0431f7893e55c91204ee
Contents?: true
Size: 1.78 KB
Versions: 2
Compression:
Stored size: 1.78 KB
Contents
require File.dirname(__FILE__) + '/test_helper' # Gearman::Util.debug = true class CrashTest < Test::Unit::TestCase def setup teardown_gearmands Thread.new { EM.run } unless EM.reactor_running? end def teardown teardown_gearmands end def test_worker_should_reconnect_if_gearmand_goes_away start_gearmand worker = Gearman::Worker.new("localhost:4730", :reconnect_sec => 1) worker.add_ability("foo") {|data, job| "noop!" } response = nil worker.work stop_gearmand start_gearmand task = Gearman::Task.new("foo", "ping") task.on_complete {|res| response = res } Gearman::Client.new("localhost:4730").run task assert_equal "noop!", response stop_gearmand end def test_client_and_worker_should_use_failover_gearmand_if_primary_is_not_available start_gearmand 4731 worker = Gearman::Worker.new(["localhost:4730", "localhost:4731"], :reconnect_sec => 1) worker.add_ability("foo") {|data, job| "noop!" } response = nil worker.work task = Gearman::Task.new("foo", "ping") task.on_complete {|res| response = res } Gearman::Client.new(["localhost:4730", "localhost:4731"]).run task assert_equal "noop!", response stop_gearmand 4731 end def test_client_and_worker_should_switch_to_failover_gearmand_if_primary_goes_down start_gearmand 4730 start_gearmand 4731 worker = Gearman::Worker.new(["localhost:4730", "localhost:4731"], :reconnect_sec => 1) worker.add_ability("foo") {|data, job| "noop!" } response = nil worker.work stop_gearmand 4730 task = Gearman::Task.new("foo", "ping") task.on_complete {|res| response = res } Gearman::Client.new(["localhost:4730", "localhost:4731"]).run task assert_equal "noop!", response stop_gearmand 4731 end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
evented-gearman-ruby-1.0.0 | test/crash_test.rb |
gearman-ruby-2.0.0 | test/crash_test.rb |