Skip to content

Commit

Permalink
shard versioning at test level
Browse files Browse the repository at this point in the history
  • Loading branch information
dnr committed Oct 25, 2024
1 parent 538b41d commit 2379d76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/namespace_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestNamespaceSuite(t *testing.T) {

func (s *namespaceTestSuite) SetupSuite() {
// This suite doesn't embed FunctionalTestBase so we have to call CheckTestShard manually.
testcore.CheckTestShard(s.T())
testcore.CheckTestShard(s.T(), false)

s.logger = log.NewTestLogger()
s.testClusterFactory = testcore.NewTestClusterFactory()
Expand Down
25 changes: 17 additions & 8 deletions tests/testcore/functional_test_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"fmt"
"maps"
"os"
"slices"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -90,9 +89,12 @@ type (
)

var (
smokeTestSuites = []string{
"TestAdvancedVisibilitySuite",
"TestClientMiscTestSuite",
smokeTestSuites = map[string]bool{
"TestAdvancedVisibilitySuite": true,
"TestClientMiscTestSuite": true,
}
shardByTestSuites = map[string]bool{
"TestVersioningFunctionalSuite": true,
}
)

Expand Down Expand Up @@ -164,7 +166,7 @@ func (s *FunctionalTestBase) SetDynamicConfigOverrides(dynamicConfig map[dynamic
// Furthermore, all test suites in the "tests/" directory that don't inherit
// from FunctionalTestBase must implement SetupSuite that calls checkTestShard.
func (s *FunctionalTestBase) SetupSuite(defaultClusterConfigFile string, options ...Option) {
CheckTestShard(s.T())
CheckTestShard(s.T(), false)

s.testClusterFactory = NewTestClusterFactory()

Expand Down Expand Up @@ -215,15 +217,22 @@ func (s *FunctionalTestBase) SetupSuite(defaultClusterConfigFile string, options
}

func (s *FunctionalTestBase) SetupTest() {
CheckTestShard(s.T(), true)
}

// CheckTestShard supports test sharding based on environment variables.
func CheckTestShard(t *testing.T) {
func CheckTestShard(t *testing.T, atTestLevel bool) {
suiteName, _, _ := strings.Cut(t.Name(), "/")

shouldShardAtTestLevel := shardByTestSuites[suiteName]
if shouldShardAtTestLevel != atTestLevel {
return
}

indexStr := os.Getenv("TEST_SHARD_INDEX")
// special value to run only a few suites on the extended set of persistence drivers
if indexStr == "smoke_only" {
suiteName, _, _ := strings.Cut(t.Name(), "/")
if slices.Contains(smokeTestSuites, suiteName) {
if smokeTestSuites[suiteName] {
t.Logf("Running %s in smoke tests", t.Name())
return
}
Expand Down

0 comments on commit 2379d76

Please sign in to comment.