Search in sources :

Example 1 with NodeRosterHostsApi

use of com.walmartlabs.concord.client.NodeRosterHostsApi 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)

Aggregations

ConcordProcess (ca.ibodrov.concord.testcontainers.ConcordProcess)1 Payload (ca.ibodrov.concord.testcontainers.Payload)1 HostEntry (com.walmartlabs.concord.client.HostEntry)1 NodeRosterHostsApi (com.walmartlabs.concord.client.NodeRosterHostsApi)1 ProcessEntry (com.walmartlabs.concord.client.ProcessEntry)1 Utils.resourceToString (com.walmartlabs.concord.it.runtime.v2.Utils.resourceToString)1 Test (org.junit.jupiter.api.Test)1