aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar buchgr <buchgr@google.com>2017-08-04 15:09:08 +0200
committerGravatar Dmitry Lomov <dslomov@google.com>2017-08-04 17:19:11 +0200
commitfe9ba893c0ebec19228086356af5fa8d81f2809b (patch)
tree30fd46f483730219f7f981ea47ec7cc0896e3f8c /src/test/java/com/google/devtools/build
parentdba4916861074760d120dcc0f15cc916f8d8520e (diff)
grpc: Consolidate gRPC code from BES and Remote Execution. Fixes #3460, #3486
BES and Remote Execution have separate implementations of gRPC channel creation, authentication and TLS. We should merge them, to avoid duplication and bugs. One such bug is #3640, where the BES code had a different implementation for Google Application Default Credentials. RELNOTES: The Build Event Service (BES) client now properly supports Google Applicaton Default Credentials. PiperOrigin-RevId: 164253879
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteCacheTest.java22
-rw-r--r--src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java8
2 files changed, 17 insertions, 13 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteCacheTest.java b/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteCacheTest.java
index c43a09f690..1df06cdf42 100644
--- a/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteCacheTest.java
+++ b/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteCacheTest.java
@@ -28,6 +28,7 @@ import com.google.bytestream.ByteStreamProto.WriteResponse;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.ActionInputHelper;
import com.google.devtools.build.lib.authandtls.AuthAndTLSOptions;
+import com.google.devtools.build.lib.authandtls.GrpcUtils;
import com.google.devtools.build.lib.remote.Digests.ActionKey;
import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.util.io.FileOutErr;
@@ -46,6 +47,7 @@ import com.google.devtools.remoteexecution.v1test.FindMissingBlobsResponse;
import com.google.devtools.remoteexecution.v1test.GetActionResultRequest;
import com.google.devtools.remoteexecution.v1test.UpdateActionResultRequest;
import com.google.protobuf.ByteString;
+import io.grpc.CallCredentials;
import io.grpc.CallOptions;
import io.grpc.Channel;
import io.grpc.ClientCall;
@@ -108,17 +110,17 @@ public class GrpcRemoteCacheTest {
fakeServer.shutdownNow();
}
- private static class ChannelOptionsInterceptor implements ClientInterceptor {
- private final ChannelOptions channelOptions;
+ private static class CallCredentialsInterceptor implements ClientInterceptor {
+ private final CallCredentials credentials;
- public ChannelOptionsInterceptor(ChannelOptions channelOptions) {
- this.channelOptions = channelOptions;
+ public CallCredentialsInterceptor(CallCredentials credentials) {
+ this.credentials = credentials;
}
@Override
public <RequestT, ResponseT> ClientCall<RequestT, ResponseT> interceptCall(
MethodDescriptor<RequestT, ResponseT> method, CallOptions callOptions, Channel next) {
- assertThat(callOptions.getCredentials()).isEqualTo(channelOptions.getCallCredentials());
+ assertThat(callOptions.getCredentials()).isEqualTo(credentials);
// Remove the call credentials to allow testing with dummy ones.
return next.newCall(method, callOptions.withCallCredentials(null));
}
@@ -138,16 +140,16 @@ public class GrpcRemoteCacheTest {
Scratch scratch = new Scratch();
scratch.file(authTlsOptions.authCredentials, new JacksonFactory().toString(json));
- ChannelOptions channelOptions =
- ChannelOptions.create(
- authTlsOptions, scratch.resolve(authTlsOptions.authCredentials).getInputStream());
+ CallCredentials creds = GrpcUtils.newCallCredentials(
+ scratch.resolve(authTlsOptions.authCredentials).getInputStream(),
+ authTlsOptions.authScope);
RemoteOptions remoteOptions = Options.getDefaults(RemoteOptions.class);
Retrier retrier = new Retrier(remoteOptions);
return new GrpcRemoteCache(
ClientInterceptors.intercept(
InProcessChannelBuilder.forName(fakeServerName).directExecutor().build(),
- ImmutableList.of(new ChannelOptionsInterceptor(channelOptions))),
- channelOptions,
+ ImmutableList.of(new CallCredentialsInterceptor(creds))),
+ creds,
remoteOptions,
retrier);
}
diff --git a/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java b/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java
index 96e95487dc..2fcfa7ee91 100644
--- a/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java
+++ b/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java
@@ -35,6 +35,7 @@ import com.google.devtools.build.lib.actions.EnvironmentalExecException;
import com.google.devtools.build.lib.actions.ResourceSet;
import com.google.devtools.build.lib.actions.SimpleSpawn;
import com.google.devtools.build.lib.authandtls.AuthAndTLSOptions;
+import com.google.devtools.build.lib.authandtls.GrpcUtils;
import com.google.devtools.build.lib.exec.SpawnInputExpander;
import com.google.devtools.build.lib.exec.SpawnResult;
import com.google.devtools.build.lib.exec.SpawnRunner.ProgressStatus;
@@ -67,6 +68,7 @@ import com.google.watcher.v1.Change;
import com.google.watcher.v1.ChangeBatch;
import com.google.watcher.v1.Request;
import com.google.watcher.v1.WatcherGrpc.WatcherImplBase;
+import io.grpc.CallCredentials;
import io.grpc.Channel;
import io.grpc.Server;
import io.grpc.Status;
@@ -216,10 +218,10 @@ public class GrpcRemoteExecutionClientTest {
Channel channel = InProcessChannelBuilder.forName(fakeServerName).directExecutor().build();
GrpcRemoteExecutor executor =
new GrpcRemoteExecutor(channel, null, options.remoteTimeout, retrier);
- ChannelOptions defaultOpts =
- ChannelOptions.create(Options.getDefaults(AuthAndTLSOptions.class));
+ CallCredentials creds =
+ GrpcUtils.newCallCredentials(Options.getDefaults(AuthAndTLSOptions.class));
GrpcRemoteCache remoteCache =
- new GrpcRemoteCache(channel, defaultOpts, options, retrier);
+ new GrpcRemoteCache(channel, creds, options, retrier);
client = new RemoteSpawnRunner(execRoot, options, null, true, remoteCache, executor);
inputDigest = fakeFileCache.createScratchInput(simpleSpawn.getInputFiles().get(0), "xyz");
}