Skip to content

Commit bc81478

Browse files
test: ensure that directpath is enabled for direct path tests (#2263)
This should unblock #2033 which disables directpath by default
1 parent 9a2db83 commit bc81478

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ If you are using Maven without the BOM, add this to your dependencies:
5050
If you are using Gradle 5.x or later, add this to your dependencies:
5151

5252
```Groovy
53-
implementation platform('com.google.cloud:libraries-bom:26.41.0')
53+
implementation platform('com.google.cloud:libraries-bom:26.42.0')
5454
5555
implementation 'com.google.cloud:google-cloud-bigtable'
5656
```

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/test_helpers/env/CloudEnv.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ private CloudEnv(
134134
dataSettings.stubSettings().setEndpoint(dataEndpoint);
135135
}
136136

137-
setupRemoteAddrInterceptor(dataSettings.stubSettings());
137+
configureConnection(dataSettings.stubSettings());
138138
configureUserAgent(dataSettings.stubSettings());
139+
139140
if (tracingCookie != null) {
140141
injectTracingCookie(tracingCookie, dataSettings.stubSettings());
141142
}
@@ -164,21 +165,24 @@ private static void injectTracingCookie(
164165
.build());
165166
}
166167

167-
private void setupRemoteAddrInterceptor(StubSettings.Builder stubSettings) {
168+
private void configureConnection(StubSettings.Builder stubSettings) {
168169
// Build an remote address restricting interceptor
169170
final ClientInterceptor interceptor;
171+
boolean enableDirectPath = false;
170172

171173
switch (getConnectionMode()) {
172174
case DEFAULT:
173175
// nothing special
174176
return;
175177
case REQUIRE_DIRECT_PATH:
178+
enableDirectPath = true;
176179
interceptor =
177180
buildRemoteAddrInterceptor(
178181
"DirectPath IPv4 or IPv6",
179182
Predicates.or(DIRECT_PATH_IPV4_MATCHER, DIRECT_PATH_IPV6_MATCHER));
180183
break;
181184
case REQUIRE_DIRECT_PATH_IPV4:
185+
enableDirectPath = true;
182186
interceptor =
183187
buildRemoteAddrInterceptor("DirectPath IPv4", Predicates.or(DIRECT_PATH_IPV4_MATCHER));
184188
break;
@@ -201,6 +205,10 @@ private void setupRemoteAddrInterceptor(StubSettings.Builder stubSettings) {
201205
final ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> oldConfigurator =
202206
channelProvider.getChannelConfigurator();
203207

208+
if (enableDirectPath) {
209+
channelProvider.setAttemptDirectPath(true).setAttemptDirectPathXds();
210+
}
211+
204212
@SuppressWarnings("rawtypes")
205213
final ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> newConfigurator =
206214
new ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder>() {

0 commit comments

Comments
 (0)