Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SLAVE regex, log unrecognized commands #65

Merged
merged 3 commits into from
Dec 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/test_queue/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def distribute_queue
data = Marshal.dump(obj)
sock.write(data)
end
when /^SLAVE (\d+) ([\w\.-]+) (?: (.+))?/
when /^SLAVE (\d+) ([\w\.-]+)(?: (.+))?/
num = $1.to_i
slave = $2
slave_message = $3
Expand All @@ -474,6 +474,8 @@ def distribute_queue
# worker reporting an abnormal number of test failures;
# stop everything immediately and report the results.
break
else
STDERR.puts("Ignoring unrecognized command: \"#{cmd}\"")
end
sock.close
end
Expand Down
41 changes: 35 additions & 6 deletions test/minitest5.bats
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,52 @@ assert_test_queue_force_ordering() {
assert_output_contains "Failed to discover DoesNotExist specified in TEST_QUEUE_FORCE"
}

@test "multi-master succeeds when all tests pass" {
@test "multi-master central master succeeds when all tests pass" {
export TEST_QUEUE_RELAY_TOKEN=$(date | cksum | cut -d' ' -f1)
TEST_QUEUE_RELAY=0.0.0.0:12345 bundle exec minitest-queue ./test/samples/sample_minitest5.rb || true &
export SLEEP_AS_RELAY=1
TEST_QUEUE_RELAY=0.0.0.0:12345 bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb || true &
sleep 0.1
TEST_QUEUE_SOCKET=0.0.0.0:12345 run bundle exec minitest-queue ./test/samples/sample_minitest5.rb
TEST_QUEUE_SOCKET=0.0.0.0:12345 run bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb
wait

assert_status 0
assert_output_contains "Starting test-queue master"
}

@test "multi-master fails when a test fails" {
@test "multi-master remote master succeeds when all tests pass" {
export TEST_QUEUE_RELAY_TOKEN=$(date | cksum | cut -d' ' -f1)
export SLEEP_AS_MASTER=1
TEST_QUEUE_SOCKET=0.0.0.0:12345 bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb || true &
sleep 0.1
TEST_QUEUE_RELAY=0.0.0.0:12345 run bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb
wait

assert_status 0
assert_output_contains "Starting test-queue master"
}

@test "multi-master central master fails when a test fails" {
export FAIL=1
export SLEEP_AS_RELAY=1
export TEST_QUEUE_RELAY_TOKEN=$(date | cksum | cut -d' ' -f1)
TEST_QUEUE_RELAY=0.0.0.0:12345 bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb || true &
sleep 0.1
TEST_QUEUE_SOCKET=0.0.0.0:12345 run bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb
wait

assert_status 1
assert_output_contains "Starting test-queue master"
assert_output_contains "1) Failure:"
assert_output_contains "MiniTestFailure#test_fail"
}

@test "multi-master remote master fails when a test fails" {
export FAIL=1
export SLEEP_AS_MASTER=1
export TEST_QUEUE_RELAY_TOKEN=$(date | cksum | cut -d' ' -f1)
TEST_QUEUE_RELAY=0.0.0.0:12345 bundle exec minitest-queue ./test/samples/sample_minitest5.rb || true &
TEST_QUEUE_SOCKET=0.0.0.0:12345 bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb || true &
sleep 0.1
TEST_QUEUE_SOCKET=0.0.0.0:12345 run bundle exec minitest-queue ./test/samples/sample_minitest5.rb
TEST_QUEUE_RELAY=0.0.0.0:12345 run bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb
wait

assert_status 1
Expand Down
14 changes: 14 additions & 0 deletions test/sleepy_runner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'test_queue'
require 'test_queue/runner/minitest'

class SleepyTestRunner < TestQueue::Runner::MiniTest
def after_fork(num)
if ENV['SLEEP_AS_RELAY'] && relay?
sleep 5
elsif ENV['SLEEP_AS_MASTER'] && !relay?
sleep 5
end
end
end

SleepyTestRunner.new.execute