Search in sources :

Example 46 with ProcessApi

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

the class ExpressionResolveOrderIT method test.

@Test
public void test() throws Exception {
    // prepare the payload
    byte[] payload = archive(ProcessIT.class.getResource("resolveOrder").toURI());
    // start the process
    ProcessApi processApi = new ProcessApi(getApiClient());
    StartProcessResponse spr = start(payload);
    assertNotNull(spr.getInstanceId());
    // wait for completion
    ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
    // get the name of the agent's log file
    assertNotNull(pir.getLogFileName());
    // check the logs
    byte[] ab = getLog(pir.getLogFileName());
    assertLog(".*sleep time: 1 hour.*", 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 47 with ProcessApi

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

the class DependenciesIT method testMaven.

@Test
public void testMaven() throws Exception {
    byte[] payload = archive(ProcessIT.class.getResource("mvnDeps").toURI());
    ProcessApi processApi = new ProcessApi(getApiClient());
    StartProcessResponse spr = start(payload);
    assertNotNull(spr.getInstanceId());
    ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
    byte[] ab = getLog(pir.getLogFileName());
    assertLog(".*Hello, Concord.*", 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 48 with ProcessApi

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

the class DispatcherIT method testUnknownFlavor.

/**
 * Tests the behaviour of the process queue dispatcher when one of
 * the required agent types is not available.
 */
@Test
public void testUnknownFlavor() throws Exception {
    byte[] payload = archive(ProcessIT.class.getResource("unknownFlavor").toURI());
    Map<String, Object> input = new HashMap<>();
    input.put("requirements.agent.type", randomString());
    input.put("archive", payload);
    StartProcessResponse unknownFlavor = start(input);
    // ---
    // as in it/server/src/test/resources/agent.conf
    input.put("requirements.agent.type", "test");
    StartProcessResponse knownFlavor = start(input);
    ProcessApi processApi = new ProcessApi(getApiClient());
    ProcessEntry pe = waitForCompletion(processApi, knownFlavor.getInstanceId());
    assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus());
    // ---
    pe = processApi.get(unknownFlavor.getInstanceId());
    assertEquals(ProcessEntry.StatusEnum.ENQUEUED, pe.getStatus());
    processApi.kill(pe.getInstanceId());
}
Also used : ProcessApi(com.walmartlabs.concord.client.ProcessApi) HashMap(java.util.HashMap) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) StartProcessResponse(com.walmartlabs.concord.client.StartProcessResponse) Test(org.junit.jupiter.api.Test)

Example 49 with ProcessApi

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

the class DockerIT method testOut.

@Test
public void testOut() throws Exception {
    byte[] payload = archive(DockerIT.class.getResource("dockerOut").toURI());
    Map<String, Object> input = new HashMap<>();
    input.put("archive", payload);
    input.put("arguments.image", ITConstants.DOCKER_ANSIBLE_IMAGE);
    StartProcessResponse spr = start(input);
    ProcessApi processApi = new ProcessApi(getApiClient());
    ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
    assertNotNull(pir.getLogFileName());
    byte[] ab = getLog(pir.getLogFileName());
    assertLog(".*!! Hello, world !!.*", ab);
    assertLog(".*DOCKER: STDERR STILL WORKS.*", ab);
}
Also used : ProcessApi(com.walmartlabs.concord.client.ProcessApi) HashMap(java.util.HashMap) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) StartProcessResponse(com.walmartlabs.concord.client.StartProcessResponse) Test(org.junit.jupiter.api.Test)

Example 50 with ProcessApi

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

the class DockerIT method testNoLogWithStdOut.

@Test
public void testNoLogWithStdOut() throws Exception {
    byte[] payload = archive(DockerIT.class.getResource("dockerNoLogWithStdOut").toURI());
    Map<String, Object> input = new HashMap<>();
    input.put("archive", payload);
    input.put("arguments.image", ITConstants.DOCKER_ANSIBLE_IMAGE);
    StartProcessResponse spr = start(input);
    ProcessApi processApi = new ProcessApi(getApiClient());
    ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
    assertNotNull(pir.getLogFileName());
    byte[] ab = getLog(pir.getLogFileName());
    assertNoLog(".*!! Hello, world .*", ab);
    assertNoLog(".*STDERR WORKS !!.*", ab);
}
Also used : ProcessApi(com.walmartlabs.concord.client.ProcessApi) HashMap(java.util.HashMap) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) StartProcessResponse(com.walmartlabs.concord.client.StartProcessResponse) Test(org.junit.jupiter.api.Test)

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