-
Notifications
You must be signed in to change notification settings - Fork 178
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
Catch Timeout on test connection #4211
base: master
Are you sure you want to change the base?
Conversation
This is a copy of #4191, which got closed when I deleted the remote branch because of the changes in the history of master. To unblock CCT-506, I only kept the original fix of read timeout not being properly caught. I‘ll create a separate pull request for Matyáš’s discovery of duplicate exception print. Not all cases were covered by the original set of unit tests, so I backported those I wrote dealing with the additional fix. Now, the happy path and an uncaught exception path is tested in addition to the request failure one. This pull only deals with the reported bug of not dealing with timeouted requests. As such, it only tests that the exception is properly handled, printing concise details. Integration tests verifying the standard output as a whole is going to be part of the follow-up pull request. The executive code is same as in the original pull request, the tests changed slightly and there is more of them. Requesting thus a fresh review from @m-horky. Any feedback to them here will help me with the new PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this PR looks good, I like the tests. I left a few notes there to consider.
a0b6223
to
f1da1b3
Compare
Also, there was a failing test because of non-ASCII characters in the comments. I replaced the nice quotes ( |
FYI, we can ignore the following failed test:
The |
Addressed the review comments except one. See my inline comment. |
d079b8f
to
e98c02c
Compare
Resolved the last review comment and rebased on the current master. Ready for a review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for the code itself.
CI for Python 2.6 is failing on
E fixture 'caplog' not found
> available fixtures: cache, capfd, capsys, cov, doctest_namespace, insights_connection, monkeypatch, pytestconfig, record_xml_property, recwarn, run_rule, tmpdir, tmpdir_factory
you'll need to find a replacement (or e.g. backport it and use in 2.6 only) for that.
e98c02c
to
144dccc
Compare
pytest-catchlog providing the caplog fixture became part of Pytest since version 3.3. On previous ones it needs to be installed separately. Added the dependency to |
Adding the dependency to setup.py is not enough. The dependencies are grabbed from another repository. I created a pull request there, but I am afraid it’s never going to be reviewed and merged as it’s a personal repo not owned by RedHatInsights. I created a card suggesting migration of the requirements. Since jenkins-s2i-example is only used to provide the requirements file and its wheels, I think we can ditch the repo and move the files to this repository. We can even only adopt ci_requirements.txt and curl the wheels directly from PyPI, which is what pip does for other Python versions anyways. For now, I can either mark the tests as skipped for Python 2.6, or update them to check for function calls to the logger. The latter is suboptimal, but can do for the time being until CCT-768 is resolved. What do you think? |
2ebbd88
to
ae62e4c
Compare
Aha, interesting. At this point I think those tests could be skipped, let's not spend more time on this than needed. |
ae62e4c
to
e1fad89
Compare
The test_connection method only use a single very simple error logging call. It was trivial to replace it with a logger mock. It doesn’t even use logging string interpolation, so the asserts don’t need to incorrectly test the exact arguments rather than the resulting message. The other tests of the _test_urls_ and _legacy_test_urls methods use more complex logger calls, but they are no longer part of this pull request. |
e1fad89
to
64fbd73
Compare
Fixed the remaining Flake8 complaint. Now, everything should be ok. Please take a look at the alternative asserts without caplog. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
64fbd73
to
984a3f5
Compare
Updated on the current master. |
@xiangce Hi, after I tagged you I realized it didn't go through QE preverification yet. Sorry for the noise. |
984a3f5
to
5e13c23
Compare
5e13c23
to
5fe5706
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4211 +/- ##
==========================================
+ Coverage 77.01% 77.05% +0.04%
==========================================
Files 761 761
Lines 41471 41471
Branches 8763 8763
==========================================
+ Hits 31937 31955 +18
+ Misses 8481 8462 -19
- Partials 1053 1054 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
The --test-connection command only used to catch ConnectionError, including ConnectionTimeout, but not other timeouts such as ReadTimeoutError. Re-used the existing REQUEST_FAILED_EXCEPTIONS list to process all timeouts in the same way. * Card ID: CCT-506 Signed-off-by: Štěpán Tomsa <[email protected]>
5fe5706
to
6588b75
Compare
There is also #4254 in the family. It neither blocks anything nor is blocked by anything. It only shares some tests. |
All Pull Requests:
Check all that apply:
Complete Description of Additions/Changes:
The
--test-connection
command only used to catchConnectionError
, includingConnectionTimeout
, but not other timeouts such asReadTimeoutError
. Re-used the existingREQUEST_FAILED_EXCEPTIONS
list to process all timeouts in the same way.There is an integration test pull request RedHatInsights/insights-client#244 for this fix.
Card IDs: