Skip to content

Commit 85c4381

Browse files
authored
Address #3923 feedback (#3938)
1 parent df9ec34 commit 85c4381

6 files changed

+34
-30
lines changed

.golangci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ linters-settings:
8383
arguments:
8484
- "fmt.Printf"
8585
issues:
86+
# Exclude cyclomatic and cognitive complexity rules for functional tests in the `tests` root directory.
8687
exclude-rules:
87-
- path: tests\/.+\.go
88+
- path: ^tests\/.+\.go
8889
text: "(cyclomatic|cognitive)"
8990
linters:
9091
- revive

service/frontend/workflow_handler.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -3071,7 +3071,9 @@ func (wh *WorkflowHandler) validateStartWorkflowArgsForSchedule(
30713071
return errIDReusePolicyNotAllowed
30723072
}
30733073

3074-
// Unalias startWorkflow search attributes only for validation. Keep aliases in request.
3074+
// Unalias startWorkflow search attributes only for validation.
3075+
// Keep aliases in the request, because the request will be
3076+
// sent back to frontend to start workflows, which will unalias at that point.
30753077
unaliasedStartWorkflowSas, err := searchattribute.UnaliasFields(wh.saMapperProvider, startWorkflow.GetSearchAttributes(), namespaceName.String())
30763078
if err != nil {
30773079
return err
@@ -3170,6 +3172,8 @@ func (wh *WorkflowHandler) DescribeSchedule(ctx context.Context, request *workfl
31703172
return err
31713173
}
31723174

3175+
// Search attributes in the Action are already in external ("aliased") form. Do not alias them here.
3176+
31733177
// for all running workflows started by the schedule, we should check that they're
31743178
// still running, and if not, poke the schedule to refresh
31753179
needRefresh := false

tests/advanced_visibility_test.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,11 @@ func (s *advancedVisibilitySuite) isElasticsearchEnabled() bool {
8484

8585
// This cluster use customized threshold for history config
8686
func (s *advancedVisibilitySuite) SetupSuite() {
87-
if TestFlags.PersistenceDriver == mysql.PluginNameV8 ||
88-
TestFlags.PersistenceDriver == postgresql.PluginNameV12 ||
89-
TestFlags.PersistenceDriver == sqlite.PluginName {
87+
switch TestFlags.PersistenceDriver {
88+
case mysql.PluginNameV8, postgresql.PluginNameV12, sqlite.PluginName:
9089
s.setupSuite("testdata/integration_test_cluster.yaml")
9190
s.Logger.Info(fmt.Sprintf("Running advanced visibility test with %s/%s persistence", TestFlags.PersistenceType, TestFlags.PersistenceDriver))
92-
} else {
91+
default:
9392
s.setupSuite("testdata/integration_test_es_cluster.yaml")
9493
s.Logger.Info("Running advanced visibility test with Elasticsearch persistence")
9594
s.esClient = CreateESClient(&s.Suite, s.testClusterConfig.ESConfig, s.Logger)
@@ -1782,9 +1781,9 @@ func (s *advancedVisibilitySuite) TestUpsertWorkflowExecution_InvalidKey() {
17821781
s.Error(err)
17831782
s.IsType(&serviceerror.InvalidArgument{}, err)
17841783
if s.isElasticsearchEnabled() {
1785-
s.Equal("BadSearchAttributes: search attribute INVALIDKEY is not defined", err.Error())
1784+
s.ErrorContains(err, "BadSearchAttributes: search attribute INVALIDKEY is not defined")
17861785
} else {
1787-
s.Equal(fmt.Sprintf("BadSearchAttributes: Namespace %s has no mapping defined for search attribute INVALIDKEY", s.namespace), err.Error())
1786+
s.ErrorContains(err, fmt.Sprintf("BadSearchAttributes: Namespace %s has no mapping defined for search attribute INVALIDKEY", s.namespace))
17881787
}
17891788

17901789
historyResponse, err := s.engine.GetWorkflowExecutionHistory(NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{

tests/namespace_delete_test.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,26 @@ func dynamicConfig() map[dynamicconfig.Key]interface{} {
8383
func (s *namespaceTestSuite) SetupSuite() {
8484
s.logger = log.NewTestLogger()
8585

86-
var clusterConfig *TestClusterConfig
87-
if TestFlags.PersistenceDriver == mysql.PluginNameV8 ||
88-
TestFlags.PersistenceDriver == postgresql.PluginNameV12 ||
89-
TestFlags.PersistenceDriver == sqlite.PluginName {
86+
switch TestFlags.PersistenceDriver {
87+
case mysql.PluginNameV8, postgresql.PluginNameV12, sqlite.PluginName:
9088
var err error
91-
clusterConfig, err = GetTestClusterConfig("testdata/integration_test_cluster.yaml")
89+
s.clusterConfig, err = GetTestClusterConfig("testdata/integration_test_cluster.yaml")
9290
s.Require().NoError(err)
93-
} else {
91+
s.logger.Info(fmt.Sprintf("Running delete namespace tests with %s/%s persistence", TestFlags.PersistenceType, TestFlags.PersistenceDriver))
92+
default:
9493
var err error
95-
clusterConfig, err = GetTestClusterConfig("testdata/integration_test_es_cluster.yaml")
94+
s.clusterConfig, err = GetTestClusterConfig("testdata/integration_test_es_cluster.yaml")
9695
s.Require().NoError(err)
96+
s.logger.Info("Running delete namespace tests with Elasticsearch persistence")
9797
// Elasticsearch is needed to test advanced visibility code path in reclaim resources workflow.
98-
s.esClient = CreateESClient(&s.Suite, clusterConfig.ESConfig, s.logger)
99-
PutIndexTemplate(&s.Suite, s.esClient, fmt.Sprintf("testdata/es_%s_index_template.json", clusterConfig.ESConfig.Version), "test-visibility-template")
100-
CreateIndex(&s.Suite, s.esClient, clusterConfig.ESConfig.GetVisibilityIndex())
98+
s.esClient = CreateESClient(&s.Suite, s.clusterConfig.ESConfig, s.logger)
99+
PutIndexTemplate(&s.Suite, s.esClient, fmt.Sprintf("testdata/es_%s_index_template.json", s.clusterConfig.ESConfig.Version), "test-visibility-template")
100+
CreateIndex(&s.Suite, s.esClient, s.clusterConfig.ESConfig.GetVisibilityIndex())
101101
}
102102

103-
s.clusterConfig = clusterConfig
104-
clusterConfig.DynamicConfigOverrides = dynamicConfig()
103+
s.clusterConfig.DynamicConfigOverrides = dynamicConfig()
105104

106-
cluster, err := NewCluster(clusterConfig, s.logger)
105+
cluster, err := NewCluster(s.clusterConfig, s.logger)
107106
s.Require().NoError(err)
108107
s.cluster = cluster
109108
s.frontendClient = s.cluster.GetFrontendClient()

tests/schedule_test.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,13 @@ func (s *scheduleIntegrationSuite) SetupSuite() {
9696
if TestFlags.FrontendAddr != "" {
9797
s.hostPort = TestFlags.FrontendAddr
9898
}
99-
if TestFlags.PersistenceDriver == mysql.PluginNameV8 ||
100-
TestFlags.PersistenceDriver == postgresql.PluginNameV12 ||
101-
TestFlags.PersistenceDriver == sqlite.PluginName {
99+
switch TestFlags.PersistenceDriver {
100+
case mysql.PluginNameV8, postgresql.PluginNameV12, sqlite.PluginName:
102101
s.setupSuite("testdata/integration_test_cluster.yaml")
103-
} else {
102+
s.Logger.Info(fmt.Sprintf("Running schedule tests with %s/%s persistence", TestFlags.PersistenceType, TestFlags.PersistenceDriver))
103+
default:
104104
s.setupSuite("testdata/integration_test_es_cluster.yaml")
105+
s.Logger.Info("Running schedule tests with Elasticsearch persistence")
105106
s.esClient = CreateESClient(&s.Suite, s.testClusterConfig.ESConfig, s.Logger)
106107
PutIndexTemplate(&s.Suite, s.esClient, fmt.Sprintf("testdata/es_%s_index_template.json", s.testClusterConfig.ESConfig.Version), "test-visibility-template")
107108
CreateIndex(&s.Suite, s.esClient, s.testClusterConfig.ESConfig.GetVisibilityIndex())

tests/xdc/advanced_visibility_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ func (s *advVisCrossDCTestSuite) isElasticsearchEnabled() bool {
102102
func (s *advVisCrossDCTestSuite) SetupSuite() {
103103
s.logger = log.NewTestLogger()
104104
var fileName string
105-
isElasticsearchEnabled := false
106-
if tests.TestFlags.PersistenceDriver == mysql.PluginNameV8 ||
107-
tests.TestFlags.PersistenceDriver == postgresql.PluginNameV12 ||
108-
tests.TestFlags.PersistenceDriver == sqlite.PluginName {
105+
var isElasticsearchEnabled bool
106+
switch tests.TestFlags.PersistenceDriver {
107+
case mysql.PluginNameV8, postgresql.PluginNameV12, sqlite.PluginName:
109108
// NOTE: can't use xdc_integration_test_clusters.yaml here because it somehow interferes with the other xDC tests.
110109
fileName = "../testdata/xdc_integration_adv_vis_clusters.yaml"
110+
isElasticsearchEnabled = false
111111
s.logger.Info(fmt.Sprintf("Running xDC advanced visibility test with %s/%s persistence", tests.TestFlags.PersistenceType, tests.TestFlags.PersistenceDriver))
112-
} else {
112+
default:
113113
fileName = "../testdata/xdc_integration_adv_vis_es_clusters.yaml"
114114
isElasticsearchEnabled = true
115115
s.logger.Info("Running xDC advanced visibility test with Elasticsearch persistence")

0 commit comments

Comments
 (0)