Skip to content

Commit c411d47

Browse files
committed
Construct AutoValue Bootstrapper object in test instead of mocking it.
1 parent eadb202 commit c411d47

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

xds/src/main/java/io/grpc/xds/ExternalProcessorFilter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,9 @@ else if (response.hasResponseBody()) {
485485
extProcClientCallRequestObserver.onCompleted();
486486
}
487487
}
488+
// For robustness. For any internal processing failure make sure the internal state
489+
// machine is notified and the dataplane call is properly cancelled (or failed-open if
490+
// configured)
488491
} catch (Throwable t) {
489492
onError(t);
490493
}

xds/src/test/java/io/grpc/xds/ExternalProcessorFilterTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static com.google.common.truth.Truth.assertThat;
44

5+
import com.google.common.collect.ImmutableList;
56
import com.google.common.collect.ImmutableMap;
67
import com.google.protobuf.Any;
78
import io.envoyproxy.envoy.config.core.v3.GrpcService;
@@ -41,6 +42,7 @@
4142
import io.grpc.xds.ExternalProcessorFilter.ExternalProcessorFilterConfig;
4243
import io.grpc.xds.ExternalProcessorFilter.ExternalProcessorInterceptor;
4344
import io.grpc.xds.client.Bootstrapper;
45+
import io.grpc.xds.client.EnvoyProtoData.Node;
4446
import io.grpc.xds.internal.grpcservice.AllowedGrpcService;
4547
import io.grpc.xds.internal.grpcservice.AllowedGrpcServices;
4648
import io.grpc.xds.internal.grpcservice.CachedChannelManager;
@@ -158,21 +160,22 @@ public void setUp() throws Exception {
158160
this.provider = new ExternalProcessorFilter.Provider();
159161
this.provider.newInstance("ext-proc");
160162

161-
Bootstrapper.BootstrapInfo bootstrapInfo = Mockito.mock(Bootstrapper.BootstrapInfo.class);
162-
163-
// Create an AllowedGrpcServices mock
164-
AllowedGrpcServices allowedServices =
163+
AllowedGrpcServices allowedServices =
165164
AllowedGrpcServices.create(
166-
ImmutableMap.of("in-process:" + extProcServerName,
165+
ImmutableMap.of("in-process:" + extProcServerName,
167166
AllowedGrpcService.builder()
168167
.configuredChannelCredentials(ConfiguredChannelCredentials.create(
169168
InsecureChannelCredentials.create(), new InProcessChannelCredsConfig()))
170169
.build()));
171-
172-
Mockito.when(bootstrapInfo.allowedGrpcServices()).thenReturn(Optional.of(allowedServices));
173-
174-
Bootstrapper.ServerInfo serverInfo = Mockito.mock(Bootstrapper.ServerInfo.class);
175-
Mockito.when(serverInfo.isTrustedXdsServer()).thenReturn(false);
170+
171+
Bootstrapper.ServerInfo serverInfo = Bootstrapper.ServerInfo.create(
172+
"xds-server", InsecureChannelCredentials.create());
173+
174+
Bootstrapper.BootstrapInfo bootstrapInfo = Bootstrapper.BootstrapInfo.builder()
175+
.servers(ImmutableList.of(serverInfo))
176+
.node(Node.newBuilder().build())
177+
.allowedGrpcServices(Optional.of(allowedServices))
178+
.build();
176179

177180
this.filterContext = Filter.FilterContext.builder()
178181
.bootstrapInfo(bootstrapInfo)

0 commit comments

Comments
 (0)