-
Notifications
You must be signed in to change notification settings - Fork 48
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
fix(test): Enhancing test_http_timeout to include CCT-506 #244
base: master
Are you sure you want to change the base?
Conversation
7a53ca6
to
986053e
Compare
LGTM |
986053e
to
34ec1e0
Compare
I ran the test on my RHEL 9.4 VM and it didn’t fail.
Is it possible that I am doing something wrong? @Archana-PandeyM Did the test fail correctly during your review? |
I think I understood the PR wrong. The test it adds is actually verifying that the ReadTimeoutError is not caught and its traceback is printed. In such case, the test is correct and works as intended. Can you please confirm that, @zpetrace and @Archana-PandeyM? In such case, I think we can undraft, rebase, review and merge this pull request. I am working on a fix, so we can consider CCT-506 accepted. What does @m-horky think? |
I need to update my thoughs once again. I understood the original intention well: this integration test is supposed to fail. assert "Traceback" not in output.stdout ensures that it’s not the case when the exception is properly caught and concisely printed.
You can see there is no traceback, but the error is The actual wrong output this tests verifies that does not get printed is:
In this case, it’s The false positives can be easily avoided by making the error type assert more specific: - assert "timeout=0.01" in output.stdout
+ assert "read timeout=0.01" in output.stdout It however doesn’t resolve the problem of incorrectly testing For the time being, it’s at least possible to distinguish between the two error types by making the asserts more explicit as mentioned above: check the output for |
34ec1e0
to
d7eb72e
Compare
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.
I’d still consider mocking the response rather than setting a HTTP timeout. The timeout value is dependent on the actual state of the environment and as such is unreliable: it doesn’t guarantee a read error, a connection error or any error at all. If not replacing it with a mock, the two solutions can complement each other.
An error raised by a mock is no different from a real error, it’s only 100% reliable. The error doesn’t contain any response, status code, headers or body that may differ from what the actual service returns; it only emulates the network condition. Without mocking, the only reliable way to test would be to make the target service not respond in time.
That’s why I think in this case, mocking makes sense even in the integration tests.
d7eb72e
to
5cb0d98
Compare
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.
Unblocked! To make this work, http_timeout
needs to be set to 0.1
instead of 0.01
.
Value of 0.01
effectively tests when there is no network at all, but it's rather a hack and it should be set up differently (perhaps with misconfigured proxy).
…st-connection not catching ReadTimeoutError Exception
5cb0d98
to
1309953
Compare
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
Enhancing test_http_timeout to include CCT-506 - insights-client --test-connection not catching ReadTimeoutError Exception
So far this PR is a draft as the CCT card is still in refinement