@Test
public void testAllReplicasOnSameRack() throws Exception {

  Configuration conf = new HdfsConfiguration();
  conf.unset(DFSConfigKeys.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY);
  fsn = Mockito.mock(FSNamesystem.class);
  Mockito.doReturn(true).when(fsn).hasWriteLock();
  Mockito.doReturn(true).when(fsn).hasReadLock();
  bm = new BlockManager(fsn, fsn, conf);
  // Add nodes on two racks
  addNodes(nodes);
  // Added a new block in blocksMap and all the replicas are on the same rack
  BlockInfo blockInfo = addBlockOnNodes(1, rackA);
  // Since the network toppolgy is multi-rack, the blockHasEnoughRacks
  // should return false.
  assertFalse("Replicas for block is not stored on enough racks",
      bm.isPlacementPolicySatisfied(blockInfo));
}