// Make sure the expected cluster arrays are sorted so we can
// use binarySearch to test for membership
for (int i = 0; i < clusters.length; i++)
Arrays.sort(clusters[i]);
TopologyInstance ti =
topologyManager.getCurrentInstance(tunnelsEnabled);
Set<Long> switches = ti.getSwitches();
for (long sw: switches) {
if (!verifiedSwitches.contains(sw)) {
int[] expectedCluster = null;
for (int j = 0; j < clusters.length; j++) {
if (Arrays.binarySearch(clusters[j], (int) sw) >= 0) {
expectedCluster = clusters[j];
break;
}
}
if (expectedCluster != null) {
Set<Long> cluster = ti.getSwitchesInOpenflowDomain(sw);
assertEquals(expectedCluster.length, cluster.size());
for (long sw2: cluster) {
assertTrue(Arrays.binarySearch(expectedCluster, (int)sw2) >= 0);
verifiedSwitches.add(sw2);
}