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

Refactor Cassandra test utility for NoSQL support #4311

Merged
merged 34 commits into from
Jul 21, 2021

Conversation

longquanzheng
Copy link
Contributor

@longquanzheng longquanzheng commented Jul 10, 2021

What changed?

  1. Create NoSQL interface for testing
  2. Extract the logic of Cassandra to implement the interface
  3. Remove unused code

Why?
For #3514
So that other NoSQL can run persistence test easily.

Once this is merged, we can start working on NoSQL support.
Though we still need two refactoring: 1) Refactoring schema tool to support NoSQL 2) Refactoring integ test to support NoSQL.

How did you test it?
existing tests.

Potential risks
Low risks. The refactoring is only for testing support for NoSQL

Release notes
No

Documentation Changes
No

@coveralls
Copy link

coveralls commented Jul 11, 2021

Pull Request Test Coverage Report for Build 40170d4a-e7d4-4658-b87f-510ada8cde5b

  • 182 of 272 (66.91%) changed or added relevant lines in 24 files are covered.
  • 53 unchanged lines in 9 files lost coverage.
  • Overall coverage increased (+0.04%) to 56.726%

Changes Missing Coverage Covered Lines Changed/Added Lines %
common/persistence/sql/sqlPersistenceTest.go 14 15 93.33%
tools/cassandra/handler.go 0 1 0.0%
common/persistence/nosql/nosqlplugin/cassandra/plugin.go 39 41 95.12%
common/persistence/nosql/nosqlplugin/types.go 3 5 60.0%
common/persistence/persistence-tests/persistenceTestBase.go 0 3 0.0%
common/persistence/nosql/nosqlplugin/cassandra/gocql/public/testBase.go 0 4 0.0%
tools/cli/adminDBScanCommand.go 0 6 0.0%
common/persistence/nosql/nosqlPersistenceTest.go 40 48 83.33%
common/persistence/nosql/nosqlplugin/cassandra/admin.go 36 53 67.92%
common/persistence/nosql/plugin.go 13 32 40.63%
Files with Coverage Reduction New Missed Lines %
common/task/weightedRoundRobinTaskScheduler.go 1 89.64%
common/task/fifoTaskScheduler.go 2 82.47%
tools/cli/adminDBScanCommand.go 2 0%
common/persistence/nosql/nosqlplugin/cassandra/workflow.go 3 50.23%
service/history/queue/timer_gate.go 3 95.83%
service/history/task/transfer_active_task_executor.go 4 69.73%
common/persistence/nosql/nosqlplugin/cassandra/workflowUtils.go 8 78.09%
common/persistence/nosql/nosqlplugin/cassandra/workflowParsingUtils.go 14 88.1%
common/persistence/sql/sqlExecutionStore.go 16 59.54%
Totals Coverage Status
Change from base Build 4362f1b4-15a1-4779-bb50-d505e78a289c: 0.04%
Covered Lines: 77586
Relevant Lines: 136773

💛 - Coveralls

@longquanzheng longquanzheng changed the title Refactor Cassandra test utility for NoSQL support Refactor Cassandra test/tool utility for NoSQL support Jul 11, 2021
@longquanzheng longquanzheng changed the title Refactor Cassandra test/tool utility for NoSQL support Refactor Cassandra test utility for NoSQL support Jul 12, 2021
@longquanzheng longquanzheng marked this pull request as ready for review July 12, 2021 01:24
@github-actions github-actions bot force-pushed the qlong-nosql-admin branch 2 times, most recently from dd166d6 to 5b3e1ed Compare July 19, 2021 22:20
Copy link
Contributor

@yycptt yycptt left a comment

Choose a reason for hiding this comment

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

LGTM overall. I guess the change won't break our internal repo except for the naming change in TestBaseOptions struct? @Shaddoll


var supportedPlugins = map[string]nosqlplugin.Plugin{}

// RegisterPlugin will register a SQL plugin
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: NoSQL plugin. Three more in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, 4 more actually :D thanks for the catch.

@@ -0,0 +1,86 @@
// Copyright (c) 2021 Uber Technologies, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: store.go sounds a bit confusing. Maybe plugin.go or registry.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to plugin.go ,and also rename the one in sql/ for consistency.

// NewClient gets a gocql client based registered object
func NewClient() Client {
// GetOrCreateClient gets a gocql client based registered object
func GetOrCreateClient() Client {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: since it only returned registered client, maybe just GetClient()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point. I changed to GetRegisteredClient if you don't mind.

@@ -72,7 +71,7 @@ func verifyCompatibleVersion(
return nil
}

if ds.NoSQL.PluginName != cassandra_db.PluginName {
Copy link
Contributor

Choose a reason for hiding this comment

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

reusing the defined constant will be better than hardcoding I think? Anything I am missing here?

Copy link
Contributor Author

@longquanzheng longquanzheng Jul 21, 2021

Choose a reason for hiding this comment

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

It's causing another cycle dependency. And since this file will be refactored soon to support NoSQL tools(after the refactor the cycle dep should be gone) so I don't want to spend time on fixing the dependency just for this constant here. I will leave a comment to explain why I don't use the constant.

tmpl := "select domain from domains where id = ? "
query := session.Query(tmpl, domainID)
res, err := readOneRow(query)
domain, err := db.SelectDomain(ctx.Background(), &domainID, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: ctx.Background() -> newContext(c)?

// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package testcluster
Copy link
Contributor

Choose a reason for hiding this comment

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

if it's for avoiding cycle dependency would you mind add some comments describing the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah added

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.

3 participants