Skip to content

Conversation

@ejona86
Copy link
Member

@ejona86 ejona86 commented Jan 19, 2023

Our tests assume localhost is in /etc/hosts or uses some other form of local-only resolution. But that wouldn't apply to "host". What was happening is this was causing a DNS resolution, which would fail, and the InetSocketAddress would be "unresolved". Thus, the equivalent and faster code would be InetSocketAddress.createUnresolved("host", 1234). But there doesn't seem to be any reason to avoid localhost in this test, so swap to the more typical solution instead.

This should avoid flakes like:

io.grpc.okhttp.OkHttpClientTransportTest > invalidAuthorityPropagates FAILED
    org.junit.runners.model.TestTimedOutException: test timed out after 10 seconds
        at [email protected]/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at [email protected]/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929)
        at [email protected]/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1529)
        at [email protected]/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848)
        at [email protected]/java.net.InetAddress.getAllByName0(InetAddress.java:1519)
        at [email protected]/java.net.InetAddress.getAllByName(InetAddress.java:1378)
        at [email protected]/java.net.InetAddress.getAllByName(InetAddress.java:1306)
        at [email protected]/java.net.InetAddress.getByName(InetAddress.java:1256)
        at [email protected]/java.net.InetSocketAddress.<init>(InetSocketAddress.java:220)
        at app//io.grpc.okhttp.OkHttpClientTransportTest.invalidAuthorityPropagates(OkHttpClientTransportTest.java:1687)

Flake seen in #9849.

Our tests assume localhost is in /etc/hosts or uses some other form of
local-only resolution. But that wouldn't apply to "host". What was
happening is this was causing a DNS resolution, which would fail, and
the InetSocketAddress would be "unresolved". Thus, the equivalent and
faster code would be `InetSocketAddress.createUnresolved("host", 1234)`.
But there doesn't seem to be any reason to avoid localhost in this test,
so swap to the more typical solution instead.

This should avoid flakes like:
```
io.grpc.okhttp.OkHttpClientTransportTest > invalidAuthorityPropagates FAILED
    org.junit.runners.model.TestTimedOutException: test timed out after 10 seconds
        at [email protected]/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at [email protected]/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929)
        at [email protected]/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1529)
        at [email protected]/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848)
        at [email protected]/java.net.InetAddress.getAllByName0(InetAddress.java:1519)
        at [email protected]/java.net.InetAddress.getAllByName(InetAddress.java:1378)
        at [email protected]/java.net.InetAddress.getAllByName(InetAddress.java:1306)
        at [email protected]/java.net.InetAddress.getByName(InetAddress.java:1256)
        at [email protected]/java.net.InetSocketAddress.<init>(InetSocketAddress.java:220)
        at app//io.grpc.okhttp.OkHttpClientTransportTest.invalidAuthorityPropagates(OkHttpClientTransportTest.java:1687)
```
@ejona86 ejona86 requested a review from YifeiZhuang January 19, 2023 17:23
@ejona86 ejona86 merged commit 9de989b into grpc:master Jan 19, 2023
@ejona86 ejona86 deleted the okhttp-test-host branch January 19, 2023 18:51
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants