Search in sources :

Example 16 with K8sHost

use of org.onosproject.k8snode.api.K8sHost in project onos by opennetworkinglab.

the class K8sHostCodecTest method testK8sHostEncode.

/**
 * Tests the kubernetes host encoding.
 */
@Test
public void testK8sHostEncode() {
    K8sHost host = DefaultK8sHost.builder().hostIp(IpAddress.valueOf("192.168.200.10")).state(INIT).nodeNames(ImmutableSet.of("1", "2")).build();
    ObjectNode hostJson = k8sHostCodec.encode(host, context);
    assertThat(hostJson, matchesK8sHost(host));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultK8sHost(org.onosproject.k8snode.api.DefaultK8sHost) K8sHostJsonMatcher.matchesK8sHost(org.onosproject.k8snode.codec.K8sHostJsonMatcher.matchesK8sHost) K8sHost(org.onosproject.k8snode.api.K8sHost) Test(org.junit.Test)

Example 17 with K8sHost

use of org.onosproject.k8snode.api.K8sHost in project onos by opennetworkinglab.

the class K8sHostCodecTest method getK8sHost.

private K8sHost getK8sHost(String resourceName) throws IOException {
    InputStream jsonStream = K8sHostCodecTest.class.getResourceAsStream(resourceName);
    JsonNode json = context.mapper().readTree(jsonStream);
    assertThat(json, notNullValue());
    K8sHost host = k8sHostCodec.decode((ObjectNode) json, context);
    assertThat(host, notNullValue());
    return host;
}
Also used : InputStream(java.io.InputStream) DefaultK8sHost(org.onosproject.k8snode.api.DefaultK8sHost) K8sHostJsonMatcher.matchesK8sHost(org.onosproject.k8snode.codec.K8sHostJsonMatcher.matchesK8sHost) K8sHost(org.onosproject.k8snode.api.K8sHost) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 18 with K8sHost

use of org.onosproject.k8snode.api.K8sHost in project onos by opennetworkinglab.

the class K8sHostCodecTest method testK8sHostDecode.

/**
 * Tests the kubernetes host decoding.
 */
@Test
public void testK8sHostDecode() throws IOException {
    K8sHost host = getK8sHost("K8sHost.json");
    assertEquals("192.168.200.10", host.hostIp().toString());
    assertEquals("INIT", host.state().name());
}
Also used : DefaultK8sHost(org.onosproject.k8snode.api.DefaultK8sHost) K8sHostJsonMatcher.matchesK8sHost(org.onosproject.k8snode.codec.K8sHostJsonMatcher.matchesK8sHost) K8sHost(org.onosproject.k8snode.api.K8sHost) Test(org.junit.Test)

Example 19 with K8sHost

use of org.onosproject.k8snode.api.K8sHost in project onos by opennetworkinglab.

the class K8sHostManagerTest method testUpdateHost.

/**
 * Checks if updating a host works well with proper event.
 */
@Test
public void testUpdateHost() {
    K8sHost updated = HOST_2.updateState(COMPLETE);
    target.updateHost(updated);
    validateEvents(K8S_HOST_UPDATED, K8S_HOST_COMPLETE);
}
Also used : DefaultK8sHost(org.onosproject.k8snode.api.DefaultK8sHost) K8sHost(org.onosproject.k8snode.api.K8sHost) Test(org.junit.Test)

Aggregations

K8sHost (org.onosproject.k8snode.api.K8sHost)19 DefaultK8sHost (org.onosproject.k8snode.api.DefaultK8sHost)6 Test (org.junit.Test)5 Consumes (javax.ws.rs.Consumes)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 K8sHostJsonMatcher.matchesK8sHost (org.onosproject.k8snode.codec.K8sHostJsonMatcher.matchesK8sHost)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 INDENT_OUTPUT (com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 HashSet (java.util.HashSet)2 PUT (javax.ws.rs.PUT)2 K8sHostService (org.onosproject.k8snode.api.K8sHostService)2 K8sRouterBridge (org.onosproject.k8snode.api.K8sRouterBridge)2 K8sTunnelBridge (org.onosproject.k8snode.api.K8sTunnelBridge)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)1 InputStream (java.io.InputStream)1 DELETE (javax.ws.rs.DELETE)1