Search in sources :

Example 1 with Payload

use of ca.ibodrov.concord.testcontainers.Payload in project concord-plugins by walmartlabs.

the class TerraformTaskIT method test.

private void test(String concordYmlSource) throws Exception {
    String orgName = "org_" + randomString();
    concord.organizations().create(orgName);
    String projectName = "project_" + randomString();
    concord.projects().create(orgName, projectName);
    byte[] terraform_file = readToBytes("it/main.tf");
    Payload payload = new Payload().org(orgName).project(projectName).file("main.tf", terraform_file).file("mydir/main.tf", terraform_file).file("mydir/nested/main.tf", terraform_file).concordYml(new String(readToBytes(concordYmlSource)).replace("%%version%%", CURRENT_VERSION));
    ConcordProcess proc = concord.processes().start(payload);
    proc.waitForStatus(ProcessEntry.StatusEnum.FINISHED);
    proc.assertLog(".*FINISHED.*");
    proc.assertLogAtLeast(".*No changes\\..*", 3);
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) Payload(ca.ibodrov.concord.testcontainers.Payload) Utils.randomString(ca.ibodrov.concord.testcontainers.Utils.randomString)

Example 2 with Payload

use of ca.ibodrov.concord.testcontainers.Payload in project concord by walmartlabs.

the class ProcessIT method testTags.

@Test
public void testTags() throws Exception {
    byte[] archive = archive(ProcessIT.class.getResource("example").toURI());
    ConcordProcess parent = concord.processes().start(new Payload().archive(archive));
    // ---
    parent.expectStatus(StatusEnum.FINISHED);
    // ---
    archive = archive(ProcessIT.class.getResource("tags").toURI());
    Payload payload = new Payload().archive(archive).parent(parent.instanceId());
    ConcordProcess child = concord.processes().start(payload);
    // ---
    child.expectStatus(StatusEnum.FINISHED);
    // ---
    List<ProcessEntry> l = parent.subprocesses("abc");
    assertTrue(l.isEmpty());
    l = parent.subprocesses("test");
    assertEquals(1, l.size());
    ProcessEntry e = l.get(0);
    assertEquals(child.instanceId(), e.getInstanceId());
    // ---
    l = concord.processes().list(ProcessListQuery.builder().addTags("xyz").build());
    assertTrue(l.isEmpty());
    l = concord.processes().list(ProcessListQuery.builder().addTags("IT").build());
    assertEquals(1, l.size());
    e = l.get(0);
    assertEquals(child.instanceId(), e.getInstanceId());
}
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)

Example 3 with Payload

use of ca.ibodrov.concord.testcontainers.Payload in project concord by walmartlabs.

the class ConcordTaskIT method testSuspendParentProcess.

@Test
public void testSuspendParentProcess() throws Exception {
    Payload payload = new Payload().archive(resource("concord/concordTaskSuspendParentProcess"));
    ConcordProcess proc = concord.processes().start(payload);
    expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
    // ---
    proc.assertLog(".*Hello, Concord!.*");
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) Payload(ca.ibodrov.concord.testcontainers.Payload) Test(org.junit.jupiter.api.Test)

Example 4 with Payload

use of ca.ibodrov.concord.testcontainers.Payload in project concord by walmartlabs.

the class ConcordTaskIT method testForkSuspend.

@Test
public void testForkSuspend() throws Exception {
    String nameVar = "name_" + randomString();
    String orgName = "org_" + randomString();
    concord.organizations().create(orgName);
    String projectName = "project_" + randomString();
    concord.projects().create(orgName, projectName);
    Payload payload = new Payload().archive(resource("concord/concordTaskForkSuspend")).org(orgName).project(projectName).arg("name", nameVar);
    ConcordProcess proc = concord.processes().start(payload);
    // ---
    expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
    // ---
    proc.assertLog(".*\\{varFromFork=Hello, " + nameVar + "}.*");
    proc.assertLog(".*\\{varFromFork=Bye, " + nameVar + "}.*");
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) Payload(ca.ibodrov.concord.testcontainers.Payload) ITUtils.randomString(com.walmartlabs.concord.it.common.ITUtils.randomString) Test(org.junit.jupiter.api.Test)

Example 5 with Payload

use of ca.ibodrov.concord.testcontainers.Payload in project concord by walmartlabs.

the class ConcordTaskIT method testExternalApiToken.

/**
 * start process with api key
 */
@Test
public void testExternalApiToken() throws Exception {
    String username = "user_" + randomString();
    UsersApi usersApi = new UsersApi(concord.apiClient());
    usersApi.createOrUpdate(new CreateUserRequest().setUsername(username).setType(CreateUserRequest.TypeEnum.LOCAL));
    ApiKeysApi apiKeysApi = new ApiKeysApi(concord.apiClient());
    CreateApiKeyResponse cakr = apiKeysApi.create(new CreateApiKeyRequest().setUsername(username));
    // ---
    Payload payload = new Payload().archive(resource("concord/concordTaskApiKey")).arg("myApiKey", cakr.getKey());
    ConcordProcess proc = concord.processes().start(payload);
    // ---
    expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
    // ---
    proc.assertLog(".*Hello, Concord!. From: .*" + username + ".*");
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) Payload(ca.ibodrov.concord.testcontainers.Payload) ITUtils.randomString(com.walmartlabs.concord.it.common.ITUtils.randomString) Test(org.junit.jupiter.api.Test)

Aggregations

ConcordProcess (ca.ibodrov.concord.testcontainers.ConcordProcess)70 Payload (ca.ibodrov.concord.testcontainers.Payload)70 Test (org.junit.jupiter.api.Test)68 ITUtils.randomString (com.walmartlabs.concord.it.common.ITUtils.randomString)22 ProcessEntry (com.walmartlabs.concord.client.ProcessEntry)15 Utils.resourceToString (com.walmartlabs.concord.it.runtime.v2.Utils.resourceToString)9 FormListEntry (com.walmartlabs.concord.client.FormListEntry)7 FormSubmitResponse (com.walmartlabs.concord.client.FormSubmitResponse)6 ProcessCheckpointEntry (com.walmartlabs.concord.client.ProcessCheckpointEntry)5 ApiClient (com.walmartlabs.concord.ApiClient)3 HashMap (java.util.HashMap)3 Utils.randomString (ca.ibodrov.concord.testcontainers.Utils.randomString)1 HostEntry (com.walmartlabs.concord.client.HostEntry)1 NodeRosterHostsApi (com.walmartlabs.concord.client.NodeRosterHostsApi)1 ProcessApi (com.walmartlabs.concord.client.ProcessApi)1 ProcessEventEntry (com.walmartlabs.concord.client.ProcessEventEntry)1 ProcessEventsApi (com.walmartlabs.concord.client.ProcessEventsApi)1 Path (java.nio.file.Path)1 Map (java.util.Map)1 MimeMessage (javax.mail.internet.MimeMessage)1