Skip to content

Commit a737169

Browse files
fweikertcopybara-github
authored andcommitted
Reduce shell test flakiness.
We've seen an increasing number of flakes due to a) transient network issues and b) the fact that a subset of CI workers has an /etc/bazel.bazelrc file. This change addresses both issues by disabling bzlmod (thus avoiding any requests to BCR) and by filtering out irrelevant log entries. PiperOrigin-RevId: 638217146 Change-Id: I525a3abcdc824a40aba602d57b0b51f51c94a695
1 parent 34e3159 commit a737169

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/test/shell/integration/bazel_command_log_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ source "${CURRENT_DIR}/../integration_test_setup.sh" \
2121

2222
log="$(bazel --batch info command_log)"
2323

24+
# Less network flakiness without bzlmod
25+
disable_bzlmod
26+
2427
function tear_down() {
2528
# Clean up after ourselves.
2629
bazel --nobatch shutdown
@@ -46,6 +49,8 @@ function strip_lines_from_bazel_cc() {
4649
-e '/^WARNING: The startup option --host_javabase is deprecated; prefer --server_javabase.$/d' \
4750
-e '/^WARNING: The home directory is not defined, no home_rc will be looked for.$/d' \
4851
-e '/^WARNING: ignoring JAVA_TOOL_OPTIONS in environment.$/d' \
52+
-e '/^WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:$/d' \
53+
-e '/^\/etc\/bazel.bazelrc$/d' \
4954
-e '/Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release/d' \
5055
-e '/^E[0-9]* /d' \
5156
$TEST_log)

src/test/shell/integration/client_test.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1919
source "${CURRENT_DIR}/../integration_test_setup.sh" \
2020
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }
2121

22+
# Less network flakiness without bzlmod
23+
disable_bzlmod
24+
25+
function strip_lines_from_bazel_cc() {
26+
# sed can't redirect back to its input file (it'll only generate an empty
27+
# file). In newer versions of gnu sed there is a -i option to edit in place.
28+
29+
# Ignore common warnings caused by the environment on our CI workers.
30+
clean_log=$(\
31+
sed \
32+
-e '/^WARNING: ignoring JAVA_TOOL_OPTIONS in environment.$/d' \
33+
-e '/^WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:$/d' \
34+
-e '/^\/etc\/bazel.bazelrc$/d' \
35+
$TEST_log)
36+
37+
echo "$clean_log" > $TEST_log
38+
}
2239

2340
#### TESTS #############################################################
2441

@@ -422,19 +439,31 @@ function test_client_is_quiet_by_default() {
422439

423440
bazel info server_pid > stdout 2> stderr || fail "bazel info failed"
424441
cp stderr $TEST_log || fail "cp failed"
442+
443+
strip_lines_from_bazel_cc
444+
425445
assert_equals 2 $(cat $TEST_log | wc -l)
426446
expect_log "^\$TEST_TMPDIR defined: output root default"
427447
expect_log "^Starting local $capitalized_product_name server and connecting to it...$"
428448
cp stdout $TEST_log || fail "cp failed"
449+
450+
strip_lines_from_bazel_cc
451+
429452
assert_equals 1 $(cat $TEST_log | wc -l)
430453
expect_log "^[0-9]\+$"
431454

432455
rm stderr stdout || fail "rm failed"
433456
bazel info server_pid > stdout 2> stderr || fail "bazel info failed"
434457
cp stderr $TEST_log || fail "cp failed"
458+
459+
strip_lines_from_bazel_cc
460+
435461
assert_equals 1 $(cat $TEST_log | wc -l)
436462
expect_log "^\$TEST_TMPDIR defined: output root default"
437463
cp stdout $TEST_log || fail "cp failed"
464+
465+
strip_lines_from_bazel_cc
466+
438467
assert_equals 1 $(cat $TEST_log | wc -l)
439468
expect_log "^[0-9]\+$"
440469
}

0 commit comments

Comments
 (0)