Search in sources :

Example 61 with ProcessEntry

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

the class ThrowExceptionTaskIT method testThrowExceptionMessage.

@Test
public void testThrowExceptionMessage() throws Exception {
    URI uri = ThrowExceptionTaskIT.class.getResource("throwExceptionMessage").toURI();
    byte[] payload = archive(uri);
    // start the process
    ProcessApi processApi = new ProcessApi(getApiClient());
    StartProcessResponse spr = start(payload);
    // wait for completion
    ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
    assertEquals(ProcessEntry.StatusEnum.FAILED, pir.getStatus());
    // check logs
    byte[] ab = getLog(pir.getLogFileName());
    assertLog(".*Kaboom!! Error occurred.*", 2, 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) Test(org.junit.jupiter.api.Test)

Example 62 with ProcessEntry

use of com.walmartlabs.concord.client.ProcessEntry 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 63 with ProcessEntry

use of com.walmartlabs.concord.client.ProcessEntry 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 64 with ProcessEntry

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

the class NodeRosterIT method test.

/**
 * Tests various methods of the 'noderoster' plugin.
 */
@Test
public void test() throws Exception {
    // run the Ansible flow first to get some data
    String concordYml = resourceToString(NodeRosterIT.class.getResource("noderoster/ansible.yml")).replaceAll("PROJECT_VERSION", ITConstants.PROJECT_VERSION);
    ConcordProcess proc = concord.processes().start(new Payload().concordYml(concordYml).resource("playbook.yml", NodeRosterIT.class.getResource("noderoster/playbook.yml")));
    ProcessEntry pe = expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
    // wait for the Node Roster data to appear
    NodeRosterHostsApi hostsApi = new NodeRosterHostsApi(concord.apiClient());
    while (true) {
        List<HostEntry> l = hostsApi.list(null, null, pe.getInstanceId(), null, 10, 0);
        if (!l.isEmpty()) {
            break;
        }
    }
    // run the Node Roster flow next to test the plugin
    concordYml = resourceToString(ProcessIT.class.getResource("noderoster/noderoster.yml")).replaceAll("PROJECT_VERSION", ITConstants.PROJECT_VERSION);
    proc = concord.processes().start(new Payload().concordYml(concordYml));
    expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
    proc.assertLog(".*hostsWithArtifacts:.*ok=true.*");
    proc.assertLog(".*ansible_dns=.*");
    proc.assertLog(".*deployedOnHost:.*ok=true.*");
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) NodeRosterHostsApi(com.walmartlabs.concord.client.NodeRosterHostsApi) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) Payload(ca.ibodrov.concord.testcontainers.Payload) HostEntry(com.walmartlabs.concord.client.HostEntry) Utils.resourceToString(com.walmartlabs.concord.it.runtime.v2.Utils.resourceToString) Test(org.junit.jupiter.api.Test)

Example 65 with ProcessEntry

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

the class ProcessIT method testMetadataWithWithItems.

@Test
public void testMetadataWithWithItems() throws Exception {
    ConcordProcess proc = concord.processes().start(new Payload().archive(resource("processMetadataWithItems")));
    ProcessEntry pe = expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
    assertNotNull(pe.getMeta());
    assertEquals("c", pe.getMeta().get("var"));
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) Payload(ca.ibodrov.concord.testcontainers.Payload) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessEntry (com.walmartlabs.concord.client.ProcessEntry)70 Test (org.junit.jupiter.api.Test)68 ProcessApi (com.walmartlabs.concord.client.ProcessApi)55 StartProcessResponse (com.walmartlabs.concord.client.StartProcessResponse)54 HashMap (java.util.HashMap)35 URI (java.net.URI)23 ConcordProcess (ca.ibodrov.concord.testcontainers.ConcordProcess)15 Payload (ca.ibodrov.concord.testcontainers.Payload)15 Path (java.nio.file.Path)4 ITUtils.randomString (com.walmartlabs.concord.it.common.ITUtils.randomString)3 Utils.resourceToString (com.walmartlabs.concord.it.runtime.v2.Utils.resourceToString)3 File (java.io.File)3 FormListEntry (com.walmartlabs.concord.client.FormListEntry)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 UUID (java.util.UUID)2 ZipArchiveOutputStream (org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream)2 ApiClient (com.walmartlabs.concord.ApiClient)1 FormSubmitResponse (com.walmartlabs.concord.client.FormSubmitResponse)1 HostEntry (com.walmartlabs.concord.client.HostEntry)1 NodeRosterHostsApi (com.walmartlabs.concord.client.NodeRosterHostsApi)1