Search in sources :

Example 1 with EnginePlugin

use of com.spotify.docker.client.messages.swarm.EnginePlugin in project docker-client by spotify.

the class DefaultDockerClientTest method testListNodes.

@Test
public void testListNodes() throws Exception {
    requireDockerApiVersionAtLeast("1.24", "swarm support");
    List<Node> nodes = sut.listNodes();
    assertThat(nodes.size(), greaterThanOrEqualTo(1));
    Node nut = nodes.get(0);
    Date now = new Date();
    assertThat(nut.id(), allOf(notNullValue(), not("")));
    assertThat(nut.version().index(), allOf(notNullValue(), greaterThan(0L)));
    assertThat(nut.createdAt(), allOf(notNullValue(), lessThanOrEqualTo(now)));
    assertThat(nut.updatedAt(), allOf(notNullValue(), lessThanOrEqualTo(now)));
    NodeSpec specs = nut.spec();
    assertThat(specs, notNullValue());
    // Can be null if not set
    assertThat(specs.name(), is(anything()));
    // Can be null if not set
    assertThat(specs.labels(), is(anything()));
    assertThat(specs.role(), isIn(new String[] { "manager", "worker" }));
    assertThat(specs.availability(), isIn(new String[] { "active", "pause", "drain" }));
    NodeDescription desc = nut.description();
    assertThat(desc.hostname(), allOf(notNullValue(), not("")));
    assertThat(desc.platform(), notNullValue());
    assertThat(desc.platform().architecture(), allOf(notNullValue(), not("")));
    assertThat(desc.platform().os(), allOf(notNullValue(), not("")));
    assertThat(desc.resources(), notNullValue());
    assertThat(desc.resources().memoryBytes(), greaterThan(0L));
    assertThat(desc.resources().nanoCpus(), greaterThan(0L));
    EngineConfig engine = desc.engine();
    assertThat(engine, notNullValue());
    assertThat(engine.engineVersion(), allOf(notNullValue(), not("")));
    assertThat(engine.labels(), is(anything()));
    assertThat(engine.plugins().size(), greaterThanOrEqualTo(0));
    for (EnginePlugin plugin : engine.plugins()) {
        assertThat(plugin.type(), allOf(notNullValue(), not("")));
        assertThat(plugin.name(), allOf(notNullValue(), not("")));
    }
}
Also used : NodeDescription(com.spotify.docker.client.messages.swarm.NodeDescription) EnginePlugin(com.spotify.docker.client.messages.swarm.EnginePlugin) Node(com.spotify.docker.client.messages.swarm.Node) NodeSpec(com.spotify.docker.client.messages.swarm.NodeSpec) Long.toHexString(java.lang.Long.toHexString) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) EngineConfig(com.spotify.docker.client.messages.swarm.EngineConfig) Date(java.util.Date) Test(org.junit.Test)

Aggregations

EngineConfig (com.spotify.docker.client.messages.swarm.EngineConfig)1 EnginePlugin (com.spotify.docker.client.messages.swarm.EnginePlugin)1 Node (com.spotify.docker.client.messages.swarm.Node)1 NodeDescription (com.spotify.docker.client.messages.swarm.NodeDescription)1 NodeSpec (com.spotify.docker.client.messages.swarm.NodeSpec)1 Long.toHexString (java.lang.Long.toHexString)1 Date (java.util.Date)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)1 Test (org.junit.Test)1