@Test
public void testAddNodeWithInvalidTopology() {

  // The last node is a node with invalid topology
  try {
    cluster.add(rackOnlyNode);
    fail("Exception should be thrown, so we should not have reached here.");
  } catch (Exception e) {
    if (!(e instanceof IllegalArgumentException)) {
      fail("Expecting IllegalArgumentException, but caught:" + e);
    }
    assertTrue(e.getMessage().contains("illegal network location"));
  }
}