[ONOS-7926] Implement IPAM service to allocate IP for Kubernetes POD
Change-Id: I32fd1fffb41ec728d0be092ac5a8f555179e7a9e
diff --git a/apps/k8s-networking/app/src/test/java/org/onosproject/k8snetworking/codec/K8sIpamCodecTest.java b/apps/k8s-networking/app/src/test/java/org/onosproject/k8snetworking/codec/K8sIpamCodecTest.java
index 8335867..95914eb 100644
--- a/apps/k8s-networking/app/src/test/java/org/onosproject/k8snetworking/codec/K8sIpamCodecTest.java
+++ b/apps/k8s-networking/app/src/test/java/org/onosproject/k8snetworking/codec/K8sIpamCodecTest.java
@@ -76,7 +76,7 @@
*/
@Test
public void testK8sIpamEncode() {
- K8sIpam ipam = new DefaultK8sIpam(
+ K8sIpam ipam = new DefaultK8sIpam("network-1-10.10.10.10",
IpAddress.valueOf("10.10.10.10"), "network-1");
ObjectNode nodeJson = k8sIpamCodec.encode(ipam, context);
diff --git a/apps/k8s-networking/app/src/test/java/org/onosproject/k8snetworking/codec/K8sIpamJsonMatcher.java b/apps/k8s-networking/app/src/test/java/org/onosproject/k8snetworking/codec/K8sIpamJsonMatcher.java
index 81bbf10..3934ea9 100644
--- a/apps/k8s-networking/app/src/test/java/org/onosproject/k8snetworking/codec/K8sIpamJsonMatcher.java
+++ b/apps/k8s-networking/app/src/test/java/org/onosproject/k8snetworking/codec/K8sIpamJsonMatcher.java
@@ -27,6 +27,7 @@
private final K8sIpam ipam;
+ private static final String IPAM_ID = "ipamId";
private static final String IP_ADDRESS = "ipAddress";
private static final String NETWORK_ID = "networkId";
@@ -37,6 +38,14 @@
@Override
protected boolean matchesSafely(JsonNode jsonNode, Description description) {
+ // check IPAM ID
+ String jsonIpamId = jsonNode.get(IPAM_ID).asText();
+ String ipamId = ipam.ipamId();
+ if (!jsonIpamId.equals(ipamId)) {
+ description.appendText("IPAM ID was " + jsonIpamId);
+ return false;
+ }
+
// check IP address
String jsonIpAddress = jsonNode.get(IP_ADDRESS).asText();
String ipAddress = ipam.ipAddress().toString();