Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ build:regenerate-snapshots --//build/config:python_snapshots=false
test --local_resources=wptserve=1

# use lower test timeouts: https://bazel.build/reference/test-encyclopedia#role-test-runner
# corresponds to small,medium,large,enormous tests (medium is default)
build --test_timeout=3,15,60,240
# corresponds to small,medium,large,enormous tests (medium is default). No test gets more than 60 s,
# in any config: every test should finish within 40 s, sanitizers included, so a test that reaches
# 60 s has hung or regressed. Make a slow test faster or shard it; don't raise its size. Only PGO
# training (pgo-instrument) allows longer.
build --test_timeout=3,15,60,60

# TODO(cleanup): Bazel 9 sets this by default, which breaks the macOS-cross build. Fix and re-enable.
common --@bazel_tools//tools/test:incompatible_use_default_test_toolchain=False
Expand Down Expand Up @@ -336,8 +339,8 @@ build:tsan-common --test_env=TSAN_OPTIONS=halt_on_error=true:handle_sigabrt=0:hi
build:tsan-common --test_env=KJ_CLEAN_SHUTDOWN=1
# Clang-tidy loads this shared object into an unsanitized process, which cannot resolve TSan hooks.
build:tsan-common --per_file_copt='tools/clang-tidy@-fno-sanitize=thread'
# TSan significantly increases test runtime.
build:tsan-common --test_timeout=30,150,600,2400
# TSan significantly increases test runtime, so the smaller sizes get more time, up to the 60 s cap.
build:tsan-common --test_timeout=30,60,60,60
# Enable V8's TSan synchronization annotations. V8's Bazel build does not currently derive this
# define from the compiler's sanitizer flags. V8_IS_TSAN, which would also make V8's generated code
# call into TSan on every load and store, is left off: that costs V8-heavy tests about 20x the time
Expand Down Expand Up @@ -427,7 +430,7 @@ build:macos --copt='-femit-dwarf-unwind=no-compact-unwind'
build:macos-cross-x86_64 --cpu=darwin_x86_64 --host_cpu=darwin_arm64 --platforms //:macOS_x86
# Some cross-compiled tests are slower when run over Rosetta, increase the medium test size timeout.
# Test performance is still very much satisfactory considering that emulation is being used here.
build:macos-cross-x86_64 --test_timeout=1,30,60,240
build:macos-cross-x86_64 --test_timeout=1,30,60,60

# On Linux, the toolchain is LLVM's own, over a pinned sysroot (build/deps/llvm.MODULE.bazel), and
# nothing is taken from the host. It links libc++, libc++abi and libunwind statically, so binaries
Expand Down Expand Up @@ -545,7 +548,8 @@ build:pgo-instrument --config=release_linux-without-pgo --config=thin-lto --conf
build:pgo-instrument --copt=-fprofile-generate --linkopt=-fprofile-generate
# The instrumented tests run slower and also merge their profiles (build/pgo/profile-env.sh). In
# training, the serving workload takes about a minute against its 15 s limit, and the eventsource
# tests 10-12 s. A test that times out loses its profile.
# tests 10-12 s. A test that times out loses its profile. Training collects profiles rather than
# checking changes, so it keeps longer timeouts than the 60 s cap on every other config.
build:pgo-instrument --test_timeout=30,240,600,1200
# Instrument the Rust code too. Its counters go into the same profile, written by the profile
# runtime that clang links; rustc's own copy of that runtime would clash with it, and stable rustc
Expand Down Expand Up @@ -680,10 +684,11 @@ build:coverage --copt=-g1
# Use limited coverage mode for smaller binaries and faster execution (used by Chromium)
build:coverage --copt=-mllvm --copt=-limited-coverage-experimental=true
coverage --test_tag_filters=-off-by-default,-requires-fuzzilli,-requires-container-engine,-lint,-benchmark,-workerd-benchmark,-no-coverage
# Coverage instrumentation slows down test execution, so extend timeouts
# Coverage instrumentation slows down test execution, so every size gets the full 60 s cap. The
# slowest test takes about 25 s under coverage on bazelflare.
# We disable enormous tests due to the slowdown (CI jobs have a 6h max duration)
coverage --test_size_filters=-enormous
coverage --test_timeout=240,240,240,240
coverage --test_timeout=60,60,60,60
coverage --build_tests_only

# These configs are defined internally and enabled on many machines.
Expand Down
3 changes: 2 additions & 1 deletion src/workerd/server/tests/repl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("//:build/wd_py_test.bzl", "wd_py_test")
# `workerd repl` as a user runs it, input piped in: what only the command line and the console
# do. src/workerd/server/repl/repl-environment-test.c++ covers evaluation. Each case starts
# workerd; in a fastbuild on a loaded CI executor the cases take about 15 s in all, a medium test's
# whole timeout.
# whole timeout, and under TSan about 55 s, so they run in shards.
wd_js_test(
name = "repl-test",
size = "large",
Expand All @@ -17,6 +17,7 @@ wd_js_test(
"WORKERD_BINARY": "$(rootpath //src/workerd/server:workerd)",
"REPL_CONFIG": "$(rootpath :repl-test.capnp)",
},
shard_count = 4,
)

# `workerd repl` on a pseudo-terminal: what it leaves the terminal as when a signal ends it.
Expand Down
16 changes: 15 additions & 1 deletion src/workerd/server/tests/repl/repl-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@ import { mkdtemp, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { env, platform } from 'node:process';
import { test } from 'node:test';
import { test as nodeTest } from 'node:test';
import assert from 'node:assert';

assert(env.WORKERD_BINARY !== undefined, 'Set WORKERD_BINARY.');
assert(env.REPL_CONFIG !== undefined, 'Set REPL_CONFIG.');

// Each case starts workerd, which takes about two seconds under TSan, so Bazel runs the cases in
// shards (`shard_count`): a shard runs every SHARDS-th case declared, starting at its SHARD-th.
const SHARDS = Number(env.TEST_TOTAL_SHARDS ?? 1);
const SHARD = Number(env.TEST_SHARD_INDEX ?? 0);
if (env.TEST_SHARD_STATUS_FILE !== undefined) {
await writeFile(env.TEST_SHARD_STATUS_FILE, '');
}
let declared = 0;
function test(...args) {
if (declared++ % SHARDS === SHARD) {
nodeTest(...args);
}
}

// A build can make the compile caches for another binary's V8 flags
// (//build/config:compile_cache_v8_flags), and workerd then logs this warning as it starts. It
// isn't the REPL's output, so it's dropped from stderr.
Expand Down
11 changes: 9 additions & 2 deletions src/wpt/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ wpt_test(
"transformstream_enable_standard_constructor",
],
config = "encoding-test.ts",
# The shards divide the test files. Unsharded, the suite took 25 s under TSan, and 50-80 s on a
# slow executor.
shard_count = 4,
wpt_directory = "@wpt//:encoding@module",
)

Expand All @@ -224,8 +227,9 @@ wpt_test(
config = "WebCryptoAPI-test.ts",
include_tentative = True,
# Generating RSA keys makes up most of the run time, so the shards divide the variants of
# generateKey/successes_RSA-*.
shard_count = 8,
# generateKey/successes_RSA-*. With 8 shards, a shard took 20 s under TSan, and 40-60 s on a
# slow executor.
shard_count = 16,
target_compatible_with = select({
# Too slow on Windows
"@platforms//os:windows": ["@platforms//:incompatible"],
Expand Down Expand Up @@ -272,6 +276,9 @@ wpt_test(
"text_decoder_cjk_decoder",
],
config = "encoding-test-ts.ts",
# The shards divide the test files. Unsharded, the suite took 25 s under TSan, and 50-80 s on a
# slow executor.
shard_count = 4,
wpt_directory = "@wpt//:encoding@module",
)

Expand Down
Loading