-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Remote: Fix "file not found" error when remote cache is changed from enabled to disabled. #14252
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3204,23 +3204,23 @@ EOF | |
expect_not_log "WARNING: Writing to Remote Cache:" | ||
} | ||
|
||
function test_download_toplevel_when_turn_remote_cache_off() { | ||
# Test that BwtB does cause build failure if remote cache is disabled in a following build. | ||
function test_download_toplevel_when_turn_remote_cache_off_without_metadata() { | ||
# Test that BwtB doesn't cause build failure if remote cache is disabled in a following build. | ||
# See https://github.com/bazelbuild/bazel/issues/13882. | ||
|
||
mkdir -p a | ||
cat > a/BUILD <<EOF | ||
mkdir a | ||
cat > a/BUILD <<'EOF' | ||
genrule( | ||
name = "producer", | ||
outs = ["a.txt", "b.txt"], | ||
cmd = "touch \$(OUTS)", | ||
cmd = "touch $(OUTS)", | ||
) | ||
|
||
genrule( | ||
name = "consumer", | ||
outs = ["out.txt"], | ||
srcs = [":b.txt", "in.txt"], | ||
cmd = "cat \$(SRCS) > \$@", | ||
cmd = "cat $(SRCS) > $@", | ||
) | ||
EOF | ||
echo 'foo' > a/in.txt | ||
|
@@ -3232,44 +3232,73 @@ EOF | |
--verbose_failures \ | ||
//a:consumer >& $TEST_log || fail "Failed to populate the cache" | ||
|
||
bazel clean || fail "Failed to clean" | ||
bazel clean >& $TEST_log || fail "Failed to clean" | ||
|
||
# download top level outputs without remote metadata | ||
# download top level outputs | ||
bazel build \ | ||
--remote_cache=grpc://localhost:${worker_port} \ | ||
--remote_download_toplevel \ | ||
--verbose_failures \ | ||
//a:consumer >& $TEST_log || fail "Failed to download outputs without remote metadata" | ||
(! [[ -f bazel-bin/a/a.txt ]] && ! [[ -f bazel-bin/a/b.txt ]]) \ | ||
|| fail "Expected outputs of producer are not downloaded without remote metadata" | ||
//a:consumer >& $TEST_log || fail "Failed to download outputs" | ||
[[ -f bazel-bin/a/a.txt ]] || [[ -f bazel-bin/a/b.txt ]] \ | ||
&& fail "Expected outputs of producer are not downloaded" | ||
|
||
# build without remote cache without remote metadata | ||
# build without remote cache | ||
echo 'bar' > a/in.txt | ||
bazel build \ | ||
--remote_download_toplevel \ | ||
--verbose_failures \ | ||
//a:consumer >& $TEST_log || fail "Failed to build without remote cache without remote metadata" | ||
//a:consumer >& $TEST_log || fail "Failed to build without remote cache" | ||
} | ||
|
||
bazel clean || fail "Failed to clean" | ||
function test_download_toplevel_when_turn_remote_cache_off_with_metadata() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 2 test cases differ by 1 option only -- why not put the test case as a separate helper function and call that twice with different parameters (Bash tests parameterization). Example here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
# Test that BwtB doesn't cause build failure if remote cache is disabled (but with | ||
# --experimental_action_cache_store_output_metadata) in a following build. | ||
# See https://github.com/bazelbuild/bazel/issues/13882. | ||
|
||
mkdir a | ||
cat > a/BUILD <<'EOF' | ||
genrule( | ||
name = "producer", | ||
outs = ["a.txt", "b.txt"], | ||
cmd = "touch $(OUTS)", | ||
) | ||
|
||
genrule( | ||
name = "consumer", | ||
outs = ["out.txt"], | ||
srcs = [":b.txt", "in.txt"], | ||
cmd = "cat $(SRCS) > $@", | ||
) | ||
EOF | ||
echo 'foo' > a/in.txt | ||
|
||
# download top level outputs with remote metadata | ||
# populate the cache | ||
bazel build \ | ||
--remote_cache=grpc://localhost:${worker_port} \ | ||
--remote_download_toplevel \ | ||
--verbose_failures \ | ||
//a:consumer >& $TEST_log || fail "Failed to populate the cache" | ||
|
||
bazel clean >& $TEST_log || fail "Failed to clean" | ||
|
||
# download top level outputs | ||
bazel build \ | ||
--remote_cache=grpc://localhost:${worker_port} \ | ||
--remote_download_toplevel \ | ||
--experimental_action_cache_store_output_metadata \ | ||
--verbose_failures \ | ||
//a:consumer >& $TEST_log || fail "Failed to download outputs with remote metadata" | ||
(! [[ -f bazel-bin/a/a.txt ]] && ! [[ -f bazel-bin/a/b.txt ]]) \ | ||
|| fail "Expected outputs of producer are not downloaded with remote metadata" | ||
//a:consumer >& $TEST_log || fail "Failed to download outputs" | ||
[[ -f bazel-bin/a/a.txt ]] || [[ -f bazel-bin/a/b.txt ]] \ | ||
&& fail "Expected outputs of producer are not downloaded" | ||
|
||
# build without remote cache with remote metadata | ||
# build without remote cache | ||
echo 'bar' > a/in.txt | ||
bazel build \ | ||
--remote_download_toplevel \ | ||
--experimental_action_cache_store_output_metadata \ | ||
--verbose_failures \ | ||
//a:consumer >& $TEST_log || fail "Failed to build without remote cache with remote metadata" | ||
//a:consumer >& $TEST_log || fail "Failed to build without remote cache" | ||
} | ||
|
||
run_suite "Remote execution and remote cache tests" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supernit:
--verbose_failures
is unlikely needed/we could add that to the blazerc for the whole test if that aids debugging failures.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.