Search in sources :

Example 1 with TestStatusResponse

use of org.apache.hive.ptest.api.response.TestStatusResponse in project hive by apache.

the class ExecutionController method testStatus.

@RequestMapping(value = "/testStatus", method = RequestMethod.POST)
@ResponseBody
public TestStatusResponse testStatus(@RequestBody TestStopRequest stopRequest, BindingResult result) {
    String testHandle = stopRequest.getTestHandle();
    Test test = mTests.get(testHandle);
    if (result.hasErrors() || Strings.nullToEmpty(stopRequest.getTestHandle()).trim().isEmpty() || test == null) {
        return new TestStatusResponse(Status.illegalArgument());
    }
    return new TestStatusResponse(Status.ok(), test.toTestStatus());
}
Also used : PTest(org.apache.hive.ptest.execution.PTest) TestStatusResponse(org.apache.hive.ptest.api.response.TestStatusResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with TestStatusResponse

use of org.apache.hive.ptest.api.response.TestStatusResponse in project hive by apache.

the class PTestClient method testTailLog.

public boolean testTailLog(String testHandle) throws Exception {
    testHandle = Strings.nullToEmpty(testHandle).trim();
    if (testHandle.isEmpty()) {
        throw new IllegalArgumentException("TestHandle is required");
    }
    TestStatusRequest statusRequest = new TestStatusRequest(testHandle);
    TestStatusResponse statusResponse;
    do {
        TimeUnit.SECONDS.sleep(5);
        statusResponse = post(statusRequest, true);
    } while (Status.isPending(statusResponse.getTestStatus().getStatus()));
    long offset = 0;
    do {
        long length = statusResponse.getTestStatus().getLogFileLength();
        if (length > offset) {
            offset = printLogs(testHandle, offset);
        } else {
            TimeUnit.SECONDS.sleep(5);
        }
        statusResponse = post(statusRequest, true);
    } while (Status.isInProgress(statusResponse.getTestStatus().getStatus()));
    while (offset < statusResponse.getTestStatus().getLogFileLength()) {
        offset = printLogs(testHandle, offset);
    }
    Status.assertOKOrFailed(statusResponse.getTestStatus().getStatus());
    return Status.isOK(statusResponse.getTestStatus().getStatus());
}
Also used : TestStatusResponse(org.apache.hive.ptest.api.response.TestStatusResponse) TestStatusRequest(org.apache.hive.ptest.api.request.TestStatusRequest)

Aggregations

TestStatusResponse (org.apache.hive.ptest.api.response.TestStatusResponse)2 TestStatusRequest (org.apache.hive.ptest.api.request.TestStatusRequest)1 PTest (org.apache.hive.ptest.execution.PTest)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1