aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com
diff options
context:
space:
mode:
authorGravatar Dmitry Lomov <dslomov@google.com>2017-02-16 17:00:59 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2017-02-16 17:03:12 +0000
commitbef19d10b1262e610569b4f604635eb0bea07e01 (patch)
tree7026cd938aebeca54ee6e9965922b155866fad8c /src/test/java/com
parent4b73e972d909bcd533f2f9940f95a00b9b73bdde (diff)
*** Reason for rollback *** Bisected by dmarting as a root cause of TF breakage: http://ci.bazel.io/job/TensorFlow/672/BAZEL_VERSION=HEAD,PLATFORM_NAME=linux-x86_64/console *** Original change description *** Reinstate idleness checks where the server self-terminates when it's idle and there is either too much memory pressure or the workspace directory is gone. Arguably, it should kill itself when the workspace directory is gone regardless of whether it's idle or not, but let's first get us back to a known good state, then we can think about improvements. -- PiperOrigin-RevId: 147726386 MOS_MIGRATED_REVID=147726386
Diffstat (limited to 'src/test/java/com')
-rw-r--r--src/test/java/com/google/devtools/build/lib/BUILD1
-rw-r--r--src/test/java/com/google/devtools/build/lib/server/GrpcServerTest.java111
2 files changed, 0 insertions, 112 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/BUILD b/src/test/java/com/google/devtools/build/lib/BUILD
index 78f77e2d96..7f26b3e773 100644
--- a/src/test/java/com/google/devtools/build/lib/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/BUILD
@@ -737,7 +737,6 @@ java_test(
":testutil",
"//src/main/java/com/google/devtools/build/lib:bazel-main",
"//src/main/java/com/google/devtools/build/lib:collect",
- "//src/main/java/com/google/devtools/build/lib:inmemoryfs",
"//src/main/java/com/google/devtools/build/lib:io",
"//src/main/java/com/google/devtools/build/lib:runtime",
"//src/main/java/com/google/devtools/build/lib:unix",
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 b83ad0432b..7d504d347e 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
@@ -23,32 +23,18 @@ import static org.mockito.Mockito.when;
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.runtime.BlazeCommandDispatcher.LockingMode;
-import com.google.devtools.build.lib.runtime.CommandExecutor;
-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.BlazeClock;
import com.google.devtools.build.lib.util.Preconditions;
-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.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -348,101 +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 < 50; i++) {
- Thread.sleep(200);
- 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(List.class), any(OutErr.class), any(LockingMode.class),
- any(String.class), any(Long.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
- }
}