Shard the fuzz test

This commit is contained in:
David Dworken 2024-02-10 19:59:26 -08:00
parent 7fb25c22c1
commit f2c3aebe3a
No known key found for this signature in database
2 changed files with 35 additions and 7 deletions

View File

@ -60,15 +60,37 @@ var shellTesters []shellTester = []shellTester{bashTester{}, zshTester{}}
var shardNumberAllocator int = 0
func markTestForSharding(t *testing.T, testShardNumber int) {
func numTestShards() int {
numTestShardsStr := os.Getenv("NUM_TEST_SHARDS")
currentShardNumberStr := os.Getenv("CURRENT_SHARD_NUM")
if numTestShardsStr != "" && currentShardNumberStr != "" {
if numTestShardsStr == "" {
return 0
}
numTestShards, err := strconv.Atoi(numTestShardsStr)
require.NoError(t, err)
if err != nil {
panic(fmt.Errorf("failed to parse NUM_TEST_SHARDS: %v", err))
}
return numTestShards
}
func currentShardNumber() int {
currentShardNumberStr := os.Getenv("CURRENT_SHARD_NUM")
if currentShardNumberStr == "" {
return 0
}
currentShardNumber, err := strconv.Atoi(currentShardNumberStr)
require.NoError(t, err)
if testShardNumber%numTestShards != currentShardNumber {
if err != nil {
panic(fmt.Errorf("failed to parse CURRENT_SHARD_NUM: %v", err))
}
return currentShardNumber
}
func isShardedTestRun() bool {
return numTestShards() != 0 && currentShardNumber() != 0
}
func markTestForSharding(t *testing.T, testShardNumber int) {
if isShardedTestRun() {
if testShardNumber%numTestShards() == currentShardNumber() {
t.Skip("Skipping sharded test")
}
}

View File

@ -142,6 +142,12 @@ func FuzzTestMultipleUsers(f *testing.F) {
if skipSlowTests() {
f.Skip("skipping slow tests")
}
if isShardedTestRun() {
if currentShardNumber() == 0 {
f.Skip("Skipping sharded test")
}
}
s := os.Getenv("SPLIT_TESTS")
if s != "" && s != "BASIC" {
f.Skip()