Skip to content

Commit

Permalink
Functional tests refactoring (#6559)
Browse files Browse the repository at this point in the history
## What changed?
1. Refactor functional tests.
2. Move all common code into separate module
3. For every test - create designated test suite.
4. For every test - create '_test.go" file that is executing the
corresponding test suite.
5. Lots of minor refactoring related to code being messy.
  • Loading branch information
ychebotarev authored Oct 2, 2024
1 parent 913972b commit 5030b23
Show file tree
Hide file tree
Showing 114 changed files with 6,523 additions and 4,834 deletions.
13 changes: 7 additions & 6 deletions tests/acquire_shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ import (

"go.temporal.io/server/common/log"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/tests/testcore"
)

// AcquireShardFunctionalSuite is the base test suite for testing acquire shard.
// AcquireShardFunctionalSuite is the testcore test suite for testing acquire shard.
type AcquireShardFunctionalSuite struct {
FunctionalTestBase
testcore.FunctionalTestBase
logRecorder *logRecorder
logs chan logRecord
}
Expand All @@ -51,7 +52,7 @@ func (s *AcquireShardFunctionalSuite) SetupSuite() {
func (s *AcquireShardFunctionalSuite) TearDownSuite() {
// we need to wait for all components to start before we can safely tear down
time.Sleep(time.Second * 5)
s.tearDownSuite()
s.FunctionalTestBase.TearDownSuite()
}

// newLogRecorder creates a new log recorder. It records all the logs to the given channel.
Expand Down Expand Up @@ -109,7 +110,7 @@ type OwnershipLostErrorSuite struct {
// SetupSuite reads the shard ownership lost error fault injection config from the testdata folder.
func (s *OwnershipLostErrorSuite) SetupSuite() {
s.AcquireShardFunctionalSuite.SetupSuite()
s.setupSuite("testdata/acquire_shard_ownership_lost_error.yaml")
s.FunctionalTestBase.SetupSuite("testdata/acquire_shard_ownership_lost_error.yaml")
}

// TestDoesNotRetry verifies that we do not retry acquiring the shard when we get an ownership lost error.
Expand Down Expand Up @@ -151,7 +152,7 @@ type DeadlineExceededErrorSuite struct {
// SetupSuite reads the deadline exceeded error targeted fault injection config from the test data folder.
func (s *DeadlineExceededErrorSuite) SetupSuite() {
s.AcquireShardFunctionalSuite.SetupSuite()
s.setupSuite("testdata/acquire_shard_deadline_exceeded_error.yaml")
s.FunctionalTestBase.SetupSuite("testdata/acquire_shard_deadline_exceeded_error.yaml")
}

// TestDoesRetry verifies that we do retry acquiring the shard when we get a deadline exceeded error because that should
Expand Down Expand Up @@ -193,7 +194,7 @@ type EventualSuccessSuite struct {
// the next call to return a successful response.
func (s *EventualSuccessSuite) SetupSuite() {
s.AcquireShardFunctionalSuite.SetupSuite()
s.setupSuite("testdata/acquire_shard_eventual_success.yaml")
s.FunctionalTestBase.SetupSuite("testdata/acquire_shard_eventual_success.yaml")
}

// TestEventuallySucceeds verifies that we eventually succeed in acquiring the shard when we get a deadline exceeded
Expand Down
Loading

0 comments on commit 5030b23

Please sign in to comment.