Initial support for multi kubernetes clusters for k8s nodes
Change-Id: I6ca132898f8e157e0583de38a637fdc135f21d6f
diff --git a/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeJsonMatcher.java b/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeJsonMatcher.java
index b953f54..816ca76 100644
--- a/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeJsonMatcher.java
+++ b/apps/k8s-node/app/src/test/java/org/onosproject/k8snode/codec/K8sNodeJsonMatcher.java
@@ -28,8 +28,10 @@
private final K8sNode node;
+ private static final String CLUSTER_NAME = "clusterName";
private static final String HOSTNAME = "hostname";
private static final String TYPE = "type";
+ private static final String SEGMENT_ID = "segmentId";
private static final String MANAGEMENT_IP = "managementIp";
private static final String DATA_IP = "dataIp";
private static final String INTEGRATION_BRIDGE = "integrationBridge";
@@ -45,6 +47,14 @@
@Override
protected boolean matchesSafely(JsonNode jsonNode, Description description) {
+ // check cluster name
+ String jsonClusterName = jsonNode.get(CLUSTER_NAME).asText();
+ String clusterName = node.clusterName();
+ if (!jsonClusterName.equals(clusterName)) {
+ description.appendText("cluster name was " + jsonClusterName);
+ return false;
+ }
+
// check hostname
String jsonHostname = jsonNode.get(HOSTNAME).asText();
String hostname = node.hostname();
@@ -61,6 +71,16 @@
return false;
}
+ // check segment ID
+ JsonNode jsonSegmentId = jsonNode.get(SEGMENT_ID);
+ if (jsonSegmentId != null) {
+ int segmentId = jsonSegmentId.asInt();
+ if (segmentId != node.segmentId()) {
+ description.appendText("segment ID was " + segmentId);
+ return false;
+ }
+ }
+
// check management IP
String jsonMgmtIp = jsonNode.get(MANAGEMENT_IP).asText();
String mgmtIp = node.managementIp().toString();