spec/sqewer/cli_spec.rb in sqewer-3.0.0 vs spec/sqewer/cli_spec.rb in sqewer-3.0.1
- old
+ new
@@ -1,8 +1,12 @@
require_relative '../spec_helper'
-describe Sqewer::CLI, :sqs => true do
+describe Sqewer::CLI, :sqs => true, :wait => {timeout: 120} do
+ after :each do
+ Dir.glob('*-result').each{|path| File.unlink(path) }
+ end
+
describe 'runs the commandline app, executes jobs and then quits cleanly' do
it 'on a USR1 signal' do
submitter = Sqewer::Connection.default
stderr = Tempfile.new('worker-stderr')
@@ -15,17 +19,16 @@
j = {job_class: 'MyJob', first_name: 'John', last_name: 'Doe'}
submitter.send_message(JSON.dump(j))
end
end
- sleep 8 # Give it some time to process all the jobs
+ sleep 10 # Give it some time to process all the jobs
Process.kill("USR1", pid)
- sleep 2
+ wait_for { Process.wait(pid) }
generated_files = Dir.glob('*-result')
expect(generated_files).not_to be_empty
- generated_files.each{|path| File.unlink(path) }
stderr.rewind
log_output = stderr.read
expect(log_output).to include('Stopping (clean shutdown)')
end
@@ -45,10 +48,11 @@
end
end
sleep 4
Process.kill("TERM", pid)
-
+ wait_for { Process.wait(pid) }
+
generated_files = Dir.glob('*-result')
expect(generated_files).not_to be_empty
generated_files.each{|path| File.unlink(path) }
stderr.rewind