Search in sources :

Example 1 with StartProcessResponse

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

the class FormsIT method testDateTimeField.

@Test
public void testDateTimeField() throws Exception {
    ApiClient apiClient = serverRule.getClient();
    // ---
    byte[] payload = archive(FormsIT.class.getResource("dateTimeField").toURI());
    Map<String, Object> input = new HashMap<>();
    input.put("archive", payload);
    ProcessApi processApi = new ProcessApi(apiClient);
    StartProcessResponse spr = serverRule.start(input);
    assertNotNull(spr.getInstanceId());
    ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED);
    // ---
    consoleRule.login(Concord.ADMIN_API_KEY);
    String url = "/#/process/" + pir.getInstanceId();
    consoleRule.navigateToRelative(url);
    WebElement wizardButton = consoleRule.waitFor(By.id("formWizardButton"));
    wizardButton.click();
    WebElement dateField = consoleRule.waitFor(By.name("dateField"));
    dateField.sendKeys("2019-09-04");
    WebElement dateTimeField = consoleRule.waitFor(By.name("dateTimeField"));
    dateTimeField.sendKeys("2019-09-04T01:05:00.000-04:00");
    // close the popup
    consoleRule.waitFor(By.id("root")).click();
    Thread.sleep(1000);
    WebElement submitButton = consoleRule.waitFor(By.id("formSubmitButton"));
    submitButton.click();
    // ---
    pir = waitForCompletion(processApi, pir.getInstanceId());
    byte[] ab = serverRule.getLog(pir.getLogFileName());
    assertLog(".*dateField=2019-09-04.*", ab);
    assertLog(".*dateTimeField=2019-09-04T05:05:00.000Z.*", ab);
}
Also used : ProcessApi(com.walmartlabs.concord.client.ProcessApi) HashMap(java.util.HashMap) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) ApiClient(com.walmartlabs.concord.ApiClient) WebElement(org.openqa.selenium.WebElement) StartProcessResponse(com.walmartlabs.concord.client.StartProcessResponse) Test(org.junit.jupiter.api.Test)

Example 2 with StartProcessResponse

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

the class DependenciesIT method testUploadAndRun.

@Test
public void testUploadAndRun() throws Exception {
    String dep = "file:///" + ITConstants.DEPENDENCIES_DIR + "/example.jar";
    String request = "{ \"entryPoint\": \"main\", \"dependencies\": [ \"" + dep + "\" ] }";
    Path tmpDir = createTempDir();
    Path requestFile = tmpDir.resolve(Constants.Files.CONFIGURATION_FILE_NAME);
    Files.write(requestFile, Collections.singletonList(request));
    Path src = Paths.get(DependenciesIT.class.getResource("deps").toURI());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ZipArchiveOutputStream zip = new ZipArchiveOutputStream(baos)) {
        IOUtils.zip(zip, src);
        IOUtils.zip(zip, tmpDir);
    }
    byte[] payload = baos.toByteArray();
    // ---
    ProcessApi processApi = new ProcessApi(getApiClient());
    StartProcessResponse spr = start(payload);
    assertNotNull(spr.getInstanceId());
    ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId());
    assertEquals(ProcessEntry.StatusEnum.FINISHED, psr.getStatus());
    // ---
    byte[] ab = getLog(psr.getLogFileName());
    assertLog(".*Hello!.*", ab);
}
Also used : Path(java.nio.file.Path) ProcessApi(com.walmartlabs.concord.client.ProcessApi) ZipArchiveOutputStream(org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StartProcessResponse(com.walmartlabs.concord.client.StartProcessResponse) Test(org.junit.jupiter.api.Test)

Example 3 with StartProcessResponse

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

the class DependencyManagerIT method test.

@Test
public void test() throws Exception {
    byte[] payload = archive(DependencyManagerIT.class.getResource("dependencyManager").toURI());
    Map<String, Object> input = new HashMap<>();
    input.put("archive", payload);
    Map<String, Object> cfg = new HashMap<>();
    cfg.put("dependencies", new String[] { "mvn://com.walmartlabs.concord.it.tasks:dependency-manager-test:" + ITConstants.PROJECT_VERSION });
    String url = "http://" + env("IT_DOCKER_HOST_ADDR", "localhost") + ":" + rule.getPort() + "/item.txt";
    cfg.put("arguments", Collections.singletonMap("url", url));
    input.put("request", cfg);
    StartProcessResponse spr = start(input);
    // ---
    ProcessApi processApi = new ProcessApi(getApiClient());
    ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED);
    byte[] ab = getLog(pir.getLogFileName());
    assertLog(".*downloading.*", ab);
    assertLog(".*using a cached copy.*", ab);
    assertLog(".*Got: Hello!.*", 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 4 with StartProcessResponse

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

the class DockerAnsibleIT method test.

@Test
public void test() throws Exception {
    byte[] payload = archive(DockerIT.class.getResource("dockerAnsible").toURI(), ITConstants.DEPENDENCIES_DIR);
    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());
    assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
    byte[] ab = getLog(pir.getLogFileName());
    assertLog(".*\"msg\": \"Hello from Docker!\".*", ab);
    // --
    File resp = processApi.downloadAttachment(pir.getInstanceId(), "ansible_stats.json");
    assertNotNull(resp);
}
Also used : ProcessApi(com.walmartlabs.concord.client.ProcessApi) HashMap(java.util.HashMap) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) File(java.io.File) StartProcessResponse(com.walmartlabs.concord.client.StartProcessResponse) Test(org.junit.jupiter.api.Test)

Example 5 with StartProcessResponse

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

the class DockerIT method testTaskSyntaxOut.

@Test
public void testTaskSyntaxOut() throws Exception {
    byte[] payload = archive(DockerIT.class.getResource("dockerTaskSyntaxOut").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)

Aggregations

StartProcessResponse (com.walmartlabs.concord.client.StartProcessResponse)57 Test (org.junit.jupiter.api.Test)56 ProcessApi (com.walmartlabs.concord.client.ProcessApi)54 ProcessEntry (com.walmartlabs.concord.client.ProcessEntry)54 HashMap (java.util.HashMap)34 URI (java.net.URI)23 Path (java.nio.file.Path)4 File (java.io.File)3 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 ApiException (com.walmartlabs.concord.ApiException)1 ProjectEntry (com.walmartlabs.concord.client.ProjectEntry)1 ProjectsApi (com.walmartlabs.concord.client.ProjectsApi)1 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)1 HashSet (java.util.HashSet)1 WebElement (org.openqa.selenium.WebElement)1