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

[code-coverage] update admin and frontend client to use generated code #5702

Merged

Conversation

ketsiambaku
Copy link
Member

@ketsiambaku ketsiambaku commented Mar 2, 2024

What changed?
In this PR admin & frontend client wrapper is generated using gowrap
history was generated in a previous PR #5728 however, I am adding to/modifiing the template so it can generate code for the other decorators as well.
Will have an follow up PR for matching client because of the multiple special cases :)

Why?
To improve code coverage
To reduce manual work when new methods are added in the future

How did you test it?
unit tests

Potential risks

Release notes

Documentation Changes

@@ -34,6 +34,7 @@ import (
//go:generate gowrap gen -g -p . -i Client -t ../templates/errorinjectors.tmpl -o ../wrappers/errorinjectors/admin_generated.go -v client=Admin
//go:generate gowrap gen -g -p . -i Client -t ../templates/grpc.tmpl -o ../wrappers/grpc/admin_generated.go -v client=Admin -v package=adminv1 -v path=github.com/uber/cadence-idl/go/proto/admin/v1 -v prefix=Admin
//go:generate gowrap gen -g -p . -i Client -t ../templates/thrift.tmpl -o ../wrappers/thrift/admin_generated.go -v client=Admin -v prefix=Admin
//go:generate gowrap gen -g -p . -i Client -t ../templates/tchannel.tmpl -o ../wrappers/tchannel/admin_generated.go -v client=Admin
Copy link
Member

Choose a reason for hiding this comment

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

Could you elaborate on why it is tchannel? :)
As far as I understand, it is an abstraction around thrift or grpc clients.
Not sure what would be the best name here.
timed? timed_out?

Copy link
Member Author

@ketsiambaku ketsiambaku Mar 4, 2024

Choose a reason for hiding this comment

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

The naming was based off of this comment under the constructors. However this is old code maybe previously used as a tchannel wrapper and was refactored later. I like timed better

Copy link
Member

Choose a reason for hiding this comment

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

As far as I see @shijiesheng called it timeout wrapper in #5728
Lets rename it to timeout then.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@ketsiambaku ketsiambaku changed the title [code-coverage] update admin client to use generated code [code-coverage] update admin and frontend client to use generated code Mar 4, 2024
@coveralls
Copy link

coveralls commented Mar 4, 2024

Pull Request Test Coverage Report for Build 018e1d74-4044-43d0-a74b-6220b624b802

Details

  • 14 of 14 (100.0%) changed or added relevant lines in 3 files are covered.
  • 76 unchanged lines in 14 files lost coverage.
  • Overall coverage increased (+0.2%) to 63.627%

Files with Coverage Reduction New Missed Lines %
common/task/weighted_round_robin_task_scheduler.go 2 89.05%
common/task/parallel_task_processor.go 2 93.06%
service/history/task/transfer_active_task_executor.go 2 72.38%
service/matching/taskListManager.go 2 80.96%
common/persistence/statsComputer.go 2 95.71%
common/util.go 2 91.69%
common/persistence/executionManager.go 2 78.59%
service/history/execution/mutable_state_util.go 2 78.48%
common/persistence/nosql/nosqlplugin/cassandra/workflow.go 3 71.88%
service/history/shard/context.go 9 66.84%
Totals Coverage Status
Change from base Build 018e1bb3-a46f-4e6f-90af-e244a5deb9e0: 0.2%
Covered Lines: 92975
Relevant Lines: 146125

💛 - Coveralls

ctx, cancel := c.createContext({{(index $method.Params 0).Name}})
{{- end -}}
{{- else if eq $ClientName "Frontend" -}}
{{- if or (eq $method.Name "ListArchivedWorkflowExecutions")
Copy link
Member

Choose a reason for hiding this comment

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

It is hard to read/add more stuff into if cases.
@Zijian-Uber Introduced a nice way to form exceptions/special handing with template list, see https://github.com/uber/cadence/blob/master/service/frontend/templates/clusterredirection.tmpl#L17

Then you can simplify the condition significantly:
https://github.com/uber/cadence/blob/master/service/frontend/templates/clusterredirection.tmpl#L62

@ketsiambaku ketsiambaku marked this pull request as draft March 6, 2024 21:44
@ketsiambaku ketsiambaku marked this pull request as ready for review March 7, 2024 19:36
Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Merging #5702 (deb140c) into master (ee74964) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
Files Coverage Δ
client/wrappers/timeout/timeout.go 100.00% <100.00%> (ø)

... and 4 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 ee74964...deb140c. Read the comment docs.

Comment on lines -2 to +26
"context"
"time"
"context"
"time"
Copy link
Member

@Groxx Groxx Mar 7, 2024

Choose a reason for hiding this comment

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

it's relatively minor but: see if you can switch your IDE to use tabs instead of spaces in *.tmpl files? fewer changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Noted

FrontendDefaultLongPollTimeout = time.Minute * 3
)

func createContext(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Since all client decorators are using the same logic to create context, I removed this from the template and into a function that they can all share

Copy link
Member

@3vilhamster 3vilhamster left a comment

Choose a reason for hiding this comment

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

Looks nice :)

@ketsiambaku ketsiambaku merged commit da4cbf2 into cadence-workflow:master Mar 8, 2024
20 checks passed
@ketsiambaku ketsiambaku deleted the gowrap-client-frontend branch April 14, 2024 18:18
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.

4 participants