Skip to content
Draft
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
10 changes: 3 additions & 7 deletions common/backoff/jitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ import (
"testing"
"time"

"github.com/stretchr/testify/suite"
"go.temporal.io/server/common/testing/parallelsuite"
)

type (
jitterSuite struct {
suite.Suite
parallelsuite.Suite[*jitterSuite]
}
)

func TestJitterSuite(t *testing.T) {
s := new(jitterSuite)
suite.Run(t, s)
}

func (s *jitterSuite) SetupSuite() {
parallelsuite.Run(t, new(jitterSuite))
}

func (s *jitterSuite) TestJitter_Int64() {
Expand Down
12 changes: 3 additions & 9 deletions common/backoff/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,20 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.temporal.io/api/serviceerror"
"go.temporal.io/server/common/testing/parallelsuite"
)

type (
RetrySuite struct {
*require.Assertions // override suite.Suite.Assertions with require.Assertions; this means that s.NotNil(nil) will stop the test, not merely log an error
suite.Suite
parallelsuite.Suite[*RetrySuite]
}

someError struct{}
)

func TestRetrySuite(t *testing.T) {
suite.Run(t, new(RetrySuite))
}

func (s *RetrySuite) SetupTest() {
s.Assertions = require.New(s.T()) // Have to define our overridden assertions in the test setup. If we did it earlier, s.T() will return nil
parallelsuite.RunLegacySequential(t, new(RetrySuite)) //nolint:staticcheck // SA1019: TestThrottleRetryContext temporarily changes package global retry policy.
}

func (s *RetrySuite) TestRetrySuccess() {
Expand Down
12 changes: 3 additions & 9 deletions common/backoff/retrypolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.temporal.io/server/common/clock"
"go.temporal.io/server/common/testing/parallelsuite"
)

type (
RetryPolicySuite struct {
*require.Assertions // override suite.Suite.Assertions with require.Assertions; this means that s.NotNil(nil) will stop the test, not merely log an error
suite.Suite
parallelsuite.Suite[*RetryPolicySuite]
}
)

Expand Down Expand Up @@ -62,11 +60,7 @@ func ExampleExponentialRetryPolicy_WithMaximumInterval() {
}

func TestRetryPolicySuite(t *testing.T) {
suite.Run(t, new(RetryPolicySuite))
}

func (s *RetryPolicySuite) SetupTest() {
s.Assertions = require.New(s.T()) // Have to define our overridden assertions in the test setup. If we did it earlier, s.T() will return nil
parallelsuite.Run(t, new(RetryPolicySuite))
}

func (s *RetryPolicySuite) TestExponentialBackoff() {
Expand Down
19 changes: 7 additions & 12 deletions common/circuitbreaker/circuitbreaker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/testing/parallelsuite"
)

