Repository navigation
test(bigquery-jdbc): align ITOpenTelemetryTest with per-connection proxy, TrustStore, and GAPIC Logging - #15348
Conversation
…oxy, TrustStore, and GAPIC Logging
There was a problem hiding this comment.
Code Review
This pull request refactors ITOpenTelemetryTest.java to improve proxy and SSL trust store handling during integration testing. It removes global system property modifications, introduces helper methods to build verification credentials and transport channel providers, and migrates log fetching to use LoggingClient with a bounded timestamp filter. The review feedback suggests two key improvements: removing the unused local variable hexSpanId in verifyAndFetchLogs, and failing fast with an exception if an SSL trust store is configured but the channel builder is not an instance of NettyChannelBuilder to prevent silent failures.
| String traceId = null; | ||
| String hexSpanId = null; | ||
| for (LogEntry entry : entries) { | ||
| if (entry.getTrace() != null) { | ||
| if (!entry.getTrace().isEmpty()) { | ||
| traceId = entry.getTrace(); | ||
| hexSpanId = entry.getSpanId(); | ||
| hexSpanId = entry.getSpanId().isEmpty() ? null : entry.getSpanId(); | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
| if (sslTrustStorePath != null | ||
| && !sslTrustStorePath.trim().isEmpty() | ||
| && builder instanceof NettyChannelBuilder) { | ||
| try { | ||
| TrustManagerFactory tmf = | ||
| loadTrustManagerFactory( | ||
| sslTrustStorePath, | ||
| sslTrustStorePassword, | ||
| sslTrustStoreType, | ||
| sslTrustStoreProvider); | ||
| SslContext sslContext = GrpcSslContexts.forClient().trustManager(tmf).build(); | ||
| ((NettyChannelBuilder) builder).sslContext(sslContext); | ||
| } catch (IOException | GeneralSecurityException e) { | ||
| throw new IllegalStateException("Failed to configure test SSL TrustStore", e); | ||
| } | ||
| } |
There was a problem hiding this comment.
If sslTrustStorePath is provided but the builder is not an instance of NettyChannelBuilder (for example, if the classpath uses unshaded Netty or another transport), the trust store configuration is silently skipped. This can lead to hard-to-debug SSL handshake failures. It is safer to fail fast by throwing an IllegalStateException if a trust store is requested but cannot be applied to the channel builder.
if (sslTrustStorePath != null && !sslTrustStorePath.trim().isEmpty()) {
if (builder instanceof NettyChannelBuilder) {
try {
TrustManagerFactory tmf =
loadTrustManagerFactory(
sslTrustStorePath,
sslTrustStorePassword,
sslTrustStoreType,
sslTrustStoreProvider);
SslContext sslContext = GrpcSslContexts.forClient().trustManager(tmf).build();
((NettyChannelBuilder) builder).sslContext(sslContext);
} catch (IOException | GeneralSecurityException e) {
throw new IllegalStateException("Failed to configure test SSL TrustStore", e);
}
} else {
throw new IllegalStateException(
"SSL TrustStore configured but the channel builder is not an instance of NettyChannelBuilder: "
+ builder.getClass().getName());
}
}
Summary
Updates
ITOpenTelemetryTestso integration tests verify the driver's per-connection proxy,SSLTrustStore*, anduniverseDomainpropagation directly instead of relying on JVM-wide system properties, and aligns log verification with GAPICLoggingClient.Key Decisions
setUpProxyProperties()/tearDownProxyProperties()(https.proxyHost,http.proxyHost, etc.) because global properties masked whether the driver actually propagated proxy and TrustStore settings to its exporters.TransportChannelProvider(supportingProxyUid/ProxyPwdandSSLTrustStore*) and per-client Apache5 HTTP transport on verification credentials for bothverifyAndFetchLogs(...)andverifyAndFetchTrace(...).verifyAndFetchLogs(...)from legacyLoggingto GAPICLoggingClientand added an explicittimestamp >= <24h ago>filter bound (previously added automatically byLoggingImpl).@Tag("disable_universe_domain"): Kept pending a live custom-universe integration test run.Behavior Changes