use of com.facebook.presto.server.ServerInfoResource in project presto by prestodb.
the class TestServerInfoResource method testServerShutdown.
@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerShutdown() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
Response response = serverInfoResource.updateState(NodeState.SHUTTING_DOWN);
assertEquals(response.getStatus(), 200);
NodeState nodeState = serverInfoResource.getServerState();
assertTrue(nodeState == NodeState.SHUTTING_DOWN);
}
}
use of com.facebook.presto.server.ServerInfoResource in project presto by prestodb.
the class TestServerInfoResource method testServerShutdownFollowedByActive.
@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerShutdownFollowedByActive() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
serverInfoResource.updateState(NodeState.SHUTTING_DOWN);
Response response = serverInfoResource.updateState(NodeState.ACTIVE);
assertEquals(response.getStatus(), BAD_REQUEST.getStatusCode());
assertEquals(response.getEntity(), "Cluster is shutting down");
}
}
use of com.facebook.presto.server.ServerInfoResource in project presto by prestodb.
the class TestServerInfoResource method testServerShutdownFollowedByInactive.
@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerShutdownFollowedByInactive() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
serverInfoResource.updateState(NodeState.SHUTTING_DOWN);
Response response = serverInfoResource.updateState(NodeState.INACTIVE);
assertEquals(response.getStatus(), BAD_REQUEST.getStatusCode());
assertEquals(response.getEntity(), "Cluster is shutting down");
}
}
use of com.facebook.presto.server.ServerInfoResource in project presto by prestodb.
the class TestServerInfoResource method testServerInactiveThenActive.
@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerInactiveThenActive() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
Response response = serverInfoResource.updateState(NodeState.INACTIVE);
assertEquals(response.getStatus(), 200);
NodeState nodeState = serverInfoResource.getServerState();
assertTrue(nodeState == NodeState.INACTIVE);
response = serverInfoResource.updateState(NodeState.ACTIVE);
assertEquals(response.getStatus(), 200);
nodeState = serverInfoResource.getServerState();
assertTrue(nodeState == NodeState.ACTIVE);
}
}
use of com.facebook.presto.server.ServerInfoResource in project presto by prestodb.
the class TestServerInfoResource method testServerActive.
@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerActive() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
NodeState nodeState = serverInfoResource.getServerState();
assertTrue(nodeState == NodeState.ACTIVE);
}
}
Aggregations