DEV: Split out multisite tests in bin/turbo_rspec
* A new process is started that just runs the multisite tests * The other processes are instructed to exclude the multisite tests
This commit is contained in:
parent
0bf3316aec
commit
15c02c03c7
|
@ -44,8 +44,10 @@ module TurboTests
|
||||||
|
|
||||||
setup_tmp_dir
|
setup_tmp_dir
|
||||||
|
|
||||||
tests_in_groups.each_with_index do |tests, process_num|
|
start_multisite_subprocess(@files)
|
||||||
start_subprocess(tests, process_num + 1)
|
|
||||||
|
tests_in_groups.each_with_index do |tests, process_id|
|
||||||
|
start_regular_subprocess(tests, process_id + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
handle_messages
|
handle_messages
|
||||||
|
@ -83,23 +85,45 @@ module TurboTests
|
||||||
FileUtils.mkdir_p('tmp/test-pipes/')
|
FileUtils.mkdir_p('tmp/test-pipes/')
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_subprocess(tests, process_num)
|
def start_multisite_subprocess(tests)
|
||||||
|
start_subprocess(
|
||||||
|
{},
|
||||||
|
["--tag", "type:multisite"],
|
||||||
|
tests,
|
||||||
|
"multisite"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_regular_subprocess(tests, process_id)
|
||||||
|
start_subprocess(
|
||||||
|
{ 'TEST_ENV_NUMBER' => process_id.to_s },
|
||||||
|
["--tag", "~type:multisite"],
|
||||||
|
tests,
|
||||||
|
process_id
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_subprocess(env, extra_args, tests, process_id)
|
||||||
if tests.empty?
|
if tests.empty?
|
||||||
@messages << {
|
@messages << {
|
||||||
type: 'exit',
|
type: 'exit',
|
||||||
process_num: process_num
|
process_id: process_id
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
tmp_filename = "tmp/test-pipes/subprocess-#{process_id}"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
File.mkfifo("tmp/test-pipes/subprocess-#{process_num}")
|
File.mkfifo(tmp_filename)
|
||||||
rescue Errno::EEXIST
|
rescue Errno::EEXIST
|
||||||
end
|
end
|
||||||
|
|
||||||
env = { 'TEST_ENV_NUMBER' => process_num.to_s }
|
env['RSPEC_SILENCE_FILTER_ANNOUNCEMENTS'] = '1'
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
"bundle", "exec", "rspec",
|
"bundle", "exec", "rspec",
|
||||||
"-f", "TurboTests::JsonRowsFormatter",
|
*extra_args,
|
||||||
"-o", "tmp/test-pipes/subprocess-#{process_num}",
|
"--format", "TurboTests::JsonRowsFormatter",
|
||||||
|
"--out", tmp_filename,
|
||||||
*tests
|
*tests
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -107,25 +131,25 @@ module TurboTests
|
||||||
command_str = [
|
command_str = [
|
||||||
env.map { |k, v| "#{k}=#{v}" }.join(' '),
|
env.map { |k, v| "#{k}=#{v}" }.join(' '),
|
||||||
command.join(' ')
|
command.join(' ')
|
||||||
].join(' ')
|
].select { |x| x.size > 0 }.join(' ')
|
||||||
|
|
||||||
STDERR.puts "Process #{process_num}: #{command_str}"
|
STDERR.puts "Process #{process_id}: #{command_str}"
|
||||||
end
|
end
|
||||||
|
|
||||||
_stdin, stdout, stderr, _wait_thr = Open3.popen3(env, *command)
|
_stdin, stdout, stderr, _wait_thr = Open3.popen3(env, *command)
|
||||||
|
|
||||||
@threads <<
|
@threads <<
|
||||||
Thread.new do
|
Thread.new do
|
||||||
File.open("tmp/test-pipes/subprocess-#{process_num}") do |fd|
|
File.open(tmp_filename) do |fd|
|
||||||
fd.each_line do |line|
|
fd.each_line do |line|
|
||||||
message = JSON.parse(line)
|
message = JSON.parse(line)
|
||||||
message = message.symbolize_keys
|
message = message.symbolize_keys
|
||||||
message[:process_num] = process_num
|
message[:process_id] = process_id
|
||||||
@messages << message
|
@messages << message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@messages << { type: 'exit', process_num: process_num }
|
@messages << { type: 'exit', process_id: process_id }
|
||||||
end
|
end
|
||||||
|
|
||||||
@threads << start_copy_thread(stdout, STDOUT)
|
@threads << start_copy_thread(stdout, STDOUT)
|
||||||
|
@ -167,7 +191,7 @@ module TurboTests
|
||||||
when 'close'
|
when 'close'
|
||||||
when 'exit'
|
when 'exit'
|
||||||
exited += 1
|
exited += 1
|
||||||
if exited == @num_processes
|
if exited == @num_processes + 1
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -155,6 +155,7 @@ end
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.fail_fast = ENV['RSPEC_FAIL_FAST'] == "1"
|
config.fail_fast = ENV['RSPEC_FAIL_FAST'] == "1"
|
||||||
|
config.silence_filter_announcements = ENV['RSPEC_SILENCE_FILTER_ANNOUNCEMENTS'] == "1"
|
||||||
config.include Helpers
|
config.include Helpers
|
||||||
config.include MessageBus
|
config.include MessageBus
|
||||||
config.include RSpecHtmlMatchers
|
config.include RSpecHtmlMatchers
|
||||||
|
|
Loading…
Reference in New Issue