@Test
public void testLocality() throws Exception {
NetworkTopology nt = new NetworkTopology();
Node r1n1 = new NodeBase("/default/rack1/node1");
nt.add(r1n1);
Node r1n2 = new NodeBase("/default/rack1/node2");
nt.add(r1n2);
Node r2n3 = new NodeBase("/default/rack2/node3");
nt.add(r2n3);
LOG.debug("r1n1 parent: " + r1n1.getParent() + "\n" +
"r1n2 parent: " + r1n2.getParent() + "\n" +
"r2n3 parent: " + r2n3.getParent());
// Same host
assertEquals(0, JobInProgress.getMatchingLevelForNodes(r1n1, r1n1, 3));
// Same rack
assertEquals(1, JobInProgress.getMatchingLevelForNodes(r1n1, r1n2, 3));