Search in sources :

Example 1 with ResultWithQueryId

use of com.facebook.presto.tests.ResultWithQueryId in project presto by prestodb.

the class TestTaskInfoResource method testGetTaskInfo.

@Test
public void testGetTaskInfo() {
    String sql = "SELECT * FROM tpch.sf1.customer WHERE tpch.sf1.customer.nationkey = 1";
    ResultWithQueryId<MaterializedResult> result = queryRunner.executeWithQueryId(queryRunner.getDefaultSession(), sql);
    QueryId queryId = result.getQueryId();
    Optional<StageInfo> stageInfo = server.getQueryManager().getFullQueryInfo(queryId).getOutputStage();
    if (stageInfo.isPresent()) {
        Stream<TaskInfo> latestTaskInfo = stageInfo.get().getAllStages().stream().flatMap(stage -> stage.getLatestAttemptExecutionInfo().getTasks().stream());
        Iterable<TaskInfo> iterableTaskInfo = latestTaskInfo::iterator;
        for (TaskInfo taskInfo : iterableTaskInfo) {
            URI taskURI = taskUri("v1/taskInfo/", taskInfo.getTaskId().toString());
            Request taskInfoRequest = prepareGet().setUri(taskURI).build();
            TaskInfo responseTaskInfo = client.execute(taskInfoRequest, createJsonResponseHandler(jsonCodec(TaskInfo.class)));
            compareTasks(taskInfo, responseTaskInfo);
        }
    } else {
        fail("StageInfo not present");
    }
}
Also used : TaskInfo(com.facebook.presto.execution.TaskInfo) StageInfo(com.facebook.presto.execution.StageInfo) ResultWithQueryId(com.facebook.presto.tests.ResultWithQueryId) QueryId(com.facebook.presto.spi.QueryId) Request(com.facebook.airlift.http.client.Request) MaterializedResult(com.facebook.presto.testing.MaterializedResult) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 2 with ResultWithQueryId

use of com.facebook.presto.tests.ResultWithQueryId in project presto by prestodb.

the class TestStageInfo method testGetStageWithStageId.

@Test
public void testGetStageWithStageId() {
    String sql = "SELECT nationkey AS nationkey, count(*) AS count FROM tpch.sf1.supplier GROUP BY nationkey";
    ResultWithQueryId<MaterializedResult> result = queryRunner.executeWithQueryId(queryRunner.getDefaultSession(), sql);
    QueryId queryId = result.getQueryId();
    Optional<StageInfo> stageInfo = server.getQueryManager().getFullQueryInfo(queryId).getOutputStage();
    if (stageInfo.isPresent()) {
        List<StageInfo> allStages = stageInfo.get().getAllStages();
        for (StageInfo expectedStage : allStages) {
            Optional<StageInfo> actualStage = stageInfo.get().getStageWithStageId(expectedStage.getStageId());
            if (!actualStage.isPresent()) {
                fail("StageInfo with id " + expectedStage.getStageId() + "not found");
            }
            assertEquals(expectedStage.getStageId(), actualStage.get().getStageId());
        }
    }
}
Also used : QueryId(com.facebook.presto.spi.QueryId) ResultWithQueryId(com.facebook.presto.tests.ResultWithQueryId) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Aggregations

QueryId (com.facebook.presto.spi.QueryId)2 MaterializedResult (com.facebook.presto.testing.MaterializedResult)2 ResultWithQueryId (com.facebook.presto.tests.ResultWithQueryId)2 Test (org.testng.annotations.Test)2 Request (com.facebook.airlift.http.client.Request)1 StageInfo (com.facebook.presto.execution.StageInfo)1 TaskInfo (com.facebook.presto.execution.TaskInfo)1 URI (java.net.URI)1