cmd/testwrapper, tstest: move test sharding out of test code
Previously, sharding required tests to opt in by calling tstest.Shard, which used a process-global counter to assign each test to a shard. This had two problems: most tests didn't call it, so they ran on every shard (defeating the purpose), and shard assignments were unstable (depended on call order, so adding a test could reshuffle others). Remove tstest.Shard and tstest.SkipOnUnshardedCI entirely. Instead, have testwrapper implement sharding automatically for all tests: when TS_TEST_SHARD=N/M is set, it uses "go list -json" (no compilation) to find test source files, scans them for top-level Test/Benchmark/ Example/Fuzz function names, and filters by fnv32a(name) % M == N-1. The filtered names are passed as an anchored -run regex to go test. Using go list instead of "go test -list" avoids linking the test binary twice (Go's build cache does not cache test binary linking). Fixes #19886 Change-Id: I62ab7b3d757324d4c5fd0b5de50c1e3742681791 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
db60aa8eca
commit
94af1b00fb
@@ -57,7 +57,6 @@ func metricByName(t testing.TB, name string) *clientmetric.Metric {
|
||||
// [tstest/largetailnet/BenchmarkGiantTailnet], which only measures cost
|
||||
// of the same fast path — this test verifies correctness.
|
||||
func TestNetmapDeltaFastPath(t *testing.T) {
|
||||
tstest.Shard(t)
|
||||
|
||||
logf := logger.Discard
|
||||
if testing.Verbose() {
|
||||
@@ -105,7 +104,7 @@ func TestNetmapDeltaFastPath(t *testing.T) {
|
||||
// Snapshot baseline metric values; we'll assert deltas against
|
||||
// these. Globals make per-test isolation impossible, but deltas
|
||||
// are robust against interleaving (assuming no other test runs in
|
||||
// parallel here, hence tstest.Shard above).
|
||||
// parallel here).
|
||||
mFast := metricByName(t, "controlclient_map_response_handled_incrementally")
|
||||
mFull := metricByName(t, "controlclient_map_response_handled_full_rebuild")
|
||||
mUpsert := metricByName(t, "localbackend_netmap_delta_peer_upserted")
|
||||
|
||||
Reference in New Issue
Block a user