Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create TEST_SHARD_STATUS_FILE when sharding tests #3547

Merged
merged 1 commit into from
Apr 26, 2023
Merged
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
5 changes: 5 additions & 0 deletions go/tools/builders/generate_test_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ func testsInShard() []testing.InternalTest {
if err != nil || totalShards <= 1 {
return allTests
}
file, err := os.Create(os.Getenv("TEST_SHARD_STATUS_FILE"))
if err != nil {
log.Fatalf("Failed to touch TEST_SHARD_STATUS_FILE: %v", err)
}
_ = file.Close()
shardIndex, err := strconv.Atoi(os.Getenv("TEST_SHARD_INDEX"))
if err != nil || shardIndex < 0 {
return allTests
Expand Down
6 changes: 6 additions & 0 deletions tests/core/go_test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ go_test(
],
)

go_test(
name = "sharding_test",
srcs = ["sharding_test.go"],
shard_count = 2,
)

go_bazel_test(
name = "env_inherit_test",
srcs = ["env_inherit_test.go"],
Expand Down
13 changes: 13 additions & 0 deletions tests/core/go_test/sharding_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package sharding_test

import (
"log"
"os"
"testing"
)

func TestShardStatusFile(t *testing.T) {
if _, err := os.Stat(os.Getenv("TEST_SHARD_STATUS_FILE")); err != nil {
log.Fatalf("Expected Go test runner to create TEST_SHARD_STATUS_FILE: %v", err)
}
}