Skip to content

Conversation

@rschmitt
Copy link
Contributor

@rschmitt rschmitt commented Jun 3, 2025

This change adds basic integration test coverage for connection timeouts for the sync and async clients. The tests work by sending a request to a non-routable IP address, with timeouts configured two different ways (ConnectionConfig and RequestConfig), using both HTTP and HTTPS. The connection request gets blackholed pretty reliably, and then the tests assert that we actually waited a reasonable length of time with respect to the configured timeout. Finally, there are some client-specific assertions for the type and content of the exception thrown.

@garydgregory
Copy link
Member

Odd that the tests fail only on macOS.

@rschmitt
Copy link
Contributor Author

rschmitt commented Jun 3, 2025

They do? I developed them on macOS, and my /etc/hosts file doesn't have an entry for the address I'm using. They were failing on JDK17+, but I fixed that.

@garydgregory
Copy link
Member

I saw these failures:

https://github.com/apache/httpcomponents-client/actions/runs/15425891897

We're they random?

@rschmitt
Copy link
Contributor Author

rschmitt commented Jun 3, 2025

Those are JDK17/JDK21 failures occasioned by a change in capitalization. JDK8 and JDK11 report connect timed out, while JDK17 and JDK21 report Connect timed out.

There are some cases in integration testing where there are significant differences between Linux and macOS, such as the default loopback addresses, but to my knowledge this PR isn't affected by them.

@rschmitt rschmitt force-pushed the timeout-tests branch 2 times, most recently from fac7043 to b945bfa Compare June 4, 2025 02:46
This change adds basic integration test coverage for connection timeouts
for the sync and async clients. The tests work by sending a request to a
non-routable IP address, with timeouts configured two different ways
(`ConnectionConfig` and `RequestConfig`), using both HTTP and HTTPS. The
connection request gets blackholed pretty reliably, and then the tests
assert that we actually waited a reasonable length of time with respect
to the configured timeout. Finally, there are some client-specific
assertions for the type and content of the exception thrown.
@rschmitt rschmitt merged commit 3500661 into apache:master Jun 4, 2025
10 checks passed
@rschmitt rschmitt deleted the timeout-tests branch June 4, 2025 17:15
@garydgregory
Copy link
Member

We need Windows tests in the CI I think:

[ERROR] Tests run: 13, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.043 s <<< FAILURE! -- in org.apache.hc.client5.http.TestHttpRoute
[ERROR] org.apache.hc.client5.http.TestHttpRoute.testUnixDomainSocketModeling -- Time elapsed: 0.015 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: </var/run/docker.sock->{}->[http://target1.test.invalid:80]> but was: <\var\run\docker.sock->{}->[http://target1.test.invalid:80]>
        at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
        at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
        at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
        at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145)
        at org.apache.hc.client5.http.TestHttpRoute.testUnixDomainSocketModeling(TestHttpRoute.java:469)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

I have Rancher Desktop 1.18.2 installed if that matters.

@rschmitt
Copy link
Contributor Author

rschmitt commented Jun 4, 2025

Windows CI builds were disabled in 2022 due to "intermittent network failures." I'm not sure what that means. Do any of these tests talk to the internet?

@rschmitt
Copy link
Contributor Author

rschmitt commented Jun 4, 2025

#642

@ok2c
Copy link
Member

ok2c commented Jun 4, 2025

Windows CI builds were disabled in 2022 due to "intermittent network failures." I'm not sure what that means. Do any of these tests talk to the internet?

@rschmitt @garydgregory That means that some integration tests fail intermittently with connection reset for no obvious reasons on Windows only. The same tests always pass on Ubuntu and MacOS. I tried really hard to find the cause of those failures to no avail. I will have to disable tests on Windows again if the problem recurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants