ClusterConfig config = new ClusterConfig(3, 1, 2);
List<Integer> topology = Arrays.asList(new Integer[] { 0, 1, 2 });
JSONObject obj = config.getTopology(topology);
config.validate();
System.out.println(obj.toString(4));
JSONArray partitions = obj.getJSONArray("partitions");
// despite 3 hosts, should only have 1 partition with k-safety of 2
assertEquals(1, partitions.length());
// All the execution sites should have the same relative index
for (int ii = 0; ii < partitions.length(); ii++) {
JSONObject partition = partitions.getJSONObject(ii);
assertEquals(0, partition.getInt("partition_id"));
JSONArray replicas = partition.getJSONArray("replicas");
assertEquals(3, replicas.length());
HashSet<Integer> replicasContents = new HashSet<Integer>();
for (int zz = 0; zz < replicas.length(); zz++) {
replicasContents.add(replicas.getInt(zz));
}
assertTrue(replicasContents.contains(0));
assertTrue(replicasContents.contains(1));
assertTrue(replicasContents.contains(2));