Skip to content

Commit

Permalink
Make --incompatible_remote_build_event_upload_respect_no_cache a no-op
Browse files Browse the repository at this point in the history
RELNOTES: `--incompatible_remote_build_event_upload_respect_no_cache` is now a no-op.
  • Loading branch information
brentleyjones committed Apr 11, 2023
1 parent 4392eb6 commit 4743c64
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 269 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,7 @@ public void afterAnalysis(
// Separating the conditions for readability.
private boolean shouldParseNoCacheOutputs() {
if (remoteOptions == null
|| remoteOptions.remoteBuildEventUploadMode != RemoteBuildEventUploadMode.ALL
|| !remoteOptions.incompatibleRemoteBuildEventUploadRespectNoCache) {
|| remoteOptions.remoteBuildEventUploadMode != RemoteBuildEventUploadMode.ALL) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ public final class RemoteOptions extends CommonRemoteOptions {
deprecationWarning =
"--incompatible_remote_build_event_upload_respect_no_cache has been deprecated in favor"
+ " of --remote_build_event_upload=minimal.",
help =
"If set to true, outputs referenced by BEP are not uploaded to remote cache if the"
+ " generating action cannot be cached remotely.")
help = "Deprecated. No-op. Use --remote_build_event_upload=minimal instead.")
public boolean incompatibleRemoteBuildEventUploadRespectNoCache;

@Option(
Expand Down
264 changes: 0 additions & 264 deletions src/test/shell/bazel/remote/remote_execution_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2495,270 +2495,6 @@ EOF
expect_not_log "WARNING: Remote Cache:"
}

function test_uploader_respect_no_cache() {
mkdir -p a
cat > a/BUILD <<EOF
genrule(
name = 'foo',
outs = ["foo.txt"],
cmd = "echo \"foo bar\" > \$@",
tags = ["no-cache"],
)
EOF

bazel build \
--remote_cache=grpc://localhost:${worker_port} \
--incompatible_remote_build_event_upload_respect_no_cache \
--remote_build_event_upload=all \
--build_event_json_file=bep.json \
//a:foo >& $TEST_log || fail "Failed to build"

cat bep.json > $TEST_log
expect_not_log "a:foo.*bytestream://" || fail "local files are converted"
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"
}

function test_uploader_respect_no_cache_minimal() {
mkdir -p a
cat > a/BUILD <<EOF
genrule(
name = 'foo',
outs = ["foo.txt"],
cmd = "echo \"foo bar\" > \$@",
tags = ["no-cache"],
)
EOF

bazel build \
--remote_cache=grpc://localhost:${worker_port} \
--remote_download_minimal \
--incompatible_remote_build_event_upload_respect_no_cache \
--remote_build_event_upload=all \
--build_event_json_file=bep.json \
//a:foo >& $TEST_log || fail "Failed to build"

cat bep.json > $TEST_log
expect_not_log "a:foo.*bytestream://" || fail "local files are converted"
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"
}

function test_uploader_alias_action_respect_no_cache() {
mkdir -p a
cat > a/BUILD <<EOF
genrule(
name = 'foo',
outs = ["foo.txt"],
cmd = "echo \"foo bar\" > \$@",
tags = ["no-cache"],
)
alias(
name = 'foo-alias',
actual = '//a:foo',
)
EOF

bazel build \
--remote_cache=grpc://localhost:${worker_port} \
--incompatible_remote_build_event_upload_respect_no_cache \
--remote_build_event_upload=all \
--build_event_json_file=bep.json \
//a:foo-alias >& $TEST_log || fail "Failed to build"

cat bep.json > $TEST_log
expect_not_log "a:foo.*bytestream://"
expect_log "command.profile.gz.*bytestream://"
}

function test_uploader_respect_no_cache_trees() {
mkdir -p a
cat > a/output_dir.bzl <<'EOF'
def _gen_output_dir_impl(ctx):
output_dir = ctx.actions.declare_directory(ctx.attr.outdir)
ctx.actions.run_shell(
outputs = [output_dir],
inputs = [],
command = """
mkdir -p $1/sub; \
index=0; while ((index<10)); do echo $index >$1/$index.txt; index=$(($index+1)); done
echo "Shuffle, duffle, muzzle, muff" > $1/sub/bar
""",
arguments = [output_dir.path],
execution_requirements = {"no-cache": ""},
)
return [
DefaultInfo(files = depset(direct = [output_dir])),
]
gen_output_dir = rule(
implementation = _gen_output_dir_impl,
attrs = {
"outdir": attr.string(mandatory = True),
},
)
EOF

cat > a/BUILD <<EOF
load(":output_dir.bzl", "gen_output_dir")
gen_output_dir(
name = "foo",
outdir = "dir",
)
EOF

bazel build \
--remote_cache=grpc://localhost:${worker_port} \
--incompatible_remote_build_event_upload_respect_no_cache \
--remote_build_event_upload=all \
--build_event_json_file=bep.json \
//a:foo >& $TEST_log || fail "Failed to build"

cat bep.json > $TEST_log
expect_not_log "a:foo.*bytestream://" || fail "local tree files are converted"
expect_not_log "a/dir/.*bytestream://" || fail "local tree files are converted"
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"
}

function test_uploader_respect_no_upload_results() {
mkdir -p a
cat > a/BUILD <<EOF
genrule(
name = 'foo',
outs = ["foo.txt"],
cmd = "echo \"foo bar\" > \$@",
)
EOF

bazel build \
--remote_cache=grpc://localhost:${worker_port} \
--remote_upload_local_results=false \
--incompatible_remote_build_event_upload_respect_no_cache \
--remote_build_event_upload=all \
--build_event_json_file=bep.json \
//a:foo >& $TEST_log || fail "Failed to build"

cat bep.json > $TEST_log
expect_not_log "a:foo.*bytestream://" || fail "local files are converted"
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"
}

function test_uploader_respect_no_upload_results_combined_cache() {
mkdir -p a
cat > a/BUILD <<EOF
genrule(
name = 'foo',
outs = ["foo.txt"],
cmd = "echo \"foo bar\" > \$@",
)
EOF

cache_dir=$(mktemp -d)

bazel build \
--remote_cache=grpc://localhost:${worker_port} \
--disk_cache=$cache_dir \
--remote_upload_local_results=false \
--incompatible_remote_build_event_upload_respect_no_cache \
--remote_build_event_upload=all \
--build_event_json_file=bep.json \
//a:foo >& $TEST_log || fail "Failed to build"

cat bep.json > $TEST_log
expect_not_log "a:foo.*bytestream://" || fail "local files are converted"
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"
remote_cas_files="$(count_remote_cas_files)"
[[ "$remote_cas_files" == 1 ]] || fail "Expected 1 remote cas entries, not $remote_cas_files"
}

function test_remote_exec_convert_remote_file() {
mkdir -p a
cat > a/BUILD <<'EOF'
sh_test(
name = "test",
srcs = ["test.sh"],
)
EOF
cat > a/test.sh <<'EOF'
#!/bin/bash
set -e
echo \"foo\"
exit 0
EOF
chmod 755 a/test.sh

bazel test \
--remote_executor=grpc://localhost:${worker_port} \
--build_event_json_file=bep.json \
--noremote_upload_local_results \
--incompatible_remote_build_event_upload_respect_no_cache \
--remote_build_event_upload=all \
//a:test >& $TEST_log || fail "Failed to test //a:test"

cat bep.json > $TEST_log
expect_not_log "test\.log.*file://" || fail "remote files generated in remote execution are not converted"
expect_log "test\.log.*bytestream://" || fail "remote files generated in remote execution are not converted"
}


function test_uploader_ignore_disk_cache_of_combined_cache() {
mkdir -p a
cat > a/BUILD <<EOF
genrule(
name = 'foo',
outs = ["foo.txt"],
cmd = "echo \"foo bar\" > \$@",
tags = ["no-cache"],
)
EOF

cache_dir=$(mktemp -d)

bazel build \
--remote_cache=grpc://localhost:${worker_port} \
--disk_cache=$cache_dir \
--incompatible_remote_build_event_upload_respect_no_cache \
--remote_build_event_upload=all \
--build_event_json_file=bep.json \
//a:foo >& $TEST_log || fail "Failed to build"

cat bep.json > $TEST_log
expect_not_log "a:foo.*bytestream://" || fail "local files are converted"
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"

disk_cas_files="$(count_disk_cas_files $cache_dir)"
[[ "$disk_cas_files" == 0 ]] || fail "Expected 0 disk cas entries, not $disk_cas_files"
}

function test_uploader_incompatible_remote_results_ignore_disk() {
mkdir -p a
cat > a/BUILD <<EOF
genrule(
name = 'foo',
outs = ["foo.txt"],
cmd = "echo \"foo bar\" > \$@",
tags = ["no-remote"],
)
EOF

cache_dir=$(mktemp -d)

bazel build \
--remote_cache=grpc://localhost:${worker_port} \
--disk_cache=$cache_dir \
--incompatible_remote_build_event_upload_respect_no_cache \
--remote_build_event_upload=all \
--incompatible_remote_results_ignore_disk \
--build_event_json_file=bep.json \
//a:foo >& $TEST_log || fail "Failed to build"

cat bep.json > $TEST_log
expect_not_log "a:foo.*bytestream://" || fail "local files are converted"
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"

disk_cas_files="$(count_disk_cas_files $cache_dir)"
# foo.txt, stdout and stderr for action 'foo'
[[ "$disk_cas_files" == 3 ]] || fail "Expected 3 disk cas entries, not $disk_cas_files"
}

function test_missing_outputs_dont_upload_action_result() {
# Test that if declared outputs are not created, even the exit code of action
# is 0, we treat this as failed and don't upload action result.
Expand Down

0 comments on commit 4743c64

Please sign in to comment.