Skip to content
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

Merged
merged 3 commits into from
Feb 10, 2023

Conversation

alexshtin
Copy link
Member

@alexshtin alexshtin commented Feb 9, 2023

What changed?

  • Enable Elasticsearch functional tests for SQL advanced visibility. With this PR Buildkite runs advanced visibility tests (former Elasticsearch tests) for mysql8, postrges12, and sqlite SQL drivers. Containers which use these drivers doesn't depended on Elasticsearch anymore.
  • For other drivers it runs same tests using Elasticsearch.
  • 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.

@alexshtin alexshtin force-pushed the feature/adv-sql-tests branch 4 times, most recently from 15004aa to 270142f Compare February 10, 2023 00:27
s.Require().NoError(err)
} else {
var err error
clusterConfig, err = GetTestClusterConfig("testdata/integration_namespace_cluster.yaml")
Copy link
Member

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?

Copy link
Member Author

@alexshtin alexshtin Feb 10, 2023

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),
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Contributor

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.

@alexshtin alexshtin force-pushed the feature/adv-sql-tests branch from 270142f to 9ff9885 Compare February 10, 2023 06:24
@alexshtin alexshtin marked this pull request as ready for review February 10, 2023 08:15
@alexshtin alexshtin requested a review from a team as a code owner February 10, 2023 08:15
@@ -82,3 +82,9 @@ linters-settings:
- name: unhandled-error
arguments:
- "fmt.Printf"
issues:
exclude-rules:
- path: tests\/.+\.go
Copy link
Contributor

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?

Copy link
Member Author

@alexshtin alexshtin Feb 10, 2023

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 ^.

Comment on lines +281 to +284
@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
Copy link
Contributor

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.

Copy link
Member Author

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.

Comment on lines +87 to +89
if TestFlags.PersistenceDriver == mysql.PluginNameV8 ||
TestFlags.PersistenceDriver == postgresql.PluginNameV12 ||
TestFlags.PersistenceDriver == sqlite.PluginName {
Copy link
Contributor

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?

Copy link
Member Author

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.

Comment on lines +90 to +92
var err error
clusterConfig, err = GetTestClusterConfig("testdata/integration_test_cluster.yaml")
s.Require().NoError(err)
Copy link
Contributor

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?

Copy link
Member Author

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.

Comment on lines +195 to +214
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)
}

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member

@dnr dnr left a 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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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")

Copy link
Member Author

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
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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),
Copy link
Member

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

@yiminc yiminc merged commit 74bfaff into temporalio:master Feb 10, 2023
@alexshtin alexshtin deleted the feature/adv-sql-tests branch February 10, 2023 21:26
alexshtin added a commit to alexshtin/temporal that referenced this pull request Feb 10, 2023
alexshtin added a commit to alexshtin/temporal that referenced this pull request Feb 10, 2023
alexshtin added a commit to alexshtin/temporal that referenced this pull request Feb 11, 2023
alexshtin added a commit that referenced this pull request Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants