Skip to content

Add tests for stateManagerCtx#558

Open
KentHsu wants to merge 17 commits into
dapr:mainfrom
KentHsu:add-tests-for-stateManagerCtx
Open

Add tests for stateManagerCtx#558
KentHsu wants to merge 17 commits into
dapr:mainfrom
KentHsu:add-tests-for-stateManagerCtx

Conversation

@KentHsu

@KentHsu KentHsu commented May 1, 2024

Copy link
Copy Markdown

Description

This PR add tests for stateManagerCtx
mockgen a mock_client file so stateManagerCtx can run tests with this mock client
Added tests for methods in stateManagerCtx and fixed a bug in setWithTTL method

Issue reference

Please reference the issue this PR will close: #446

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

KentHsu added 3 commits May 1, 2024 21:34
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
@KentHsu KentHsu requested review from a team as code owners May 1, 2024 13:43
@codecov

codecov Bot commented May 1, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 6.20690% with 544 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.44%. Comparing base (27248ba) to head (4b0276c).
⚠️ Report is 139 commits behind head on main.

Files with missing lines Patch % Lines
actor/mock_client/mock_client.go 4.28% 514 Missing ⚠️
actor/mock/mock_server.go 11.53% 23 Missing ⚠️
actor/mock/mock_manager.go 50.00% 5 Missing ⚠️
actor/mock/mock_container.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #558      +/-   ##
==========================================
+ Coverage   58.04%   58.44%   +0.40%     
==========================================
  Files          55       57       +2     
  Lines        3568     3973     +405     
==========================================
+ Hits         2071     2322     +251     
- Misses       1375     1518     +143     
- Partials      122      133      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
@mikeee mikeee added this to the v1.11 milestone May 2, 2024

@mikeee mikeee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great stuff, just a few initial comments from my first look.

  • Would you be able to include tests for the deprecated statemanager methods until they're removed?
  • Should the makefile be updated to include a new target that can generate mockfiles using the same flags and which mockgen version/fork you're using e.g. https://github.com/uber-go/mock and a corresponding version

A side note is that I believe we should exclude generated mocks from codecov scans - possibly in a separate PR.

KentHsu added 6 commits May 3, 2024 00:27
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
This reverts commit 9481caf.

Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
@KentHsu

KentHsu commented May 3, 2024

Copy link
Copy Markdown
Author

Thank you for the feedback. I have updated this PR with

  • Added tests for stateManager methods. These tests are duplicates of stateManagerCtx tests.
  • Added a new target in Makefile to generate mocks and updated mocks. I'm using golang mock because this is how those mock were generated. mock_factory_impl.go is not created by mockgen so it's not in the Makefile. mock_server.go is updated but I didn't put it in the Makefile because it was manually edited.
  • Put mocks in .codecov.yaml ignore. Let me know if this is okay. I'll revert it if it's inappropriate.

@mikeee

mikeee commented May 5, 2024

Copy link
Copy Markdown
Member

Just had another skim-read, looking great so far. I haven't forgotten and will pick the review up tomorrow when I get a moment 👌

@KentHsu

KentHsu commented May 5, 2024

Copy link
Copy Markdown
Author

Sure. Please take your time 👍
BTW, I realize that I do need another PR to update .codecov.yaml... I'll submit another PR to update it when this one is ready.

@mikeee

mikeee commented May 6, 2024

Copy link
Copy Markdown
Member

Is there any reason against using Uber's maintained fork to generate mock interfaces?

@KentHsu

KentHsu commented May 6, 2024

Copy link
Copy Markdown
Author

I tried both and I didn't see anything blocking us from using Uber's fork.
If we want to switch to Uber's fork, I'll have to update go.mod and other test files using these mocks since Uber's fork doesn't work with those original mocks. Is that okay?

KentHsu added 2 commits May 7, 2024 00:08
This reverts commit be6e8ce.

Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
@KentHsu

KentHsu commented May 6, 2024

Copy link
Copy Markdown
Author

I went ahead to make some commits to use Uber's gomock fork and revert the change in .codecov.yaml. Please let me know if there's any concern. Thanks.

@KentHsu

KentHsu commented May 21, 2024

Copy link
Copy Markdown
Author

Hi @mikeee, would you like me to create another PR to exclude the mock files so that this PR won't be block by code coverage? Any suggestions on the code change in this PR?

@yaron2

yaron2 commented Jul 22, 2024

Copy link
Copy Markdown
Member

@KentHsu please resolve the conflicts

KentHsu added 3 commits July 23, 2024 19:22
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
@KentHsu

KentHsu commented Jul 23, 2024

Copy link
Copy Markdown
Author

Hi @yaron2, @mikeee , I just resolved the conflicts and updated mocks. Please let me know if there's anything I can do to get this PR merged. Thank you.

@mikeee mikeee modified the milestones: v1.11, v1.12 Sep 4, 2024
@mikeee mikeee modified the milestones: v1.12, v1.13 Jan 29, 2025
@mikeee mikeee modified the milestones: v1.13, v1.14 Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Owner

Development

Successfully merging this pull request may close these issues.

test: we should add tests for the stateManagerCtx

3 participants