Search in sources :

Example 36 with RunRecord

use of co.cask.cdap.proto.RunRecord in project cdap by caskdata.

the class LogHandlerTestRun method testLogsRunId.

private void testLogsRunId(String appId, String entityType, String entityId, String namespace, String format, List<String> suppress) throws Exception {
    ProgramId programId = new NamespaceId(namespace).app(appId).program(ProgramType.valueOfCategoryName(entityType), entityId);
    RunRecord runRecord = mockLogReader.getRunRecord(programId);
    int expectedEvents = 20;
    if (runRecord.getStatus() == ProgramRunStatus.RUNNING || runRecord.getStatus() == ProgramRunStatus.SUSPENDED) {
        expectedEvents = 30;
    }
    long startTime = MockLogReader.getMockTimeSecs(0);
    long stopTime = MockLogReader.getMockTimeSecs(100);
    String nextNoFromUrl;
    if (suppress.isEmpty()) {
        nextNoFromUrl = String.format("apps/%s/%s/%s/runs/%s/logs?format=%s&start=%s&stop=%s", appId, entityType, entityId, runRecord.getPid(), format, startTime, stopTime);
    } else {
        String fieldsToSuppress = getSuppressStr(suppress);
        nextNoFromUrl = String.format("apps/%s/%s/%s/runs/%s/logs?format=%s&start=%s&stop=%s&suppress=%s", appId, entityType, entityId, runRecord.getPid(), format, startTime, stopTime, fieldsToSuppress);
    }
    HttpResponse response = doGet(getVersionedAPIPath(nextNoFromUrl, namespace));
    verifyLogs(response, entityId, format, true, true, true, expectedEvents, 20, suppress);
}
Also used : RunRecord(co.cask.cdap.proto.RunRecord) HttpResponse(org.apache.http.HttpResponse) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ProgramId(co.cask.cdap.proto.id.ProgramId)

Aggregations

RunRecord (co.cask.cdap.proto.RunRecord)36 Test (org.junit.Test)19 ProgramId (co.cask.cdap.proto.id.ProgramId)16 HttpResponse (org.apache.http.HttpResponse)13 File (java.io.File)10 IOException (java.io.IOException)10 Id (co.cask.cdap.proto.Id)8 ApplicationManager (co.cask.cdap.test.ApplicationManager)8 WorkflowManager (co.cask.cdap.test.WorkflowManager)7 Category (org.junit.experimental.categories.Category)6 WorkflowTokenDetail (co.cask.cdap.proto.WorkflowTokenDetail)5 ApplicationId (co.cask.cdap.proto.id.ApplicationId)5 NamespaceId (co.cask.cdap.proto.id.NamespaceId)5 TimeoutException (java.util.concurrent.TimeoutException)5 ConflictException (co.cask.cdap.common.ConflictException)4 NotFoundException (co.cask.cdap.common.NotFoundException)4 KeyValueTable (co.cask.cdap.api.dataset.lib.KeyValueTable)3 WorkflowNodeStateDetail (co.cask.cdap.proto.WorkflowNodeStateDetail)3 AppRequest (co.cask.cdap.proto.artifact.AppRequest)3 Table (co.cask.cdap.api.dataset.table.Table)2