diff options
author | 2017-11-15 07:11:08 -0800 | |
---|---|---|
committer | 2017-11-15 07:19:40 -0800 | |
commit | 275ae45b1228bdd0f912c4fbd634b29ba4180383 (patch) | |
tree | 6264b6aa3eb23a451a0b3c41935a7197a8815bfd /src/test/java/com/google/devtools/build/lib/server/GrpcServerTest.java | |
parent | 84943fc8f84fef04cf0a7b7fe7f0abea1e1497f2 (diff) |
Automated rollback of commit 4869c4e17d5b1410070a1570f3244148d8f97b5d.
*** Reason for rollback ***
Causing Bazel server to crash when running bazel clean --expunge
https://github.com/bazelbuild/bazel/issues/3956
*** Original change description ***
Delayed rollforward of commit 8fb311b4dced234b2f799c16c7d08148619f4087.
This was rolled back due to Tensorflow breakage but the patch I exported to gerrit (https://bazel-review.googlesource.com/c/bazel/+/18590) passed Tensorflow (https://ci.bazel.io/job/bazel/job/presubmit/52/Downstream_projects/). Confirmed with jcater@ that the "newly failing" projects in the Global Tests are known issues. I think we can check this in now.
Additionally I had attempted to reproduce any tensorflow issues with this by building and testing Tensor...
***
ROLLBACK_OF=172361085
RELNOTES:None
PiperOrigin-RevId: 175821671
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/server/GrpcServerTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/server/GrpcServerTest.java | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/server/GrpcServerTest.java b/src/test/java/com/google/devtools/build/lib/server/GrpcServerTest.java index 8a036b5ede..c8cd21b0b1 100644 --- a/src/test/java/com/google/devtools/build/lib/server/GrpcServerTest.java +++ b/src/test/java/com/google/devtools/build/lib/server/GrpcServerTest.java @@ -24,33 +24,17 @@ import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.Uninterruptibles; -import com.google.devtools.build.lib.clock.BlazeClock; -import com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.LockingMode; -import com.google.devtools.build.lib.runtime.CommandExecutor; -import com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.InvocationPolicy; -import com.google.devtools.build.lib.server.CommandProtos.PingRequest; -import com.google.devtools.build.lib.server.CommandProtos.RunRequest; import com.google.devtools.build.lib.server.CommandProtos.RunResponse; -import com.google.devtools.build.lib.server.CommandServerGrpc.CommandServerBlockingStub; import com.google.devtools.build.lib.server.GrpcServerImpl.StreamType; import com.google.devtools.build.lib.testutil.Suite; import com.google.devtools.build.lib.testutil.TestSpec; import com.google.devtools.build.lib.testutil.TestThread; import com.google.devtools.build.lib.testutil.TestUtils; -import com.google.devtools.build.lib.util.io.OutErr; -import com.google.devtools.build.lib.vfs.FileSystem; -import com.google.devtools.build.lib.vfs.FileSystemUtils; -import com.google.devtools.build.lib.vfs.Path; -import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem; import com.google.protobuf.ByteString; import io.grpc.Status; import io.grpc.StatusRuntimeException; -import io.grpc.netty.NettyChannelBuilder; import io.grpc.stub.ServerCallStreamObserver; import java.nio.charset.StandardCharsets; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -350,107 +334,4 @@ public class GrpcServerTest { .setStandardOutput(ByteString.copyFrom(chunk3.getBytes(StandardCharsets.ISO_8859_1))) .build()); } - - private static class Server { - private final Path workspaceDirectory; - private final Path serverDirectory; - private final CommandExecutor commandExecutor; - private final GrpcServerImpl impl; - private final TestThread serverThread; - private final CommandServerBlockingStub clientStub; - - private Server() throws Exception { - FileSystem fs = new InMemoryFileSystem(BlazeClock.instance()); - workspaceDirectory = fs.getPath("/workspace"); - workspaceDirectory.createDirectory(); - serverDirectory = fs.getPath("/server"); - serverDirectory.createDirectory(); - Path pidfile = fs.getPath("/server/server.pid.txt"); - FileSystemUtils.writeContentAsLatin1(pidfile, "1234"); - commandExecutor = mock(CommandExecutor.class); - impl = - new GrpcServerImpl( - commandExecutor, BlazeClock.instance(), 0, workspaceDirectory, serverDirectory, 1000); - serverThread = - new TestThread() { - @Override - public void runTest() throws Exception { - impl.serve(); - } - }; - - serverThread.start(); - CommandServerBlockingStub stubCandidate = null; - boolean ok = false; - - // Wait until the server starts up. Should be reasonably quick. - for (int i = 0; i < 20; i++) { - Thread.sleep(100); - PingRequest request = PingRequest.newBuilder().setCookie(impl.getRequestCookie()).build(); - if (impl.getAddress() == null) { - continue; - } - - if (stubCandidate == null) { - stubCandidate = - CommandServerGrpc.newBlockingStub( - NettyChannelBuilder.forAddress(impl.getAddress()).usePlaintext(true).build()); - } - - try { - stubCandidate.ping(request); - ok = true; - break; - } catch (StatusRuntimeException e) { - continue; - } - } - - if (!ok) { - throw new IllegalStateException("Server did not start up in time"); - } - - clientStub = stubCandidate; - } - - private void finish() throws Exception { - impl.signalShutdown(); - serverThread.joinAndAssertState(1000); - } - } - - @Test - public void testRunCommand() throws Exception { - Server server = new Server(); - when(server.commandExecutor.exec( - any(InvocationPolicy.class), - any(List.class), - any(OutErr.class), - any(LockingMode.class), - any(String.class), - any(Long.class), - any(Optional.class))) - .thenReturn(42); - - RunRequest request = - RunRequest.newBuilder() - .setClientDescription("client") - .setCookie(server.impl.getRequestCookie()) - .build(); - - Iterator<RunResponse> result = server.clientStub.run(request); - int exitCode = -1; - while (result.hasNext()) { - exitCode = result.next().getExitCode(); - } - server.finish(); - assertThat(exitCode).isEqualTo(42); - } - - @Test - public void testIdleShutdownWhenWorkspaceDeleted() throws Exception { - Server server = new Server(); - server.workspaceDirectory.delete(); - server.serverThread.joinAndAssertState(10000); // We check the workspace dir every five seconds - } } |