Search in sources :

Example 56 with ProcessApi

use of com.walmartlabs.concord.client.ProcessApi in project concord by walmartlabs.

the class TimeoutHandlingIT method testTimeout.

@Test
public void testTimeout() throws Exception {
    ProcessApi processApi = new ProcessApi(getApiClient());
    // prepare the payload
    byte[] payload = archive(ProcessIT.class.getResource("timeoutHandling").toURI());
    // start the process and wait for it to fail
    StartProcessResponse spr = start(payload);
    waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.TIMED_OUT);
    // find the child processes
    ProcessEntry child = waitForChild(processApi, spr.getInstanceId(), ProcessEntry.KindEnum.TIMEOUT_HANDLER, ProcessEntry.StatusEnum.FINISHED);
    // check the handler's logs for expected messages
    byte[] ab = getLog(child.getLogFileName());
    assertLog(".*projectInfo: \\{.*orgName=Default.*\\}.*", ab);
    assertLog(".*processInfo: \\{.*sessionKey=.*\\}.*", ab);
    assertLog(".*initiator: \\{.*username=.*\\}.*", ab);
}
Also used : ProcessApi(com.walmartlabs.concord.client.ProcessApi) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) StartProcessResponse(com.walmartlabs.concord.client.StartProcessResponse) Test(org.junit.jupiter.api.Test)

Example 57 with ProcessApi

use of com.walmartlabs.concord.client.ProcessApi in project concord by walmartlabs.

the class ResourceIT method test.

private void test(String resource, String pattern) throws Exception {
    URI dir = ResourceIT.class.getResource(resource).toURI();
    byte[] payload = archive(dir);
    ProcessApi processApi = new ProcessApi(getApiClient());
    StartProcessResponse spr = start(payload);
    ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
    assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
    byte[] ab = getLog(pir.getLogFileName());
    assertLog(pattern, ab);
}
Also used : ProcessApi(com.walmartlabs.concord.client.ProcessApi) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) URI(java.net.URI) StartProcessResponse(com.walmartlabs.concord.client.StartProcessResponse)

Example 58 with ProcessApi

use of com.walmartlabs.concord.client.ProcessApi in project concord by walmartlabs.

the class AbstractGeneralTriggerIT method waitProcesses.

protected Map<ProcessEntry.StatusEnum, ProcessEntry> waitProcesses(String orgName, String projectName, ProcessEntry.StatusEnum first, ProcessEntry.StatusEnum... more) throws Exception {
    ProcessApi processApi = new ProcessApi(getApiClient());
    List<ProcessEntry> processes;
    while (true) {
        processes = processApi.list(orgName, projectName, null, null, null, null, null, null, null, null, null);
        if (processes.size() == 1 + (more != null ? more.length : 0)) {
            break;
        }
        Thread.sleep(1000);
    }
    Map<ProcessEntry.StatusEnum, ProcessEntry> ps = new HashMap<>();
    for (ProcessEntry p : processes) {
        ProcessEntry pir = waitForStatus(processApi, p.getInstanceId(), first, more);
        ProcessEntry pe = ps.put(pir.getStatus(), pir);
        if (pe != null) {
            throw new RuntimeException("already got process with '" + pe.getStatus() + "' status, id: " + pe.getInstanceId());
        }
    }
    return ps;
}
Also used : ProcessApi(com.walmartlabs.concord.client.ProcessApi) HashMap(java.util.HashMap) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry)

Aggregations

ProcessApi (com.walmartlabs.concord.client.ProcessApi)58 ProcessEntry (com.walmartlabs.concord.client.ProcessEntry)55 StartProcessResponse (com.walmartlabs.concord.client.StartProcessResponse)54 Test (org.junit.jupiter.api.Test)54 HashMap (java.util.HashMap)34 URI (java.net.URI)23 File (java.io.File)4 Path (java.nio.file.Path)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 UUID (java.util.UUID)2 ZipArchiveOutputStream (org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream)2 ConcordProcess (ca.ibodrov.concord.testcontainers.ConcordProcess)1 Payload (ca.ibodrov.concord.testcontainers.Payload)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ApiClient (com.walmartlabs.concord.ApiClient)1 ApiException (com.walmartlabs.concord.ApiException)1 FormListEntry (com.walmartlabs.concord.client.FormListEntry)1 FormSubmitResponse (com.walmartlabs.concord.client.FormSubmitResponse)1 ITUtils.randomString (com.walmartlabs.concord.it.common.ITUtils.randomString)1 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)1