bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.06k stars 4.04k forks source link

Local_test_resources doesn't actually restrict concurrency when `--local_test_jobs` is specified #22598

Open Ryang20718 opened 4 months ago

Ryang20718 commented 4 months ago

Description of the bug:

I expect the resource:<name>:amount tag to restrict test concurrency

Which category does this issue belong to?

Core

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

sh_test( name = "a", srcs = ["test.sh"], tags = ["resources:foo:1"], )

sh_test( name = "b", srcs = ["test.sh"], tags = ["resources:foo:1"], )

assuming this is in the root dir, if I run bazel test //... --local_resources=foo=1, I'd expect test a and b to run serially, but currently they run in parallel

Which operating system are you running Bazel on?

ubuntu 20.04

What is the output of bazel info release?

release 7.1.2

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

https://github.com/bazelbuild/bazel/issues/18153

Any other information, logs, or outputs that you want to share?

No response

fmeum commented 4 months ago

@AlessandroPatti

AlessandroPatti commented 4 months ago

@Ryang20718 @fmeum I am unable to repro this issue with the following commands

pushd $(mktemp -d)
touch MODULE.bazel
echo 'sh_test(name="a",srcs=["test.sh"],tags=["resources:foo:1"])' >> BUILD.bazel
echo 'sh_test(name="b",srcs=["test.sh"],tags=["resources:foo:1"])' >> BUILD.bazel
echo 'sleep 10' > test.sh
chmod u+x test.sh
USE_BAZEL_VERSION=7.1.2 bazelisk test //... --spawn_strategy=local --local_resources=foo=1 --disk_cache= --remote_cache= --nocache_test_results

The output looks like

[9 / 11] 2 actions, 1 running
   Testing //:a; 6s local
   [Sched] Testing //:b; 6s

Maybe related to https://github.com/bazelbuild/bazel/issues/19709?

Ryang20718 commented 4 months ago

@AlessandroPatti

we have --local_test_jobs=8 which seems to take precedence over the local_resources?

Ryang20718 commented 4 months ago

But yeah, with that removed it works!. I think that makes sense, if we tag all of our jobs with resources, probably shouldn't be using --local_test_jobs

fmeum commented 4 months ago

I think that this interaction is still pretty confusing - could you reopen?