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] Add tests for mutable_state_util.go #6062

Merged
merged 2 commits into from
Jun 6, 2024

Conversation

ketsiambaku
Copy link
Member

What changed?
Added tests to improve code coverage in service/history/execution/mutable_state_util_test.go

Why?
Code Coverage Initiative 📈

How did you test it?

Potential risks

Release notes

Documentation Changes

@ketsiambaku ketsiambaku changed the title Add tests for mutable_state_util_test.go [code-coverage] Add tests for mutable_state_util_test.go May 26, 2024
@ketsiambaku ketsiambaku marked this pull request as ready for review May 26, 2024 22:58
@ketsiambaku ketsiambaku changed the title [code-coverage] Add tests for mutable_state_util_test.go [code-coverage] Add tests for mutable_state_util.go May 26, 2024
Copy link

codecov bot commented May 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.10%. Comparing base (c6a145d) to head (d96623b).

Current head d96623b differs from pull request most recent head bb0c768

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

Additional details and impacted files

see 40 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 c6a145d...bb0c768. Read the comment docs.

@coveralls
Copy link

coveralls commented May 26, 2024

Pull Request Test Coverage Report for Build 018fdb1f-40a9-4f14-ab60-448573a7c3cf

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 55 unchanged lines in 11 files lost coverage.
  • Overall coverage increased (+0.03%) to 69.714%

Files with Coverage Reduction New Missed Lines %
common/task/weighted_round_robin_task_scheduler.go 2 89.05%
service/history/replication/task_processor.go 2 81.25%
service/matching/tasklist/matcher.go 2 89.35%
common/persistence/nosql/nosql_task_store.go 3 85.52%
service/matching/tasklist/task_list_manager.go 3 75.49%
common/archiver/filestore/historyArchiver.go 4 80.95%
common/task/fifo_task_scheduler.go 4 83.51%
service/frontend/api/handler.go 6 62.45%
service/history/task/transfer_standby_task_executor.go 7 85.92%
service/history/engine/engineimpl/poll_mutable_state.go 9 74.16%
Totals Coverage Status
Change from base Build 018fd17e-a401-4eba-8372-591d1e581574: 0.03%
Covered Lines: 103128
Relevant Lines: 147930

💛 - Coveralls

expected := testdata.DomainName
mockDomainCache.EXPECT().GetDomainName(childInfo.DomainID).Return(expected, nil)
name, err := GetChildExecutionDomainName(childInfo, mockDomainCache, constants.TestLocalDomainEntry)
assert.Nil(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

assert.NoError() is a better candidate for error-checking.
Also, I recommend using require in this case since most probably you're not interested in checking for value if err != nil; in fact, in lots of cases it will even panic.

Copy link
Member Author

Choose a reason for hiding this comment

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

changed

service/history/execution/mutable_state_util_test.go Outdated Show resolved Hide resolved
service/history/execution/mutable_state_util_test.go Outdated Show resolved Hide resolved
builder.decisionTaskManager.(*mutableStateDecisionTaskManagerImpl).HasInFlightDecision()
builder.executionInfo.DecisionStartedID = 1

mutableState := CreatePersistenceMutableState(builder)
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 a mapper, taking a type (mutableStateBuilder) and creating a persistence Mutable State. Is it possible to see if there's the reverse somewhere?

This kind of code is quite prone to not getting updated, I feel fairly strongly that we should round-trip test these mappings rather than just unit-testing them. Happy to sync to discuss what I mean.

See TestMutableStateBuilder_CopyToPersistence_roundtrip for an example of a roundtrip test.

Copy link
Member

Choose a reason for hiding this comment

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

the msb.CopyToPersistance() method I was testing looks weirdly similar, but I think they're different. Not super clear, but I think this one is a deep copy, so modifications to the copied persistence struct shouldn't affect the original maybe? not super sure how rigorous that is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I can add the roundtrip test on a follow up PR. I'm looking into the example.

@ketsiambaku ketsiambaku enabled auto-merge (squash) June 6, 2024 07:39
@ketsiambaku ketsiambaku merged commit b9018bf into cadence-workflow:master Jun 6, 2024
18 checks passed
timl3136 pushed a commit to timl3136/cadence that referenced this pull request Jun 6, 2024
…#6062)

* Add tests for mutable_state_util_test.go

* added mutablestate assertions
timl3136 pushed a commit to timl3136/cadence that referenced this pull request Jun 6, 2024
…#6062)

* Add tests for mutable_state_util_test.go

* added mutablestate assertions
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