Skip to content

[Core] Fix HTTP client tests that break under the CI agents' network-isolation proxy - #51110

Merged
Alan Zimmer (alzimmermsft) merged 3 commits into
Azure:mainfrom
ibrandes:core/vertxProviderTestsUnresolvedProxy
Nov 6, 2026
Merged

Alan Zimmer (alzimmermsft) merged 3 commits into
Azure:mainfrom
ibrandes:core/vertxProviderTestsUnresolvedProxy

Conversation

@ibrandes

@ibrandes Isabelle (ibrandes) commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Description

Since the Linux CI agents' 1ES Network Isolation task updated from 1.0.192 to 1.0.193 (Nov 4), core HTTP client tests that read the global proxy configuration fail on any PR that runs them. Two separate test bugs are exposed. Production code is not affected.

The agents' network-isolation setup:

  • sets HTTPS_PROXY, http_proxy, and NO_PROXY=localhost,127.0.0.1,... for the pipeline (already the case before the update), and
  • starting with 1.0.193, also sets JAVA_TOOL_OPTIONS, which includes -Dhttps.proxyHost=<agent IP> -Dhttps.proxyPort=18080 -Dhttp.nonProxyHosts=localhost|127.0.0.1|..., so every JVM, including the test JVMs, now sees a JVM proxy.

1. VertxHttpClientProviderTests: resolved versus unresolved proxy host

nullOptionsReturnsBaseClient and defaultOptionsReturnsBaseClient fail with:

org.opentest4j.AssertionFailedError: expected: <e72385c4c000004.internal.cloudapp.net> but was: <10.1.0.164>
  • ProxyOptions.fromConfiguration ignores the HTTPS_PROXY environment variable unless java.net.useSystemProxies=true, but it does read the JVM's https.proxyHost. Before 1.0.193 these tests saw no proxy and passed.
  • VertxHttpClientBuilder loads the proxy unresolved (ProxyOptions.fromConfiguration(configuration, true)), so Vert.x is configured with the host exactly as given: 10.1.0.164.
  • The tests loaded it resolved (ProxyOptions.fromConfiguration(configuration)) and compared getAddress().getHostName(). For a resolved IP address that does a reverse DNS lookup, which on the Azure agents returns the VM's internal name.

2. buildWithHttpProxyFromEnvConfiguration (Vert.x and JDK): the agent's NO_PROXY leaks in

VertxHttpClientBuilderTests.buildWithHttpProxyFromEnvConfiguration and JdkHttpClientBuilderTests.buildWithHttpProxyFromEnvConfiguration fail with:

expectation "expectNextCount(1)" failed (expected: count = 1; actual: counted = 0; signal: onError(io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:80))
  • These tests fake the proxy environment variables they need, but not NO_PROXY. For any variable the fake doesn't define, EnvironmentConfiguration reads the real one, so the agent's NO_PROXY leaked in.
  • Because it lists localhost, the client skipped the test proxy and connected directly to localhost:80.

Changes

  • VertxHttpClientProviderTests: both tests now load the environment proxy the way VertxHttpClientBuilder does, unresolved (ProxyOptions.fromConfiguration(Configuration.getGlobalConfiguration(), true)), through a small helper with a comment explaining why. getHostName() then returns the configured host without a DNS lookup.
  • VertxHttpClientBuilderTests and JdkHttpClientBuilderTests: buildWithHttpProxyFromEnvConfiguration sets PROPERTY_NO_PROXY to "" in its fake configuration, as the Netty and OkHttp builder tests already do.

NettyAsyncHttpClientProviderTests and OkHttpAsyncClientProviderTests use the same proxy-loading pattern as the Vert.x provider tests but compare whole InetSocketAddress objects. They pass with the same JVM proxy setting, so they are unchanged.

No CHANGELOG entries, as only tests change.

Validation

To mimic the agents, these environment variables were set locally, with 8.8.8.8 (an IP whose reverse DNS name is dns.google) in place of the agent IP:

  • JAVA_TOOL_OPTIONS=-Dhttps.proxyHost=8.8.8.8 -Dhttps.proxyPort=18080 -Dhttp.nonProxyHosts=localhost|127.0.0.1|169.254.169.254
  • HTTPS_PROXY=http://8.8.8.8:18080, http_proxy=http://8.8.8.8:18080, NO_PROXY=localhost,127.0.0.1,169.254.169.254
Command Before After
mvn -o -f sdk/core/azure-core-http-vertx/pom.xml test -Dtest=VertxHttpClientProviderTests with only the JAVA_TOOL_OPTIONS proxy failed: 2 of 23 (expected: <dns.google> but was: <8.8.8.8>), matching CI passed: 23 tests
mvn -o -f sdk/core/azure-core-http-vertx/pom.xml test "-Dtest=VertxHttpClientBuilderTests,VertxHttpClientProviderTests" with all of the above failed: 1 of 44 (buildWithHttpProxyFromEnvConfiguration, Connection refused: localhost/127.0.0.1:80), matching CI passed: 44 tests
mvn -o -f sdk/core/azure-core-http-jdk-httpclient/pom.xml test -Dtest=JdkHttpClientBuilderTests with all of the above failed: 1 of 48 (buildWithHttpProxyFromEnvConfiguration) passed: 48 tests
  • VertxHttpClientProviderTests also passed (23 tests) with a hostname JVM proxy (-Dhttps.proxyHost=proxy.example.com) and with no proxy set.
  • checkstyle:check passed for azure-core-http-vertx and azure-core-http-jdk-httpclient.
  • NettyAsyncHttpClientProviderTests (24 tests, 1 skipped) and OkHttpAsyncClientProviderTests (21 tests) passed with the same JAVA_TOOL_OPTIONS proxy, without changes.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes. (Not applicable: test-only change.)
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
33 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for this test-only proxy assertion update.

No open issues 🎉

What changed in this PR

This test-only change fixes Vert.x HTTP client provider assertions when the JVM proxy host is an IP address. It aligns proxy loading in the tests with the existing builder behavior; production code is unchanged.

Changes:

  • Use a shared helper to load unresolved environment proxies in both default-client tests.
  • Explain why resolving proxy addresses can cause reverse-DNS hostname mismatches.
File Description
sdk/​core/​azure-core-http-vertx/​src/​test/​java/​com/​azure/​core/​http/​vertx/​VertxHttpClientProviderTests.java Load unresolved proxies in both tests to preserve the configured host during assertions.

Review effort: Balanced

@ibrandes Isabelle (ibrandes) changed the title [Core] [Vert.x] Fix VertxHttpClientProviderTests when the JVM proxy host is an IP address [Core] Fix HTTP client tests that break under the CI agents' network-isolation proxy Nov 5, 2026
@alzimmermsft
Alan Zimmer (alzimmermsft) merged commit 6a51adc into Azure:main Nov 6, 2026
53 of 55 checks passed
@ibrandes
Isabelle (ibrandes) deleted the core/vertxProviderTestsUnresolvedProxy branch November 6, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure.Core azure-core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants