Skip to content

Commit

Permalink
Add an integration test to verify that SIGQUIT works.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 701236558
Change-Id: Idc83f9dbdcc930e380a300cd52206904744dbd85
  • Loading branch information
tjgq authored and copybara-github committed Nov 29, 2024
1 parent 061101e commit e0738ff
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/test/shell/integration/client_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ function test_noblock_for_lock_reuse_server() {

# Get the client pid from the log. This isn't necessarily the subshell pid
# because there might be wrapper scripts in between.
local -r client_pid="$(cat "$TEST_log" | sed -nr 's/.*Running \(pid=([0-9]+)\)/\1/p')"
local -r client_pid="$(cat "$TEST_log" | scrape_client_pid)"

# Run another command in the same workspace but different startup options,
# which requires a server restart. Since the server is currently running the
Expand Down Expand Up @@ -538,7 +538,7 @@ function test_noblock_for_lock_with_batch() {

# Get the client pid from the log. This isn't necessarily the subshell pid
# because there might be wrapper scripts in between.
local -r client_pid="$(cat "$TEST_log" | sed -nr 's/.*Running \(pid=([0-9]+)\)/\1/p')"
local -r client_pid="$(cat "$TEST_log" | scrape_client_pid)"

local exit_code=0
bazel --client_debug --batch --noblock_for_lock info &>"$TEST_log-2" || exit_code=$?
Expand Down Expand Up @@ -808,4 +808,38 @@ function test_client_is_quiet_by_default() {
expect_log "^[0-9]\+$"
}

function test_sigquit() {
# Use a FIFO to spoonfeed the Bazel server.
mkdir -p a && mkfifo a/BUILD || fail "couldn't create fifo a"
mkdir -p b && mkfifo b/BUILD || fail "couldn't create fifo b"
bazel --client_debug build --nobuild //a:a &> "$TEST_log" &
local -r subshell_pid="$!"

# Wait until Bazel reads a/BUILD. After that, it will block on b/BUILD.
echo "filegroup(name='a', srcs=['//b:b'])" > a/BUILD

# Get the client pid from the log. This isn't necessarily the subshell pid
# because there might be wrapper scripts in between.
local -r client_pid="$(cat "$TEST_log" | scrape_client_pid)"

# Send a SIGQUIT to the client.
kill -SIGQUIT "$client_pid"

# Unstick the server *before* checking expectations, otherwise the test suite
# will hang.
echo "filegroup(name='b', visibility=['//visibility:public'])" > b/BUILD
wait "$subshell_pid" || fail "Couldn't wait"
rm -rf a b

# Get the jvm.out location.
local -r jvm_out="$(bazel --client_debug info output_base)/server/jvm.out"

# Look for a distinctive string indicating the presence of a thread dump.
assert_contains "Full thread dump" "$jvm_out"
}

function scrape_client_pid() {
sed -nr 's/.*Running \(pid=([0-9]+)\)/\1/p'
}

run_suite "Tests of the bazel client."

0 comments on commit e0738ff

Please sign in to comment.