type TSCBWithDynamicSettingsTestSuite struct {
suite.Suite
type CircuitBreakerSuite struct {
parallelsuite.Suite[*CircuitBreakerSuite]
}

func TestTSCBWithDynamicSettings(t *testing.T) {
suite.Run(t, &TSCBWithDynamicSettingsTestSuite{})
func TestCircuitBreakerSuite(t *testing.T) {
parallelsuite.Run(t, new(CircuitBreakerSuite))
}

func TestBasic(t *testing.T) {
s := assert.New(t)

func (s *CircuitBreakerSuite) TestBasic() {
name := "test-tscb"
tscb := NewTwoStepCircuitBreakerWithDynamicSettings(Settings{Name: name})
tscb.UpdateSettings(dynamicconfig.CircuitBreakerSettings{})
Expand All @@ -30,9 +27,7 @@ func TestBasic(t *testing.T) {
doneFn(true)
}

func TestDynamicSettings(t *testing.T) {
s := assert.New(t)

func (s *CircuitBreakerSuite) TestDynamicSettings() {
tscb := NewTwoStepCircuitBreakerWithDynamicSettings(Settings{})
tscb.UpdateSettings(dynamicconfig.CircuitBreakerSettings{})
cb1 := tscb.cb.Load()
Expand Down
7 changes: 3 additions & 4 deletions common/definition/resource_dedup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/suite"
"go.temporal.io/server/common/testing/parallelsuite"
)

type (
resourceDeduplicationSuite struct {
suite.Suite
parallelsuite.Suite[*resourceDeduplicationSuite]
}
)

func TestResourceDeduplicationSuite(t *testing.T) {
s := new(resourceDeduplicationSuite)
suite.Run(t, s)
parallelsuite.Run(t, new(resourceDeduplicationSuite))
}

func (s *resourceDeduplicationSuite) TestGenerateKey() {
Expand Down
12 changes: 3 additions & 9 deletions common/headers/caller_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,18 @@ import (
"context"
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.temporal.io/server/common/testing/parallelsuite"
"google.golang.org/grpc/metadata"
)

type (
callerInfoSuite struct {
*require.Assertions
suite.Suite
parallelsuite.Suite[*callerInfoSuite]
}
)

func TestCallerInfoSuite(t *testing.T) {
suite.Run(t, &callerInfoSuite{})
}

func (s *callerInfoSuite) SetupTest() {
s.Assertions = require.New(s.T())
parallelsuite.Run(t, &callerInfoSuite{})
}

func (s *callerInfoSuite) TestSetCallerName() {
Expand Down
12 changes: 3 additions & 9 deletions common/headers/version_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,18 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.temporal.io/api/serviceerror"
"go.temporal.io/server/common/testing/parallelsuite"
)

type (
VersionCheckerSuite struct {
*require.Assertions
suite.Suite
parallelsuite.Suite[*VersionCheckerSuite]
}
)

func TestVersionCheckerSuite(t *testing.T) {
suite.Run(t, new(VersionCheckerSuite))
}

func (s *VersionCheckerSuite) SetupTest() {
s.Assertions = require.New(s.T())
parallelsuite.Run(t, new(VersionCheckerSuite))
}

func (s *VersionCheckerSuite) TestClientSupported() {
Expand Down
21 changes: 3 additions & 18 deletions common/number/number_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,17 @@ import (
"math/rand"
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.temporal.io/server/common/testing/parallelsuite"
)

type (
numberSuite struct {
suite.Suite
*require.Assertions
parallelsuite.Suite[*numberSuite]
}
)

func TestNumberSuite(t *testing.T) {
s := new(numberSuite)
suite.Run(t, s)
}

func (s *numberSuite) SetupSuite() {}

func (s *numberSuite) TearDownSuite() {}

func (s *numberSuite) SetupTest() {
s.Assertions = require.New(s.T())
}

func (s *numberSuite) TearDownTest() {

parallelsuite.Run(t, new(numberSuite))
}

func (s *numberSuite) TestInt() {
Expand Down
12 changes: 5 additions & 7 deletions common/persistence/versionhistory/version_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,28 @@ package versionhistory
import (
"testing"

"github.com/stretchr/testify/suite"
"go.temporal.io/api/serviceerror"
historyspb "go.temporal.io/server/api/history/v1"
"go.temporal.io/server/common"
"go.temporal.io/server/common/testing/parallelsuite"
)

type (
versionHistorySuite struct {
suite.Suite
parallelsuite.Suite[*versionHistorySuite]
}

versionHistoriesSuite struct {
suite.Suite
parallelsuite.Suite[*versionHistoriesSuite]
}
)

func TestVersionHistorySuite(t *testing.T) {
s := new(versionHistorySuite)
suite.Run(t, s)
parallelsuite.Run(t, new(versionHistorySuite))
}

func TestVersionHistoriesSuite(t *testing.T) {
s := new(versionHistoriesSuite)
suite.Run(t, s)
parallelsuite.Run(t, new(versionHistoriesSuite))
}

func (s *versionHistorySuite) TestDuplicateUntilLCAItem_Success() {
Expand Down
13 changes: 3 additions & 10 deletions common/predicates/and_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,17 @@ package predicates
import (
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.temporal.io/server/common/testing/parallelsuite"
)

type (
andSuite struct {
suite.Suite
*require.Assertions
parallelsuite.Suite[*andSuite]
}
)

func TestAndSuite(t *testing.T) {
s := new(andSuite)
suite.Run(t, s)
}

func (s *andSuite) SetupTest() {
s.Assertions = require.New(s.T())
parallelsuite.Run(t, new(andSuite))
}

func (s *andSuite) TestAnd_Normal() {
Expand Down
35 changes: 13 additions & 22 deletions common/predicates/empty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,40 @@ package predicates
import (
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.temporal.io/server/common/testing/parallelsuite"
)

type (
emptySuite struct {
suite.Suite
*require.Assertions

emtpy Predicate[int]
parallelsuite.Suite[*emptySuite]
}
)

func TestNoneSuite(t *testing.T) {
s := new(emptySuite)
suite.Run(t, s)
}

func (s *emptySuite) SetupTest() {
s.Assertions = require.New(s.T())

s.emtpy = Empty[int]()
parallelsuite.Run(t, new(emptySuite))
}

func (s *emptySuite) TestEmpty_Test() {
empty := Empty[int]()
for i := 0; i != 10; i++ {
s.False(s.emtpy.Test(i))
s.False(empty.Test(i))
}
}

func (s *emptySuite) TestEmpty_Equals() {
s.True(s.emtpy.Equals(s.emtpy))
s.True(s.emtpy.Equals(Empty[int]()))
empty := Empty[int]()
s.True(empty.Equals(empty))
s.True(empty.Equals(Empty[int]()))

s.False(s.emtpy.Equals(newTestPredicate(1, 2, 3)))
s.False(s.emtpy.Equals(And[int](
s.False(empty.Equals(newTestPredicate(1, 2, 3)))
s.False(empty.Equals(And[int](
newTestPredicate(1, 2, 3),
newTestPredicate(2, 3, 4),
)))
s.False(s.emtpy.Equals(Or[int](
s.False(empty.Equals(Or[int](
newTestPredicate(1, 2, 3),
newTestPredicate(4, 5, 6),
)))
s.False(s.emtpy.Equals(Not[int](newTestPredicate(1, 2, 3))))
s.False(s.emtpy.Equals(Universal[int]()))
s.False(empty.Equals(Not[int](newTestPredicate(1, 2, 3))))
s.False(empty.Equals(Universal[int]()))
}
13 changes: 3 additions & 10 deletions common/predicates/not_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,17 @@ package predicates
import (
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.temporal.io/server/common/testing/parallelsuite"
)

type (
notSuite struct {
suite.Suite
*require.Assertions
parallelsuite.Suite[*notSuite]
}
)

func TestNotSuite(t *testing.T) {
s := new(notSuite)
suite.Run(t, s)
}

func (s *notSuite) SetupTest() {
s.Assertions = require.New(s.T())
parallelsuite.Run(t, new(notSuite))
}

func (s *notSuite) TestNot_Test() {
Expand Down
Loading