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 high-coupling method into functions in applyEvent for a more testability #6089

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

bowenxia
Copy link
Contributor

@bowenxia bowenxia commented Jun 3, 2024

What changed?
Refactored methods in applyEvent to be functions, and make them as historyReplicator parameters

Why?
Easier to do unit test

How did you test it?

Potential risks

Release notes

Documentation Changes

@bowenxia bowenxia changed the title Refactor high-coupling functions in applyEvent for a more testability Refactor high-coupling method into functions in applyEvent for a more testability Jun 3, 2024
Copy link

codecov bot commented Jun 3, 2024

Codecov Report

Attention: Patch coverage is 2.32558% with 42 lines in your changes missing coverage. Please review.

Project coverage is 68.52%. Comparing base (f0f7efd) to head (f092d74).
Report is 6 commits behind head on master.

Additional details and impacted files
Files Coverage Δ
service/history/ndc/history_replicator.go 16.87% <2.32%> (-0.26%) ⬇️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f0f7efd...f092d74. Read the comment docs.

newStateBuilder stateBuilderProvider
newMutableState mutableStateProvider
newReplicationTaskFn newReplicationTaskFn
newBranchManager branchManagerProvider
Copy link
Member

Choose a reason for hiding this comment

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

Can you add Fn suffix to these function parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do.

}
return r.applyNonStartEventsToNoneCurrentBranch(ctx, context, mutableState, branchIndex, releaseFn, task)
// passed in r because there's a recursive call within applyNonStartEventsToNoneCurrentBranchWithContinueAsNew
return r.applyNonStartEventsToNoneCurrentBranchFn(ctx, context, mutableState, branchIndex, releaseFn, task, r)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if I could do this here. It is actually a recursive call. If I change this applyEvents method to be a function, there would be too many things to be passed in into this function.

newStateBuilder stateBuilderProvider
newMutableState mutableStateProvider
newReplicationTaskFn newReplicationTaskFn
newBranchManager branchManagerProvider
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 018fe0a0-cddd-4e8a-9e06-8a5a8650a29c

Details

  • 43 of 43 (100.0%) changed or added relevant lines in 1 file are covered.
  • 171 unchanged lines in 13 files lost coverage.
  • Overall coverage decreased (-0.1%) to 69.685%

Files with Coverage Reduction New Missed Lines %
common/task/weighted_round_robin_task_scheduler.go 1 89.05%
service/history/task/transfer_standby_task_executor.go 2 87.14%
common/persistence/sql/sqlplugin/mysql/task.go 2 73.68%
service/frontend/api/handler.go 2 62.56%
service/history/task/transfer_active_task_executor.go 2 72.79%
common/util.go 2 91.78%
common/persistence/sql/sqlplugin/mysql/db.go 2 79.49%
common/task/fifo_task_scheduler.go 3 84.54%
common/archiver/filestore/historyArchiver.go 4 80.95%
service/matching/tasklist/task_list_manager.go 4 76.09%
Totals Coverage Status
Change from base Build 018fe051-df14-4702-b515-0388c6db07f3: -0.1%
Covered Lines: 103093
Relevant Lines: 147942

💛 - Coveralls

@bowenxia bowenxia merged commit 15000f0 into master Jun 4, 2024
21 checks passed
@bowenxia bowenxia deleted the xbowen_history_replicator_test02 branch June 4, 2024 01:20
timl3136 pushed a commit to timl3136/cadence that referenced this pull request Jun 6, 2024
… testability (cadence-workflow#6089)

* refactor coupled functions for a more testability

* renaming old functions
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