Search in sources :

Example 26 with ProcessApi

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

the class SecretsTaskIT method test.

@Test
public void test() throws Exception {
    String secretName = "secret_" + randomString();
    byte[] payload = archive(SecretsTaskIT.class.getResource("secretsTask").toURI());
    Map<String, Object> input = new HashMap<>();
    input.put("archive", payload);
    input.put("arguments.secretName", secretName);
    StartProcessResponse spr = start(input);
    ProcessApi processApi = new ProcessApi(getApiClient());
    ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
    assertNotNull(pir.getLogFileName());
    byte[] bytes = getLog(pir.getLogFileName());
    // System.out.println(new String(bytes));
    assertLog(".* Delete secret2.*", bytes);
}
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 27 with ProcessApi

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

the class VariablesInjectionIT method test.

@Test
public void test() throws Exception {
    byte[] payload = archive(VariablesInjectionIT.class.getResource("inject").toURI(), ITConstants.DEPENDENCIES_DIR);
    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);
    assertLog(".*Hello, world!!!.*", ab);
    assertLog(".*Hello, world. \\(from method param\\).*", ab);
    assertLog(".*Hello, world. \\(from injected var\\).*", 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 28 with ProcessApi

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

the class SuspendIT method test.

@Test
public void test() throws Exception {
    URI dir = SuspendIT.class.getResource("suspend").toURI();
    byte[] payload = archive(dir);
    // ---
    ProcessApi processApi = new ProcessApi(getApiClient());
    StartProcessResponse spr = start(payload);
    // ---
    ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED);
    byte[] ab = getLog(pir.getLogFileName());
    assertLog(".*aaaa.*", ab);
    // ---
    String testValue = "test#" + randomString();
    Map<String, Object> args = Collections.singletonMap("testValue", testValue);
    Map<String, Object> req = Collections.singletonMap(Constants.Request.ARGUMENTS_KEY, args);
    processApi.resume(spr.getInstanceId(), "ev1", null, req);
    pir = waitForCompletion(processApi, spr.getInstanceId());
    assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
    waitForLog(pir.getLogFileName(), ".*bbbb.*");
    waitForLog(pir.getLogFileName(), ".*" + Pattern.quote(testValue) + ".*");
}
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 29 with ProcessApi

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

the class ThrowExceptionTaskIT method testThrowException.

@Test
public void testThrowException() throws Exception {
    URI uri = ThrowExceptionTaskIT.class.getResource("throwExceptionTask").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(".*Catch that!.*", 3, 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 30 with ProcessApi

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

the class ProcessContainerIT method test.

@Test
public void test() throws Exception {
    Path src = Paths.get(DockerIT.class.getResource("processContainer").toURI());
    Path dst = IOUtils.createTempDir("test");
    IOUtils.copy(src, dst);
    Path concordYml = dst.resolve("concord.yml");
    String s = new String(Files.readAllBytes(concordYml));
    s = s.replaceAll("%%image%%", ITConstants.DOCKER_ANSIBLE_IMAGE);
    Files.write(concordYml, s.getBytes());
    // ---
    byte[] payload = archive(dst.toUri());
    StartProcessResponse spr = start(payload);
    // --
    ProcessApi processApi = new ProcessApi(getApiClient());
    ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
    assertNotNull(pir.getLogFileName());
    assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
    byte[] ab = getLog(pir.getLogFileName());
    assertLog(".*Hello from Docker!.*", ab);
}
Also used : Path(java.nio.file.Path) ProcessApi(com.walmartlabs.concord.client.ProcessApi) 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