8000 tests: fix wrongly used mock by maximilianwerk · Pull Request #1966 · jina-ai/serve · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tests: fix wrongly used mock #1966

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

Merged
merged 5 commits into from
Feb 24, 2021
Merged

Conversation

maximilianwerk
Copy link
Member

This is the right usage of mocker.Mock with a validation function. It generates way better tracebacks, when the tests fail.

Furthermore, the correct naming would have been wraps instead of wrap.

There are still tests, which do it via calling the mock inside the validation function like tests/distributed/test_join_local_from_remote/test_integration.py. Anyhow, they work correctly, but don't give a bad traceback. Can be refactored how it is done in this PR.

@maximilianwerk maximilianwerk requested a review from a team as a code owner February 17, 2021 16:49
@jina-bot jina-bot added size/M area/testing This issue/PR affects testing labels Feb 17, 2021
@maximilianwerk maximilianwerk force-pushed the fix-enable-wrong-wrapped-tests branch from 8287102 to e25b987 Compare February 17, 2021 16:54
@codecov
Copy link
codecov bot commented Feb 17, 2021

Codecov Report

Merging #1966 (f0bc2d5) into master (17a64e7) will decrease coverage by 32.16%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1966       +/-   ##
===========================================
- Coverage   85.63%   53.47%   -32.17%     
===========================================
  Files         183      180        -3     
  Lines       10469    10437       -32     
===========================================
- Hits         8965     5581     -3384     
- Misses       1504     4856     +3352     
Flag Coverage Δ
jina 53.47% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
jina/parsers/ping.py 0.00% <0.00%> (-100.00%) ⬇️
jina/docker/helper.py 0.00% <0.00%> (-100.00%) ⬇️
jina/parsers/hub/new.py 0.00% <0.00%> (-100.00%) ⬇️
jina/parsers/hub/list.py 0.00% <0.00%> (-100.00%) ⬇️
jina/parsers/hub/build.py 0.00% <0.00%> (-100.00%) ⬇️
jina/parsers/hub/login.py 0.00% <0.00%> (-100.00%) ⬇️
jina/parsers/hub/pushpull.py 0.00% <0.00%> (-100.00%) ⬇️
jina/types/request/common.py 0.00% <0.00%> (-100.00%) ⬇️
jina/types/ndarray/sparse/numpy.py 0.00% <0.00%> (-100.00%) ⬇️
jina/helloworld/fashion/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
... and 124 more

Continue to review full report at Codecov.

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

@github-actions
Copy link
github-actions bot commented Feb 17, 2021

Latency summary

Current PR yields:

  • 😶 index QPS at 1079, delta to last 3 avg.: +0%
  • 😶 query QPS at 17, delta to last 3 avg.: -1%

Breakdown

Version Index QPS Query QPS
current 1079 17
1.0.4 1075 17
1.0.3 1074 17

Backed by latency-tracking. Further commits will update this comment.

@@ -47,3 +47,9 @@ def rm_files(file_paths):
elif os.path.isdir(file_path):
shutil.rmtree(file_path, ignore_errors=False, >


def validate_callback(mock, validate_func):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we perhaps create a new instance of Mocker here and avoid spamming it in the code of the tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't get the suggestion 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

We could pass mocker instead of mock as an argument and use mocker.patch() or mocker.patch.object.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to create m = mocker.Mock() in the body of the test? Can't we create it inside this validate_cb instead, for each situation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because it is send to the Flow as the on_done callback and collects the callback data there.

Copy link
Contributor

Choose a reason for hiding this comment

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

we could maybe offer this as a fixture that yields the mock and when finished passes the callback through this validation?

Copy link
Contributor

Choose a reason for hiding this comment

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

This would need to be very well documented however

@maximilianwerk maximilianwerk force-pushed the fix-enable-wrong-wrapped-tests branch from e25b987 to 1897416 Compare February 17, 2021 21:06
@jina-bot jina-bot added area/core This issue/PR affects the core codebase component/resource labels Feb 17, 2021
@maximilianwerk
Copy link
Member Author

I have not a lot of experience around these tests, but could someone check, if my fix for tests/unit/flow/test_flow_skip.py::test_bad_flow_skip_handle_join is correct or if the test itself is failing. Thanks! @JoanFM

@maximilianwerk maximilianwerk force-pushed the fix-enable-wrong-wrapped-tests branch from 2232787 to 51530ea Compare February 22, 2021 11:46
nan-wang
nan-wang previously approved these changes Feb 24, 2021
Copy link
Member
@nan-wang nan-wang 8000 left a comment

Choose a reason for hiding this comment

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

LGTM👍

@nan-wang nan-wang merged commit fb303b8 into master Feb 24, 2021
@nan-wang nan-wang deleted the fix-enable-wrong-wrapped-tests branch February 24, 2021 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core This issue/PR affects the core codebase area/testing This issue/PR affects testing component/resource size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0