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

Add unit tests for methods in frontend API handler #6119

Merged
merged 15 commits into from
Jun 6, 2024

Conversation

timl3136
Copy link
Member

@timl3136 timl3136 commented Jun 5, 2024

What changed?
Add unit tests for RespondDecisionTaskCompleted in frontend api handler

Why?
Improve test coverage

How did you test it?
Unit tests

Potential risks

Release notes

Documentation Changes

s.mockDomainCache.EXPECT().GetDomainName(s.testDomainID).Return(s.testDomain, nil)
wh.config.DecisionResultCountLimit = dc.GetIntPropertyFilteredByDomain(10)
},
expectError: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we assert error message? You can change through expectError string and assert.ErrorContains()

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for your comment, I have made the change.

Copy link

codecov bot commented Jun 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.17%. Comparing base (aad09de) to head (d85f496).
Report is 1 commits behind head on master.

Current head d85f496 differs from pull request most recent head 4c0d1da

Please upload reports for the commit 4c0d1da to get more accurate results.

Additional details and impacted files

see 13 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 aad09de...4c0d1da. Read the comment docs.

@coveralls
Copy link

coveralls commented Jun 5, 2024

Pull Request Test Coverage Report for Build 018feab2-d9fc-47c6-b1ec-38eeb350d343

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 545 unchanged lines in 15 files lost coverage.
  • Overall coverage decreased (-0.3%) to 70.847%

Files with Coverage Reduction New Missed Lines %
service/history/queue/timer_queue_processor_base.go 1 77.66%
common/task/weighted_round_robin_task_scheduler.go 2 88.56%
service/frontend/api/handler.go 2 69.31%
service/history/task/transfer_active_task_executor.go 2 72.77%
common/task/fifo_task_scheduler.go 3 84.54%
common/persistence/statsComputer.go 3 98.21%
service/history/task/fetcher.go 3 86.6%
common/archiver/filestore/historyArchiver.go 4 80.95%
common/types/mapper/thrift/shared.go 4 98.31%
service/history/task/transfer_standby_task_executor.go 6 86.33%
Totals Coverage Status
Change from base Build 018feaa3-8a65-4c9c-874c-0243b9141bed: -0.3%
Covered Lines: 105521
Relevant Lines: 148942

💛 - Coveralls

timl3136 and others added 13 commits June 6, 2024 09:06
**What changed?**
Excluded `domains` that have `preferredClusters` that are not present in its `cluster` list in `ReplicationConfiguration`

**Why?**
`Domains` with `preferredClusters` not in their `cluster` list were causing the `workflow` to panic when trying to acquire the `client` for the `preferredCluster` from the `remoteFrontendClients`

**How did you test it?**
unit tests and local replication tests

**Potential risks**
The `workflow` was generally not working before because having a `preferredCluster` not in the `domain` `cluster` list is a normal scenario. The risk introduced is the `workflow` actually executing and doing something unexpected. For now, we just rebalance `domains` that have `preferredCluster` set and that can be rebalanced back to their `preferredCluster`

**Release notes**

**Documentation Changes**
Apparently that was being searched, and it noticed a "thing.go" folder that git made!
So now this has two improvements:
1. it does not step into the `.git` folder, because obviously there is no source that needs formatting in there
2. it only finds files, `-type f`, because directories aren't source files

Both pretty obviously good to have in retrospect.

---

A way to validate this kind of change for the future:
1. change the `SHELL = ...` line near the top of the makefile to include a `-x` debug flag.
   `make` will now print all the shell commands it runs, including this `find`.
2. copy it and run it by hand and check the output.
   in particular, this time I just had it find _all_ files to check where it looked, and made sure the list was reasonable
   (it included my local .idea, but that seems fine, it's small and has no go files)

I should've done 2 earlier when I added this `find` command, I likely would have noticed the directories and `.git` and removed them.  Sorry about that.
…#6062)

* Add tests for mutable_state_util_test.go

* added mutablestate assertions
Also renamed variable as `r` looks too short and stands more for reader
or ref rather than response/result.
@timl3136 timl3136 enabled auto-merge (squash) June 6, 2024 18:27
@timl3136 timl3136 merged commit b3e21fa into cadence-workflow:master Jun 6, 2024
18 checks passed
@coveralls
Copy link

coveralls commented Jun 6, 2024

Pull Request Test Coverage Report for Build 018feecd-c54b-4228-8334-8ea702900f98

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 49 unchanged lines in 8 files lost coverage.
  • Overall coverage decreased (-0.008%) to 71.292%

Files with Coverage Reduction New Missed Lines %
common/persistence/sql/sqlplugin/postgres/task.go 2 73.4%
common/util.go 2 91.84%
service/history/task/transfer_standby_task_executor.go 3 86.33%
service/history/task/task.go 3 84.81%
common/task/fifo_task_scheduler.go 4 82.47%
service/history/execution/cache.go 6 74.61%
common/persistence/sql/sqlplugin/postgres/db.go 9 65.0%
service/history/task/task_util.go 20 70.57%
Totals Coverage Status
Change from base Build 018fee53-2f0a-42d7-9d39-e20b5cb03809: -0.008%
Covered Lines: 106194
Relevant Lines: 148957

💛 - Coveralls

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.

10 participants