diff options
author | 2017-04-27 23:29:14 +0200 | |
---|---|---|
committer | 2017-04-28 01:03:18 +0200 | |
commit | 93aea2e9b53120140a9a154971ec18bf6c1412f8 (patch) | |
tree | 0688736661f25afabd46a7fd84e2b5262aeb64e9 /src/test | |
parent | 46299b4b087222886dff4b6f2c197fb15e45acca (diff) |
worker: Do not check if the process is still alive prior to using it.
This might sound strange at first, but the reasoning is this: A worker should never simply exit. Bazel controls the lifetime of its subprocesses, so a worker quitting is considered a failure (also because it cannot be distinguished from a crash).
With that set, we can improve two things:
- Bazel will now only notice that a worker crashed / quit when it tries to use one during a build. This is also the only time when we can print error messages to the user. Earlier we might have noticed that a worker crashed during validation, but had no mechanism to alert the user to this, because this wasn't necessarily during a build.
- This also fixes a race condition where a worker is still alive during validation, then quits, then the WorkerSpawnStrategy tries to send a WorkRequest, which fails, triggering an IOException.
This fixes the flaky test test_worker_restarts_after_exit (which is now called test_build_fails_when_worker_exits).
Part of #2855.
RELNOTES: Bazel will no longer gracefully restart workers that crashed / quit, instead this triggers a build failure.
PiperOrigin-RevId: 154470257
Diffstat (limited to 'src/test')
-rwxr-xr-x | src/test/shell/integration/bazel_worker_test.sh | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/src/test/shell/integration/bazel_worker_test.sh b/src/test/shell/integration/bazel_worker_test.sh index 1f20479e9f..d8877ba8ce 100755 --- a/src/test/shell/integration/bazel_worker_test.sh +++ b/src/test/shell/integration/bazel_worker_test.sh @@ -228,41 +228,24 @@ EOF assert_equals "1" $work_count } -function test_worker_restarts_after_exit() { +function test_build_fails_when_worker_exits() { prepare_example_worker cat >>BUILD <<'EOF' [work( name = "hello_world_%s" % idx, worker = ":worker", - worker_args = ["--exit_after=2"], + worker_args = ["--exit_after=1"], args = ["--write_uuid", "--write_counter"], ) for idx in range(10)] EOF bazel build :hello_world_1 &> $TEST_log \ || fail "build failed" - worker_uuid_1=$(cat $BINS/hello_world_1.out | grep UUID | cut -d' ' -f2) - work_count=$(cat $BINS/hello_world_1.out | grep COUNTER | cut -d' ' -f2) - assert_equals "1" $work_count bazel build :hello_world_2 &> $TEST_log \ - || fail "build failed" - worker_uuid_2=$(cat $BINS/hello_world_2.out | grep UUID | cut -d' ' -f2) - work_count=$(cat $BINS/hello_world_2.out | grep COUNTER | cut -d' ' -f2) - assert_equals "2" $work_count - - # Check that the same worker was used twice. - assert_equals "$worker_uuid_1" "$worker_uuid_2" + && fail "expected build to failed" || true - bazel build :hello_world_3 &> $TEST_log \ - || fail "build failed" - worker_uuid_3=$(cat $BINS/hello_world_3.out | grep UUID | cut -d' ' -f2) - work_count=$(cat $BINS/hello_world_3.out | grep COUNTER | cut -d' ' -f2) - assert_equals "1" $work_count - expect_log "worker .* can no longer be used, because its process terminated itself or got killed" - - # Check that we used a new worker. - assert_not_equals "$worker_uuid_2" "$worker_uuid_3" + expect_log "Worker process quit or closed its stdin stream when we tried to send a WorkRequest" } function test_worker_restarts_when_worker_binary_changes() { @@ -533,14 +516,12 @@ EOF bazel build :hello_world_1 &> $TEST_log \ || fail "build failed" - worker_uuid_1=$(cat $BINS/hello_world_1.out | grep UUID | cut -d' ' -f2) bazel build :hello_world_2 &> $TEST_log \ && fail "expected build to fail" || /bin/true - worker_uuid_2=$(cat $BINS/hello_world_2.out | grep UUID | cut -d' ' -f2) expect_log "^---8<---8<--- Start of log, file at /" - expect_log "thus dumping its log file for debugging purposes:" + expect_log "Worker process did not return a WorkResponse:" expect_log "I'm a very poisoned worker and will just crash." expect_log "^---8<---8<--- End of log ---8<---8<---" } |