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

Remove double exception print #4246

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

Glutexo
Copy link
Collaborator

@Glutexo Glutexo commented Oct 11, 2024

All Pull Requests:

Check all that apply:

  • Have you followed the guidelines in our Contributing document, including the instructions about commit messages?
  • No Sensitive Data in this change?
  • Is this PR to correct an issue?
  • Is this PR an enhancement?

Complete Description of Additions/Changes:

In case of a connection error, an exception description was printed on the standard output twice: once by the outer test_connection method and once by the inner _(legacy_)test_urls method. The legacy version tries multiple URLs and prints the exception description on each failure. Thus, removed the outer print that only duplicates the last caught exception.

Card IDs:

@Glutexo Glutexo added the client These issues represent work to be done by the "client" team. label Oct 11, 2024
@Glutexo Glutexo self-assigned this Oct 11, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.18%. Comparing base (f284dd0) to head (5e34f37).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4246      +/-   ##
==========================================
+ Coverage   77.11%   77.18%   +0.07%     
==========================================
  Files         761      761              
  Lines       41473    41472       -1     
  Branches     8763     8763              
==========================================
+ Hits        31981    32010      +29     
+ Misses       8437     8406      -31     
- Partials     1055     1056       +1     
Flag Coverage Δ
unittests 77.17% <100.00%> (+0.07%) ⬆️

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

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

@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 11, 2024

This pull request contains changes requested by Matyáš. First, I extracted the changes from #4191 that didn’t belong to that PR. Then, I only kept the requested changes, replacing an intermediary PR #4237.

Both pull requests introduce changes to the now untested test connection mechanic and both deal with exception handling. Because of that, general unit tests for sub-method calls are included in both of them. After one PR will have been merged I will resolve the conflict in the other one.

As for the caplog fixture, that is not supported on Python ≤2.7, I’m aware that the suggestion was to mark the tests as skipped. The change to logger asserts was however trivial. Moreover, I already used those in the sister pull request #4211. Such asserts are less semantic, but working. They need to be replaced after fixing the pipeline, but so do the skip marks.

Opening the pull request for review. @m-horky

@Glutexo Glutexo marked this pull request as ready for review October 11, 2024 13:55
@Glutexo Glutexo mentioned this pull request Oct 11, 2024
4 tasks
@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 14, 2024

If #4211 gets merged first, this pull request would bring a regression. The other PR extends the set of exceptions caught by the outer test_connection method, but this one removes the redundant exception print from the same method.

That means that after merging #4211, exceptions will be properly printed for read timeouts too (currently they are not), but then after merging this PR, that print will get removed. As a result, the read timeouts will be caught and would not dump a traceback, but wouldn’t have a nice print.

To fix that, exception handling in the inner _(legacy_)test_urls methods needs to be extended too. Doing so, read timeouts would reach the proper inner print and the outer one won’t be necessary – which was the original intention of this PR. I will create a new pull request to unblock this one.

Copy link
Contributor

@m-horky m-horky left a comment

Choose a reason for hiding this comment

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

ACK. One note.

@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 21, 2024

To make things simpler, let‘s say this is blocked by #4246 and is a blocker of #4211. Merging #4246 first will make further reviewing and merging easier and would significantly reduce the size of the test patch.

@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 22, 2024

There is also #4254 in the family. It neither blocks anything nor is blocked by anything. It only shares some tests.

@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 22, 2024

#4248 got merged. There are now conflicts. That’s because both PRs contained same tests. Will resolve and re-request a review.

@Glutexo Glutexo force-pushed the double-exception-only branch 2 times, most recently from 084d80b to c158611 Compare October 24, 2024 08:49
@Glutexo
Copy link
Collaborator Author

Glutexo commented Oct 24, 2024

Rebased on the current master with #4248 merged. Resolved conflicts in the tests:

  • Different exceptions are expected in test_connection and in _(legacy_)_test_urls.
  • Covered cases when Read Timeout caught by _(legacy_)_test_urls, but not test_connection.

This pull request only changes what is print on standard output. It is a part of what’s communicated to the user though. Because of that there are error log tests too. Prints and logging are always happen at the same time. They are on adjacent lines.

@Glutexo Glutexo requested a review from m-horky October 24, 2024 09:16
In case of a connection error, an exception description was printed on the standard output twice: once by the outer test_connection method and once by the inner _(legacy_)test_urls method. The legacy version tries multiple URLs and prints the exception description on each failure. Thus, removed the outer print that only duplicates the last caught exception.

Card IDs:

* CCT-724

Signed-off-by: Štěpán Tomsa <[email protected]>
Copy link
Contributor

@m-horky m-horky left a comment

Choose a reason for hiding this comment

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

ACK. Hi @xiangce, good to merge!

@xiangce xiangce merged commit 11209f9 into RedHatInsights:master Oct 30, 2024
15 checks passed
@Glutexo Glutexo deleted the double-exception-only branch October 30, 2024 11:34
xiangce pushed a commit that referenced this pull request Oct 31, 2024
In case of a connection error, an exception description was printed
on the standard output twice: once by the outer test_connection
method and once by the inner _(legacy_)test_urls method. The legacy
version tries multiple URLs and prints the exception description on
each failure. Thus, removed the outer print that only duplicates the
last caught exception.

Card IDs: CCT-724

Signed-off-by: Štěpán Tomsa <[email protected]>
(cherry picked from commit 11209f9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client These issues represent work to be done by the "client" team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants