test/system/daemon_tests.rb in qs-0.8.0 vs test/system/daemon_tests.rb in qs-0.8.1

- old
+ new

@@ -18,11 +18,11 @@ @app_daemon_class = build_app_daemon_class end teardown do @daemon_runner.stop if @daemon_runner - Qs.redis.with do |c| + Qs.redis.connection do |c| keys = c.keys('*qs-app*') c.pipelined{ keys.each{ |k| c.del(k) } } end Qs.client.clear(AppQueue.redis_key) AppQueue.clear_subscriptions @@ -53,14 +53,14 @@ payload_type = message.payload_type route_name = message.route_name case(route_name) when 'error', 'timeout', 'qs-app:error', 'qs-app:timeout' error = "#{exception.class}: #{exception.message}" - Qs.redis.with{ |c| c.set("qs-app:last_#{payload_type}_error", error) } + Qs.redis.connection{ |c| c.set("qs-app:last_#{payload_type}_error", error) } when 'slow', 'qs-app:slow' error = exception.class.to_s - Qs.redis.with{ |c| c.set("qs-app:last_#{payload_type}_error", error) } + Qs.redis.connection{ |c| c.set("qs-app:last_#{payload_type}_error", error) } end end end end @@ -90,11 +90,11 @@ }) @app_thread.join(JOIN_SECONDS) end should "run the job" do - assert_equal @value, Qs.redis.with{ |c| c.get("qs-app:#{@key}") } + assert_equal @value, Qs.redis.connection{ |c| c.get("qs-app:#{@key}") } end end class JobThatErrorsTests < RunningDaemonSetupTests @@ -105,11 +105,11 @@ @app_thread.join(JOIN_SECONDS) end should "run the configured error handler procs" do exp = "RuntimeError: #{@error_message}" - assert_equal exp, Qs.redis.with{ |c| c.get('qs-app:last_job_error') } + assert_equal exp, Qs.redis.connection{ |c| c.get('qs-app:last_job_error') } end end class TimeoutJobTests < RunningDaemonSetupTests @@ -121,11 +121,11 @@ should "run the configured error handler procs" do handler_class = AppHandlers::Timeout exp = "Qs::TimeoutError: #{handler_class} timed out " \ "(#{handler_class.timeout}s)" - assert_equal exp, Qs.redis.with{ |c| c.get('qs-app:last_job_error') } + assert_equal exp, Qs.redis.connection{ |c| c.get('qs-app:last_job_error') } end end class BasicEventTests < RunningDaemonSetupTests @@ -138,11 +138,11 @@ }) @app_thread.join(JOIN_SECONDS) end should "run the event" do - assert_equal @value, Qs.redis.with{ |c| c.get("qs-app:#{@key}") } + assert_equal @value, Qs.redis.connection{ |c| c.get("qs-app:#{@key}") } end end class EventThatErrorsTests < RunningDaemonSetupTests @@ -153,11 +153,11 @@ @app_thread.join(JOIN_SECONDS) end should "run the configured error handler procs" do exp = "RuntimeError: #{@error_message}" - assert_equal exp, Qs.redis.with{ |c| c.get('qs-app:last_event_error') } + assert_equal exp, Qs.redis.connection{ |c| c.get('qs-app:last_event_error') } end end class TimeoutEventTests < RunningDaemonSetupTests @@ -169,11 +169,11 @@ should "run the configured error handler procs" do handler_class = AppHandlers::TimeoutEvent exp = "Qs::TimeoutError: #{handler_class} timed out " \ "(#{handler_class.timeout}s)" - assert_equal exp, Qs.redis.with{ |c| c.get('qs-app:last_event_error') } + assert_equal exp, Qs.redis.connection{ |c| c.get('qs-app:last_event_error') } end end class ShutdownWithoutTimeoutTests < SystemTests @@ -194,27 +194,27 @@ should "shutdown and let the job and event finish" do @app_daemon.stop @app_thread.join(@nil_shutdown_timeout) assert_false @app_thread.alive? - assert_equal 'finished', Qs.redis.with{ |c| c.get('qs-app:slow') } - assert_equal 'finished', Qs.redis.with{ |c| c.get('qs-app:slow:event') } + assert_equal 'finished', Qs.redis.connection{ |c| c.get('qs-app:slow') } + assert_equal 'finished', Qs.redis.connection{ |c| c.get('qs-app:slow:event') } end should "shutdown and not let the job or event finish" do @app_daemon.halt @app_thread.join(@nil_shutdown_timeout) assert_false @app_thread.alive? - assert_nil Qs.redis.with{ |c| c.get('qs-app:slow') } + assert_nil Qs.redis.connection{ |c| c.get('qs-app:slow') } exp = "Qs::ShutdownError" - assert_equal exp, Qs.redis.with{ |c| c.get('qs-app:last_job_error') } - assert_nil Qs.redis.with{ |c| c.get('qs-app:slow:event') } + assert_equal exp, Qs.redis.connection{ |c| c.get('qs-app:last_job_error') } + assert_nil Qs.redis.connection{ |c| c.get('qs-app:slow:event') } exp = "Qs::ShutdownError" - assert_equal exp, Qs.redis.with{ |c| c.get('qs-app:last_event_error') } + assert_equal exp, Qs.redis.connection{ |c| c.get('qs-app:last_event_error') } end end class ShutdownWithTimeoutTests < SystemTests @@ -232,33 +232,33 @@ should "shutdown and not let the job or event finish" do @app_daemon.stop @app_thread.join(@shutdown_timeout + JOIN_SECONDS) assert_false @app_thread.alive? - assert_nil Qs.redis.with{ |c| c.get('qs-app:slow') } + assert_nil Qs.redis.connection{ |c| c.get('qs-app:slow') } exp = "Qs::ShutdownError" - assert_equal exp, Qs.redis.with{ |c| c.get('qs-app:last_job_error') } - assert_nil Qs.redis.with{ |c| c.get('qs-app:slow:event') } + assert_equal exp, Qs.redis.connection{ |c| c.get('qs-app:last_job_error') } + assert_nil Qs.redis.connection{ |c| c.get('qs-app:slow:event') } exp = "Qs::ShutdownError" - assert_equal exp, Qs.redis.with{ |c| c.get('qs-app:last_event_error') } + assert_equal exp, Qs.redis.connection{ |c| c.get('qs-app:last_event_error') } end should "shutdown and not let the job or event finish" do @app_daemon.halt @app_thread.join(@shutdown_timeout + JOIN_SECONDS) assert_false @app_thread.alive? - assert_nil Qs.redis.with{ |c| c.get('qs-app:slow') } + assert_nil Qs.redis.connection{ |c| c.get('qs-app:slow') } exp = "Qs::ShutdownError" - assert_equal exp, Qs.redis.with{ |c| c.get('qs-app:last_job_error') } - assert_nil Qs.redis.with{ |c| c.get('qs-app:slow:event') } + assert_equal exp, Qs.redis.connection{ |c| c.get('qs-app:last_job_error') } + assert_nil Qs.redis.connection{ |c| c.get('qs-app:slow:event') } exp = "Qs::ShutdownError" - assert_equal exp, Qs.redis.with{ |c| c.get('qs-app:last_event_error') } + assert_equal exp, Qs.redis.connection{ |c| c.get('qs-app:last_event_error') } end end class ShutdownWithUnprocessedQueueItemTests < SystemTests @@ -284,11 +284,11 @@ @app_daemon.stop @app_thread.join(@shutdown_timeout + JOIN_SECONDS) assert_false @app_thread.alive? - encoded_payloads = Qs.redis.with{ |c| c.lrange(AppQueue.redis_key, 0, 3) } + encoded_payloads = Qs.redis.connection{ |c| c.lrange(AppQueue.redis_key, 0, 3) } names = encoded_payloads.map{ |sp| Qs::Payload.deserialize(sp).name } ['slow1', 'slow2', 'basic1'].each{ |n| assert_includes n, names } end @@ -296,10 +296,10 @@ @app_daemon.halt @app_thread.join(@shutdown_timeout + JOIN_SECONDS) assert_false @app_thread.alive? - encoded_payloads = Qs.redis.with{ |c| c.lrange(AppQueue.redis_key, 0, 4) } + encoded_payloads = Qs.redis.connection{ |c| c.lrange(AppQueue.redis_key, 0, 4) } names = encoded_payloads.map{ |sp| Qs::Payload.deserialize(sp).name } ['slow1', 'slow2', 'basic1'].each{ |n| assert_includes n, names } end