Search in sources :

Example 1 with NodeInfo

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

the class DefaultDockerClientUnitTest method testInspectNode.

@Test
public void testInspectNode() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    // build() calls /version to check what format of header to send
    enqueueServerApiVersion("1.28");
    enqueueServerApiResponse(200, "fixtures/1.28/nodeInfo.json");
    final NodeInfo nodeInfo = dockerClient.inspectNode("24ifsmvkjbyhk");
    assertThat(nodeInfo, notNullValue());
    assertThat(nodeInfo.id(), is("24ifsmvkjbyhk"));
    assertThat(nodeInfo.status(), notNullValue());
    assertThat(nodeInfo.status().addr(), is("172.17.0.2"));
    assertThat(nodeInfo.managerStatus(), notNullValue());
    assertThat(nodeInfo.managerStatus().addr(), is("172.17.0.2:2377"));
    assertThat(nodeInfo.managerStatus().leader(), is(true));
    assertThat(nodeInfo.managerStatus().reachability(), is("reachable"));
}
Also used : NodeInfo(com.spotify.docker.client.messages.swarm.NodeInfo) Test(org.junit.Test)

Example 2 with NodeInfo

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

the class DefaultDockerClientUnitTest method testInspectNodeNonManager.

@Test
public void testInspectNodeNonManager() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.27");
    server.enqueue(new MockResponse().setResponseCode(200).addHeader("Content-Type", "application/json").setBody(fixture("fixtures/1.27/nodeInfoNonManager.json")));
    NodeInfo nodeInfo = dockerClient.inspectNode("24ifsmvkjbyhk");
    assertThat(nodeInfo, notNullValue());
    assertThat(nodeInfo.id(), is("24ifsmvkjbyhk"));
    assertThat(nodeInfo.status(), notNullValue());
    assertThat(nodeInfo.status().addr(), is("172.17.0.2"));
    assertThat(nodeInfo.managerStatus(), nullValue());
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) NodeInfo(com.spotify.docker.client.messages.swarm.NodeInfo) Test(org.junit.Test)

Example 3 with NodeInfo

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

the class DefaultDockerClientUnitTest method testInspectNonLeaderNode.

@Test
public void testInspectNonLeaderNode() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.27");
    server.enqueue(new MockResponse().setResponseCode(200).addHeader("Content-Type", "application/json").setBody(fixture("fixtures/1.27/nodeInfoNonLeader.json")));
    NodeInfo nodeInfo = dockerClient.inspectNode("24ifsmvkjbyhk");
    assertThat(nodeInfo, notNullValue());
    assertThat(nodeInfo.id(), is("24ifsmvkjbyhk"));
    assertThat(nodeInfo.status(), notNullValue());
    assertThat(nodeInfo.status().addr(), is("172.17.0.2"));
    assertThat(nodeInfo.managerStatus(), notNullValue());
    assertThat(nodeInfo.managerStatus().addr(), is("172.17.0.2:2377"));
    assertThat(nodeInfo.managerStatus().leader(), nullValue());
    assertThat(nodeInfo.managerStatus().reachability(), is("reachable"));
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) NodeInfo(com.spotify.docker.client.messages.swarm.NodeInfo) Test(org.junit.Test)

Aggregations

NodeInfo (com.spotify.docker.client.messages.swarm.NodeInfo)3 Test (org.junit.Test)3 MockResponse (okhttp3.mockwebserver.MockResponse)2