use of com.spotify.docker.client.messages.swarm.NodeSpec in project docker-client by spotify.
the class DefaultDockerClientUnitTest method testListNodes.
@Test
public void testListNodes() throws Exception {
final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
enqueueServerApiVersion("1.28");
server.enqueue(new MockResponse().setResponseCode(200).addHeader("Content-Type", "application/json").setBody(fixture("fixtures/1.28/listNodes.json")));
final List<Node> nodes = dockerClient.listNodes();
assertThat(nodes.size(), equalTo(1));
final Node node = nodes.get(0);
assertThat(node, notNullValue());
assertThat(node.id(), is("24ifsmvkjbyhk"));
assertThat(node.version().index(), is(8L));
final NodeSpec nodeSpec = node.spec();
assertThat(nodeSpec.name(), is("my-node"));
assertThat(nodeSpec.role(), is("manager"));
assertThat(nodeSpec.availability(), is("active"));
assertThat(nodeSpec.labels().keySet(), contains("foo"));
final NodeDescription desc = node.description();
assertThat(desc.hostname(), is("bf3067039e47"));
assertThat(desc.platform().architecture(), is("x86_64"));
assertThat(desc.platform().os(), is("linux"));
assertThat(desc.resources().memoryBytes(), is(8272408576L));
assertThat(desc.resources().nanoCpus(), is(4000000000L));
final EngineConfig engine = desc.engine();
assertThat(engine.engineVersion(), is("17.04.0"));
assertThat(engine.labels().keySet(), contains("foo"));
assertThat(engine.plugins().size(), equalTo(4));
assertThat(node.status(), notNullValue());
assertThat(node.status().addr(), is("172.17.0.2"));
assertThat(node.managerStatus(), notNullValue());
assertThat(node.managerStatus().addr(), is("172.17.0.2:2377"));
assertThat(node.managerStatus().leader(), is(true));
assertThat(node.managerStatus().reachability(), is("reachable"));
}
Aggregations