Skip to content

Commit

Permalink
Fix remote execution tests for exclusive test
Browse files Browse the repository at this point in the history
Closes #18994.

PiperOrigin-RevId: 549564228
Change-Id: I8486b78b8396232bc2b1dfc30c334bbe6dbf0a91
  • Loading branch information
coeuvre authored and copybara-github committed Jul 20, 2023
1 parent cda08cc commit 6609d6d
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions src/test/shell/bazel/remote/remote_execution_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2044,8 +2044,7 @@ EOF
expect_log "2 remote cache hit"
}

function test_exclusive_tag() {
# Test that the exclusive tag works with the remote cache.
function setup_exclusive_test_case() {
mkdir -p a
cat > a/success.sh <<'EOF'
#!/bin/sh
Expand All @@ -2059,17 +2058,60 @@ sh_test(
tags = ["exclusive"],
)
EOF
}

function test_exclusive_test_hit_remote_cache() {
# Test that the exclusive test works with the remote cache.
setup_exclusive_test_case

# Warm up the cache
bazel test \
--remote_cache=grpc://localhost:${worker_port} \
//a:success_test || fail "Failed to test //a:success_test"

bazel clean

bazel test \
--remote_cache=grpc://localhost:${worker_port} \
//a:success_test >& $TEST_log || fail "Failed to test //a:success_test"

# test action + test xml generation
expect_log "2 remote cache hit"
}

function test_exclusive_test_and_no_cache_test_results() {
# Test that the exclusive test won't hit the remote cache if
# --nocache_test_results is set.
setup_exclusive_test_case

# Warm up the cache
bazel test \
--remote_cache=grpc://localhost:${worker_port} \
//a:success_test || fail "Failed to test //a:success_test"

bazel clean

bazel test \
--remote_cache=grpc://localhost:${worker_port} \
--nocache_test_results \
//a:success_test >& $TEST_log || fail "Failed to test //a:success_test"

expect_log "remote cache hit"
# test action
expect_log "1.*-sandbox"
# test xml generation
expect_log "1 remote cache hit"
}

function test_exclusive_test_wont_remote_exec() {
# Test that the exclusive test won't execute remotely.
setup_exclusive_test_case

bazel test \
--remote_executor=grpc://localhost:${worker_port} \
//a:success_test >& $TEST_log || fail "Failed to test //a:success_test"

# test action + test xml generation
expect_log "2.*-sandbox"
}

# TODO(alpha): Add a test that fails remote execution when remote worker
Expand Down

0 comments on commit 6609d6d

Please sign in to comment.