use of com.facebook.presto.server.testing.TestingPrestoServer in project presto by prestodb.
the class DistributedQueryRunner method isConnectionVisibleToAllNodes.
private boolean isConnectionVisibleToAllNodes(ConnectorId connectorId) {
for (TestingPrestoServer server : servers) {
server.refreshNodes();
Set<Node> activeNodesWithConnector = server.getActiveNodesWithConnector(connectorId);
if (activeNodesWithConnector.size() != servers.size()) {
return false;
}
}
return true;
}
use of com.facebook.presto.server.testing.TestingPrestoServer 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.testing.TestingPrestoServer 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.testing.TestingPrestoServer in project presto by prestodb.
the class TestMemoryWorkerCrash method closeWorker.
private void closeWorker() throws Exception {
int nodeCount = getNodeCount();
DistributedQueryRunner queryRunner = (DistributedQueryRunner) getQueryRunner();
TestingPrestoServer worker = queryRunner.getServers().stream().filter(server -> !server.isCoordinator()).findAny().orElseThrow(() -> new IllegalStateException("No worker nodes"));
worker.close();
waitForNodes(nodeCount - 1);
}
use of com.facebook.presto.server.testing.TestingPrestoServer in project presto by prestodb.
the class TestMemoryManager method testReservedPoolDisabledMultiCoordinator.
@Test(timeOut = 240_000, expectedExceptions = ExecutionException.class, expectedExceptionsMessageRegExp = ".*Query killed because the cluster is out of memory. Please try again in a few minutes.")
public void testReservedPoolDisabledMultiCoordinator() throws Exception {
Map<String, String> rmProperties = ImmutableMap.<String, String>builder().put("experimental.reserved-pool-enabled", "false").put("resource-manager.memory-pool-fetch-interval", "10ms").put("resource-manager.query-heartbeat-interval", "10ms").build();
Map<String, String> coordinatorProperties = ImmutableMap.<String, String>builder().put("query.low-memory-killer.delay", "5s").put("query.low-memory-killer.policy", "total-reservation").build();
Map<String, String> extraProperties = ImmutableMap.<String, String>builder().put("experimental.reserved-pool-enabled", "false").build();
try (DistributedQueryRunner queryRunner = createQueryRunner(rmProperties, coordinatorProperties, extraProperties, 2)) {
// Reserve all the memory
QueryId fakeQueryId = new QueryId("fake");
for (TestingPrestoServer server : queryRunner.getServers()) {
List<MemoryPool> memoryPools = server.getLocalMemoryManager().getPools();
assertEquals(memoryPools.size(), 1, "Only general pool should exist");
assertTrue(memoryPools.get(0).tryReserve(fakeQueryId, "test", memoryPools.get(0).getMaxBytes()));
}
List<Future<?>> queryFutures = new ArrayList<>();
for (int i = 0; i < 2; i++) {
int coordinator = i;
Thread.sleep(500);
queryFutures.add(executor.submit(() -> queryRunner.execute(coordinator, "SELECT COUNT(*), clerk FROM orders GROUP BY clerk")));
}
// Wait for one of the queries to die
waitForQueryToBeKilled(queryRunner);
// Reserved pool shouldn't exist on the workers and allocation should have been done in the general pool
for (TestingPrestoServer server : queryRunner.getServers()) {
Optional<MemoryPool> reserved = server.getLocalMemoryManager().getReservedPool();
MemoryPool general = server.getLocalMemoryManager().getGeneralPool();
assertFalse(reserved.isPresent());
assertTrue(general.getReservedBytes() > 0);
// Free up the entire pool
general.free(fakeQueryId, "test", general.getMaxBytes());
assertTrue(general.getFreeBytes() > 0);
}
for (Future<?> query : queryFutures) {
query.get();
}
}
}
Aggregations