spec/rflow_spec.rb in rflow-1.0.1 vs spec/rflow_spec.rb in rflow-1.1.0

- old
+ new

@@ -35,11 +35,11 @@ log_lines.each {|line| expect(line).not_to match /^ERROR/ } log_lines.each {|line| expect(line).not_to match /^DEBUG/ } # Grab all the pids from the log, which seems to be the only # reliable way to get them - log_lines.map {|line| /\((\d+)\)/.match(line)[1].to_i }.uniq + log_lines.map {|line| /\(\s*(\d+)\s*\)/.match(line)[1].to_i }.uniq end def run_and_shutdown(app_name, expected_worker_count) r = start_rflow sleep 2 # give the daemon a chance to finish @@ -62,19 +62,19 @@ end yield # verify output # Terminate the master - expect(Process.kill("TERM", master_pid)).to eq(1) + expect(Process.kill('TERM', master_pid)).to eq(1) # Make sure everything is dead after a second sleep 2 ([master_pid] + worker_pids).each do |pid| expect { Process.kill(0, pid) }.to raise_error(Errno::ESRCH) end rescue Exception => e - Process.kill("TERM", master_pid) if master_pid + Process.kill('TERM', master_pid) if master_pid raise end let(:config_file_name) { 'input_config' } let(:db_file_name) { 'outdb' } @@ -92,17 +92,17 @@ Dir.chdir @temp_directory_path end after(:each) { Dir.chdir @original_directory_path } - context "when executing from the test script" do + context 'when executing from the test script' do before(:all) { load @extensions_file_name } describe '.run!' do def run_rflow_with_dsl(&block) rflow_thread = Thread.new do - ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:" + ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' RFlow::Configuration.migrate_database RFlow::Configuration::RubyDSL.configure {|c| block.call(c) } RFlow::Configuration.merge_defaults! RFlow.run! nil, false end @@ -115,11 +115,11 @@ RFlow.master.shutdown! 'SIGQUIT' if RFlow.master EM.run { EM.stop } rflow_thread.join end - it "should run a non-sharded workflow" do + it 'should run a non-sharded workflow' do run_rflow_with_dsl do |c| c.setting 'rflow.log_level', 'ERROR' c.setting 'rflow.application_directory_path', @temp_directory_path c.setting 'rflow.application_name', 'nonsharded_test' @@ -156,11 +156,11 @@ expect(File.exist?(File.join(@temp_directory_path, file_name))).to be true expect(File.readlines(file_name).map(&:to_i)).to eq(expected_contents) end end - it "should run a sharded workflow" do + it 'should run a sharded workflow' do run_rflow_with_dsl do |c| c.setting 'rflow.log_level', 'ERROR' c.setting 'rflow.application_directory_path', @temp_directory_path c.setting 'rflow.application_name', 'sharded_test' @@ -205,11 +205,11 @@ expect(File.exist?(File.join(@temp_directory_path, file_name))).to be true expect(File.readlines(file_name).map(&:to_i).sort).to eq(expected_contents.sort) end end - it "should deliver broadcast messages to every copy of a shard" do + it 'should deliver broadcast messages to every copy of a shard' do run_rflow_with_dsl do |c| c.setting 'rflow.log_level', 'FATAL' c.setting 'rflow.application_directory_path', @temp_directory_path c.setting 'rflow.application_name', 'sharded_broadcast_test' @@ -247,28 +247,28 @@ end end end end - context "when executing via the rflow binary" do - context "with a simple ruby DSL config file" do + context 'when executing via the rflow binary' do + context 'with a simple ruby DSL config file' do before(:each) do write_config_file <<-EOF RFlow::Configuration::RubyDSL.configure do |c| c.setting 'mysetting', 'myvalue' end EOF end - it "should load a ruby dsl file into a sqlite DB" do + it 'should load a ruby dsl file into a sqlite DB' do load_database - ActiveRecord::Base.establish_connection adapter: "sqlite3", database: db_file_name + ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: db_file_name expect(RFlow::Configuration::Setting.where(:name => 'mysetting').first.value).to eq('myvalue') end - it "should not load a database if the database file already exists" do + it 'should not load a database if the database file already exists' do File.open(db_file_name, 'w') {|file| file.write 'boom' } r = execute_rflow("load -d #{db_file_name} -c #{config_file_name}") # Make sure that the process execution worked @@ -276,11 +276,11 @@ expect(r[:stderr]).to eq('') expect(r[:stdout]).to match /Config database.*#{db_file_name}.*exists/ end end - context "with a component that runs subshells" do + context 'with a component that runs subshells' do let(:app_name) { 'sharded_subshell_test' } before(:each) do write_config_file <<-EOF RFlow::Configuration::RubyDSL.configure do |c| @@ -298,19 +298,19 @@ EOF load_database end - it "should run successfully daemonize and run in the background" do + it 'should run successfully daemonize and run in the background' do run_and_shutdown app_name, 1 do # 1 default worker expect(File.exist?(File.join(@temp_directory_path, 'out1'))).to be true - File.readlines('out1').each {|line| expect(line).to match /\w+ \w+ \d+ \d+:\d+:\d+ \w+ \d+/ } + File.readlines('out1').each {|line| expect(line).to match /\w+ \w+\s+\d+ \d+:\d+:\d+ \w+ \d+/ } end end end - context "with a complex, sharded ruby DSL config file" do + context 'with a complex, sharded ruby DSL config file' do let(:app_name) { 'sharded_bin_test' } before(:each) do write_config_file <<-EOF RFlow::Configuration::RubyDSL.configure do |c| @@ -350,10 +350,10 @@ expect(r[:status].exitstatus).to eq(1) expect(r[:stderr]).to eq('') expect(r[:stdout]).to match /error/i end - it "should daemonize and run in the background" do + it 'should daemonize and run in the background' do output_files = { 'out1' => [0, 3, 6, 9] * 3, 'out2' => (20..30).to_a * 2, 'out3' => (100..105).to_a, 'out_all' => [0, 3, 6, 9] * 3 + (20..30).to_a * 2 + (100..105).to_a