Skip to content
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
2 changes: 1 addition & 1 deletion common/authorization/default_authorizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (s *defaultAuthorizerSuite) testGetAuthorizerFromConfig(name string, valid
s.NoError(err)
s.NotNil(auth)
t := reflect.TypeOf(auth)
s.True(t == authorizerType)
s.Equal(t, authorizerType)
} else {
s.Error(err)
s.Nil(auth)
Expand Down
12 changes: 6 additions & 6 deletions common/authorization/default_jwt_claim_mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (s *defaultClaimMapperSuite) testTokenWithAdminPermissions(alg keyAlgorithm
s.NoError(err)
s.Equal(testSubject, claims.Subject)
s.Equal(RoleAdmin, claims.System)
s.Equal(1, len(claims.Namespaces))
s.Len(claims.Namespaces, 1)
defaultRole := claims.Namespaces[defaultNamespace]
s.Equal(RoleReader, defaultRole)
}
Expand All @@ -154,7 +154,7 @@ func (s *defaultClaimMapperSuite) TestNamespacePermissionCaseSensitive() {
s.NoError(err)
s.Equal(testSubject, claims.Subject)
s.Equal(RoleUndefined, claims.System) // no system role
s.Equal(2, len(claims.Namespaces))
s.Len(claims.Namespaces, 2)
// claims contain namespace role for 'Foo', not for 'foo'.
s.Equal(RoleReader, claims.Namespaces["Foo"])
s.Equal(RoleAdmin, claims.Namespaces["Temporal-system"])
Expand All @@ -181,7 +181,7 @@ func (s *defaultClaimMapperSuite) testTokenWithReaderWriterWorkerPermissions(alg
s.NoError(err)
s.Equal(testSubject, claims.Subject)
s.Equal(RoleUndefined, claims.System)
s.Equal(1, len(claims.Namespaces))
s.Len(claims.Namespaces, 1)
defaultRole := claims.Namespaces[defaultNamespace]
s.Equal(RoleReader|RoleWriter|RoleWorker, defaultRole)
}
Expand All @@ -198,7 +198,7 @@ func (s *defaultClaimMapperSuite) TestTokenWithReaderWriterWorkerPermissionsRege
s.NoError(err)
s.Equal(testSubject, claims.Subject)
s.Equal(RoleUndefined, claims.System)
s.Equal(1, len(claims.Namespaces))
s.Len(claims.Namespaces, 1)
defaultRole := claims.Namespaces[defaultNamespace]
s.Equal(RoleReader|RoleWriter|RoleWorker, defaultRole)
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func (s *defaultClaimMapperSuite) TestTokenWithAdminPermissionsRegex() {
s.NoError(err)
s.Equal(testSubject, claims.Subject)
s.Equal(RoleAdmin, claims.System)
s.Equal(1, len(claims.Namespaces))
s.Len(claims.Namespaces, 1)
defaultRole := claims.Namespaces[defaultNamespace]
s.Equal(RoleReader, defaultRole)
}
Expand Down Expand Up @@ -314,7 +314,7 @@ func (s *defaultClaimMapperSuite) testGetClaimMapperFromConfig(name string, vali
s.NoError(err)
s.NotNil(cm)
t := reflect.TypeOf(cm)
s.True(t == cmType)
s.Equal(t, cmType)
} else {
s.Error(err)
s.Nil(cm)
Expand Down
24 changes: 12 additions & 12 deletions common/backoff/jitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func (s *jitterSuite) TestJitter_Int64() {

for range 1048576 {
result := Jitter(input, coefficient)
s.True(result >= lowerBound)
s.True(result < upperBound)
s.GreaterOrEqual(result, lowerBound)
s.Less(result, upperBound)

result = FullJitter(input)
s.True(result >= 0)
s.True(result < input)
s.GreaterOrEqual(result, int64(0))
s.Less(result, input)
}
}

Expand All @@ -47,12 +47,12 @@ func (s *jitterSuite) TestJitter_Float64() {

for range 1048576 {
result := Jitter(input, coefficient)
s.True(result >= lowerBound)
s.True(result < upperBound)
s.GreaterOrEqual(result, lowerBound)
s.Less(result, upperBound)

result = FullJitter(input)
s.True(result >= 0)
s.True(result < input)
s.GreaterOrEqual(result, float64(0))
s.Less(result, input)
}
}

Expand All @@ -64,12 +64,12 @@ func (s *jitterSuite) TestJitter_Duration() {

for range 1048576 {
result := Jitter(input, coefficient)
s.True(result >= lowerBound)
s.True(result < upperBound)
s.GreaterOrEqual(result, lowerBound)
s.Less(result, upperBound)

result = FullJitter(input)
s.True(result >= 0)
s.True(result < input)
s.GreaterOrEqual(result, time.Duration(0))
s.Less(result, input)
}
}

Expand Down
36 changes: 18 additions & 18 deletions common/backoff/retrypolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func (s *RetryPolicySuite) TestExponentialBackoff() {
for _, expected := range expectedResult {
min, max := getNextBackoffRange(expected)
next := r.NextBackOff(nil)
s.True(next >= min, "NextBackoff too low")
s.True(next < max, "NextBackoff too high")
s.GreaterOrEqual(next, min, "NextBackoff too low")
s.Less(next, max, "NextBackoff too high")
}
}

Expand Down Expand Up @@ -116,8 +116,8 @@ func (s *RetryPolicySuite) TestMaximumInterval() {
for _, expected := range expectedResult {
min, max := getNextBackoffRange(expected)
next := r.NextBackOff(nil)
s.True(next >= min, "NextBackoff too low")
s.True(next < max, "NextBackoff too high")
s.GreaterOrEqual(next, min, "NextBackoff too low")
s.Less(next, max, "NextBackoff too high")
}
}

Expand All @@ -129,8 +129,8 @@ func (s *RetryPolicySuite) TestBackoffCoefficient() {
min, max := getNextBackoffRange(2 * time.Second)
for range 10 {
next := r.NextBackOff(nil)
s.True(next >= min, "NextBackoff too low")
s.True(next < max, "NextBackoff too high")
s.GreaterOrEqual(next, min, "NextBackoff too low")
s.Less(next, max, "NextBackoff too high")
}
}

Expand All @@ -152,15 +152,15 @@ func (s *RetryPolicySuite) TestExpirationOverflow() {
r, ts := createRetrier(policy)
next := r.NextBackOff(nil)
min, max := getNextBackoffRange(2 * time.Second)
s.True(next >= min, "NextBackoff too low")
s.True(next < max, "NextBackoff too high")
s.GreaterOrEqual(next, min, "NextBackoff too low")
s.Less(next, max, "NextBackoff too high")

ts.Advance(2 * time.Second)

next = r.NextBackOff(nil)
min, max = getNextBackoffRange(3 * time.Second)
s.True(next >= min, "NextBackoff too low")
s.True(next < max, "NextBackoff too high")
s.GreaterOrEqual(next, min, "NextBackoff too low")
s.Less(next, max, "NextBackoff too high")
}

func (s *RetryPolicySuite) TestDefaultPublishRetryPolicy() {
Expand Down Expand Up @@ -192,8 +192,8 @@ func (s *RetryPolicySuite) TestDefaultPublishRetryPolicy() {
s.Equal(done, next, "backoff not done yet!!!")
} else {
min, max := getNextBackoffRange(expected)
s.True(next >= min, "NextBackoff too low: actual: %v, min: %v", next, min)
s.True(next < max, "NextBackoff too high: actual: %v, max: %v", next, max)
s.GreaterOrEqual(next, min, "NextBackoff too low: actual: %v, min: %v", next, min)
s.Less(next, max, "NextBackoff too high: actual: %v, max: %v", next, max)
ts.Advance(expected)
}
}
Expand Down Expand Up @@ -262,8 +262,8 @@ func (s *RetryPolicySuite) TestErrorDependentPolicy() {
retrier, _ = createRetrier(policy)

delay = retrier.NextBackOff(fmt.Errorf("other error"))
s.True(delay >= 1*time.Second)
s.True(delay < 1500*time.Millisecond)
s.GreaterOrEqual(delay, 1*time.Second)
s.Less(delay, 1500*time.Millisecond)
}

func (s *RetryPolicySuite) TestConstantDelayPolicy() {
Expand All @@ -290,8 +290,8 @@ func (s *RetryPolicySuite) TestConstantDelayPolicy() {
retrier, _ = createRetrier(policy)

delay = retrier.NextBackOff(nil)
s.True(delay >= 2*time.Second)
s.True(delay < 2200*time.Millisecond)
s.GreaterOrEqual(delay, 2*time.Second)
s.Less(delay, 2200*time.Millisecond)
}

// Validate jitter computation
Expand All @@ -300,8 +300,8 @@ func (s *RetryPolicySuite) TestAddJitter() {
delay := 1 * time.Second
jitter := 0.5
jitteredDelay := addJitter(delay, jitter)
s.True(jitteredDelay >= 1*time.Second)
s.True(jitteredDelay < 1500*time.Millisecond)
s.GreaterOrEqual(jitteredDelay, 1*time.Second)
s.Less(jitteredDelay, 1500*time.Millisecond)
}
}

Expand Down
6 changes: 3 additions & 3 deletions common/cluster/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ func (s *metadataSuite) Test_RegisterMetadataChangeCallback() {
s.metadata.RegisterMetadataChangeCallback(
s,
func(oldClusterMetadata map[string]*ClusterInformation, newClusterMetadata map[string]*ClusterInformation) {
s.Equal(3, len(newClusterMetadata))
s.Len(newClusterMetadata, 3)
})

s.metadata.UnRegisterMetadataChangeCallback(s)
s.Equal(0, len(s.metadata.clusterChangeCallback))
s.Empty(s.metadata.clusterChangeCallback)
}

func (s *metadataSuite) Test_RefreshClusterMetadata_Success() {
Expand Down Expand Up @@ -389,5 +389,5 @@ func (s *metadataSuite) Test_ListAllClusterMetadataFromDB_Success() {

resp, err := s.metadata.listAllClusterMetadataFromDB(context.Background())
s.NoError(err)
s.Equal(2, len(resp))
s.Len(resp, 2)
}
8 changes: 4 additions & 4 deletions common/collection/concurrent_tx_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *ConcurrentTxMapSuite) TestGetAndDo() {
return nil
})
s.Nil(interf, "GetAndDo should return nil when key not found")
s.Nil(err, "GetAndDo should return nil when function not applied")
s.NoError(err, "GetAndDo should return nil when function not applied")
s.False(ok, "GetAndDo should return false when key not found")
s.False(fnApplied, "GetAndDo should not apply function when key not exixts")

Expand All @@ -79,7 +79,7 @@ func (s *ConcurrentTxMapSuite) TestGetAndDo() {

value1 := interf.(*intType)
s.Equal(*(value1), intType(2))
s.NotNil(err, "GetAndDo should return non nil when function applied")
s.Error(err, "GetAndDo should return non nil when function applied")
s.True(ok, "GetAndDo should return true when key found")
s.True(fnApplied, "GetAndDo should apply function when key exixts")
}
Expand All @@ -97,7 +97,7 @@ func (s *ConcurrentTxMapSuite) TestPutOrDo() {
})
valueRetuern := interf.(*intType)
s.Equal(value, *valueRetuern)
s.Nil(err, "PutOrDo should return nil when function not applied")
s.NoError(err, "PutOrDo should return nil when function not applied")
s.False(ok, "PutOrDo should return false when function not applied")
s.False(fnApplied, "PutOrDo should not apply function when key not exixts")

Expand All @@ -110,7 +110,7 @@ func (s *ConcurrentTxMapSuite) TestPutOrDo() {
})
valueRetuern = interf.(*intType)
s.Equal(value, *valueRetuern)
s.NotNil(err, "PutOrDo should return non nil when function applied")
s.Error(err, "PutOrDo should return non nil when function applied")
s.True(ok, "PutOrDo should return true when function applied")
s.True(fnApplied, "PutOrDo should apply function when key exixts")
}
Expand Down
14 changes: 7 additions & 7 deletions common/dynamicconfig/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,30 +129,30 @@ func (s *collectionSuite) TestGetFloat64Property() {
func (s *collectionSuite) TestGetBoolProperty() {
setting := dynamicconfig.NewGlobalBoolSetting(testGetBoolPropertyKey, true, "")
value := setting.Get(s.cln)
s.Equal(true, value())
s.True(value())
s.client.SetValue(testGetBoolPropertyKey, false)
s.Equal(false, value())
s.False(value())
s.client.SetValue(testGetBoolPropertyKey, "false")
s.Equal(false, value())
s.False(value())
}

func (s *collectionSuite) TestGetBoolPropertyFilteredByNamespaceID() {
setting := dynamicconfig.NewNamespaceIDBoolSetting(testGetBoolPropertyFilteredByNamespaceIDKey, true, "")
namespaceID := namespace.ID("testNamespaceID")
value := setting.Get(s.cln)
s.Equal(true, value(namespaceID))
s.True(value(namespaceID))
s.client.SetValue(testGetBoolPropertyFilteredByNamespaceIDKey, false)
s.Equal(false, value(namespaceID))
s.False(value(namespaceID))
}

func (s *collectionSuite) TestGetBoolPropertyFilteredByTaskQueueInfo() {
setting := dynamicconfig.NewTaskQueueBoolSetting(testGetBoolPropertyFilteredByTaskQueueInfoKey, false, "")
namespace := "testNamespace"
taskQueue := "testTaskQueue"
value := setting.Get(s.cln)
s.Equal(false, value(namespace, taskQueue, 0))
s.False(value(namespace, taskQueue, 0))
s.client.SetValue(testGetBoolPropertyFilteredByTaskQueueInfoKey, true)
s.Equal(true, value(namespace, taskQueue, 0))
s.True(value(namespace, taskQueue, 0))
}

func (s *collectionSuite) TestGetDurationProperty() {
Expand Down
20 changes: 10 additions & 10 deletions common/dynamicconfig/file_based_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (s *fileBasedClientSuite) SetupTest() {

func (s *fileBasedClientSuite) TestGetValue() {
cvs := s.client.GetValue(dynamicconfig.MakeKey(testGetBoolPropertyKey))
s.Equal(3, len(cvs))
s.Len(cvs, 3)
s.ElementsMatch([]dynamicconfig.ConstrainedValue{
{Constraints: dynamicconfig.Constraints{}, Value: false},
{Constraints: dynamicconfig.Constraints{Namespace: "global-samples-namespace"}, Value: true},
Expand Down Expand Up @@ -91,10 +91,10 @@ func (s *fileBasedClientSuite) TestNewFileBasedClientWithoutMetrics() {

func (s *fileBasedClientSuite) TestGetValue_CaseInsensitie() {
cvs := s.client.GetValue(dynamicconfig.MakeKey(testCaseInsensitivePropertyKey))
s.Equal(1, len(cvs))
s.Len(cvs, 1)

v := dynamicconfig.NewGlobalBoolSetting(testCaseInsensitivePropertyKey, false, "").Get(s.collection)()
s.Equal(true, v)
s.True(v)
}

func (s *fileBasedClientSuite) TestGetIntValue() {
Expand Down Expand Up @@ -185,7 +185,7 @@ func (s *fileBasedClientSuite) TestGetFloatValue_WrongType() {

func (s *fileBasedClientSuite) TestGetBoolValue() {
v := dynamicconfig.NewGlobalBoolSetting(testGetBoolPropertyKey, true, "").Get(s.collection)()
s.Equal(false, v)
s.False(v)
}

func (s *fileBasedClientSuite) TestGetStringValue() {
Expand Down Expand Up @@ -902,7 +902,7 @@ testGetFloat64PropertyKey:
- value: 22.222
`))
s.Empty(lr.Errors)
s.Equal(1, len(lr.Warnings))
s.Len(lr.Warnings, 1)
s.ErrorContains(lr.Warnings[0], `unregistered key "testgetfloat64propertykey"`)
}

Expand All @@ -914,7 +914,7 @@ testGetIntPropertyKey:
- value: not a number
`))
s.Empty(lr.Errors)
s.Equal(1, len(lr.Warnings))
s.Len(lr.Warnings, 1)
s.ErrorContains(lr.Warnings[0], `validation failed: key "testgetintpropertykey" value not a number: value type is not int`)
}

Expand All @@ -928,7 +928,7 @@ testGetIntPropertyKey:
namespace: samples-namespace
`))
s.Empty(lr.Errors)
s.Equal(1, len(lr.Warnings))
s.Len(lr.Warnings, 1)
s.ErrorContains(lr.Warnings[0], `constraint "namespace" isn't valid for dynamic config key "testgetintpropertykey"`)
}

Expand All @@ -944,12 +944,12 @@ testGetIntPropertyKey:
namespace: samples-namespace
`))
s.Empty(lr.Errors)
s.Equal(3, len(lr.Warnings))
s.Len(lr.Warnings, 3)
}

func (s *fileBasedClientSuite) TestErrorYamlDecode() {
lr := dynamicconfig.LoadYamlFile([]byte(`}}}}}}}}}`))
s.Equal(1, len(lr.Errors))
s.Len(lr.Errors, 1)
s.ErrorContains(lr.Errors[0], "decode error")
}

Expand All @@ -962,7 +962,7 @@ testGetBoolPropertyKey:
constraints:
namespace: 35
`))
s.Equal(1, len(lr.Errors))
s.Len(lr.Errors, 1)
s.ErrorContains(lr.Errors[0], "namespace constraint must be string")
}

Expand Down
Loading
Loading