-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Elasticsearch functional tests for SQL advanced visibility #3923
Conversation
15004aa
to
270142f
Compare
tests/namespace_delete_test.go
Outdated
s.Require().NoError(err) | ||
} else { | ||
var err error | ||
clusterConfig, err = GetTestClusterConfig("testdata/integration_namespace_cluster.yaml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
integration_namespace_cluster
is a weird name and I have no idea what it means. is there a more descriptive one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I cleaned it up. Removed scheduler specific configs too.
saListRequest = &workflowservice.ListWorkflowExecutionsRequest{ | ||
Namespace: namespace, | ||
PageSize: int32(2), | ||
Query: fmt.Sprintf(`WorkflowId = "%s" and %s = "another string"`, id, s.testSearchAttributeKey), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have a programmatic query builder yet, or can we factor one out of the new visibility? code like this is kind of scary, even though it's in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with it? It is functional test. It supposed to emulate user input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine, but there are a few instances in non-test code now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's on me. I'll work on making those parts better.
270142f
to
9ff9885
Compare
@@ -82,3 +82,9 @@ linters-settings: | |||
- name: unhandled-error | |||
arguments: | |||
- "fmt.Printf" | |||
issues: | |||
exclude-rules: | |||
- path: tests\/.+\.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will capture tests with tests
somewhere in the path, but it won't capture the vast majority of _test.go unit tests that we have. Is that intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want this to get applied to functional tests in tests
dir only. But you are right, it will capture others too. I need to add prefix it with ^
.
@go test $(FUNCTIONAL_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) | tee -a test.log | ||
@go test $(FUNCTIONAL_TEST_NDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) | tee -a test.log | ||
# Need to run xdc tests with race detector off because of ringpop bug causing data race issue. | ||
@go test $(FUNCTIONAL_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log | ||
@go test $(FUNCTIONAL_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) | tee -a test.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we should have a args
var to encapsulate all the common arguments instead of duplicating it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove these args completely and just use envs to generate configs and then use these configs for test clusters.
if TestFlags.PersistenceDriver == mysql.PluginNameV8 || | ||
TestFlags.PersistenceDriver == postgresql.PluginNameV12 || | ||
TestFlags.PersistenceDriver == sqlite.PluginName { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't switch/case
easier to read?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and in all other places we use switch
for these constants also.
var err error | ||
clusterConfig, err = GetTestClusterConfig("testdata/integration_test_cluster.yaml") | ||
s.Require().NoError(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to setup the database? Or is it setup somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, both DBs are already setup here. ES index also should be created earlier. This needs to be refactored.
if !s.isElasticsearchEnabled() { | ||
// When Elasticsearch is enabled, the search attribute aliases are not used. | ||
_, err = client1.UpdateNamespace(tests.NewContext(), &workflowservice.UpdateNamespaceRequest{ | ||
Namespace: namespace, | ||
Config: &namespacepb.NamespaceConfig{ | ||
CustomSearchAttributeAliases: map[string]string{ | ||
"Bool01": "CustomBoolField", | ||
"Datetime01": "CustomDatetimeField", | ||
"Double01": "CustomDoubleField", | ||
"Int01": "CustomIntField", | ||
"Keyword01": "CustomKeywordField", | ||
"Text01": "CustomTextField", | ||
}, | ||
}, | ||
}) | ||
s.NoError(err) | ||
// Wait for namespace cache to pick the UpdateNamespace changes. | ||
time.Sleep(cacheRefreshInterval) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not move this to SetupSuite
where it adds the search attributes to ES?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently it tests namespace creation in the test. Probably it should be moved out. One day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all makes sense to me. Thanks for cleaning it up!
@@ -1737,7 +1781,11 @@ func (s *elasticsearchIntegrationSuite) TestUpsertWorkflowExecution_InvalidKey() | |||
_, err := poller.PollAndProcessWorkflowTask(false, false) | |||
s.Error(err) | |||
s.IsType(&serviceerror.InvalidArgument{}, err) | |||
s.Equal("BadSearchAttributes: search attribute INVALIDKEY is not defined", err.Error()) | |||
if s.isElasticsearchEnabled() { | |||
s.Equal("BadSearchAttributes: search attribute INVALIDKEY is not defined", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s.Equal("BadSearchAttributes: search attribute INVALIDKEY is not defined", err.Error()) | |
s.ErrorContains(err, "BadSearchAttributes: search attribute INVALIDKEY is not defined") |
if s.isElasticsearchEnabled() { | ||
s.Equal("BadSearchAttributes: search attribute INVALIDKEY is not defined", err.Error()) | ||
} else { | ||
s.Equal(fmt.Sprintf("BadSearchAttributes: Namespace %s has no mapping defined for search attribute INVALIDKEY", s.namespace), err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s.Equal(fmt.Sprintf("BadSearchAttributes: Namespace %s has no mapping defined for search attribute INVALIDKEY", s.namespace), err.Error()) | |
s.ErrorContains(err, "has no mapping defined for search attribute INVALIDKEY") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave namespace there.
@@ -4,5 +4,6 @@ historyconfig: | |||
numhistoryshards: 4 | |||
numhistoryhosts: 1 | |||
workerconfig: | |||
startworkeranyway: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm tempted to get rid of this setting and always start a worker, I mean, why not? but you don't have to do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are so many things that I'm tempted to get rid of :-). Agree, this needs to be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but I added this one and feel bad about it
saListRequest = &workflowservice.ListWorkflowExecutionsRequest{ | ||
Namespace: namespace, | ||
PageSize: int32(2), | ||
Query: fmt.Sprintf(`WorkflowId = "%s" and %s = "another string"`, id, s.testSearchAttributeKey), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine, but there are a few instances in non-test code now
What changed?
mysql8
,postrges12
, andsqlite
SQL drivers. Containers which use these drivers doesn't depended on Elasticsearch anymore.esintegration
build tag is removed.Why?
To cover SQL advanced visibility with existing tests.
How did you test it?
Run them.
Potential risks
No risks.
Is hotfix candidate?
No.