From b48a319187c87e230b59142b4f7366775173faf4 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 29 May 2024 09:36:14 -0700 Subject: [PATCH] Fix IPv6-related network issues in some shell tests. PiperOrigin-RevId: 638314617 Change-Id: Ia6a3f63f998e9cfd3512d2c6a17c622c2ac60846 --- src/test/shell/bazel/BUILD | 1 + src/test/shell/bazel/bazel_test_test.sh | 12 ++++++++++-- src/test/shell/integration/BUILD | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index 1ac9df807c5882..79c355fcec165f 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -448,6 +448,7 @@ sh_test( tags = [ "no-sandbox", "no_windows", + "requires-network", # For Bzlmod ], ) diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh index 9f9b2c0878ab3f..02a5dcb14eab28 100755 --- a/src/test/shell/bazel/bazel_test_test.sh +++ b/src/test/shell/bazel/bazel_test_test.sh @@ -174,8 +174,16 @@ sh_test( ) EOF + # The next line ensures that the test passes in IPv6-only networks on macOS. + if is_darwin; then + export JAVA_TOOL_OPTIONS="-Djava.net.preferIPv6Addresses=true" + export STARTUP_OPTS="--host_jvm_args=-Djava.net.preferIPv6Addresses=true" + else + export STARTUP_OPTS="" + fi + # Test BAR is set from --action_env - BAZ=fromaction bazel --ignore_all_rc_files test --test_output=all \ + BAZ=fromaction bazel --ignore_all_rc_files $STARTUP_OPTS test --test_output=all \ --action_env=BAR=fromcli --action_env=BAZ \ //foo &> $TEST_log || fail "Test failed" expect_log "foo: frombuild" @@ -187,7 +195,7 @@ EOF # Test FOO from the BUILD file wins # Test BAR is set from --test_env # Test BAZ is set from --test_env - BAZ=fromtest bazel --ignore_all_rc_files test --test_output=all \ + BAZ=fromtest bazel --ignore_all_rc_files $STARTUP_OPTS test --test_output=all \ --action_env=FOO=fromcli --test_env=FOO=fromcli --test_env=BAR=fromcli \ --test_env=BAZ //foo &> $TEST_log || fail "Test failed" expect_log "foo: frombuild" diff --git a/src/test/shell/integration/BUILD b/src/test/shell/integration/BUILD index 2d0035a0693d26..8a49cf09ff7c8f 100644 --- a/src/test/shell/integration/BUILD +++ b/src/test/shell/integration/BUILD @@ -129,6 +129,9 @@ sh_test( "@bazel_tools//tools/bash/runfiles", ], shard_count = 8, + tags = [ + "requires-network", # For Bzlmod + ], ) sh_test(