### Question:
PipelinePlacementPolicy extends SCMCommonPlacementPolicy { @VisibleForTesting protected DatanodeDetails chooseNodeBasedOnRackAwareness( List<DatanodeDetails> healthyNodes, List<DatanodeDetails> excludedNodes, NetworkTopology networkTopology, DatanodeDetails anchor) { Preconditions.checkArgument(networkTopology != null); if (checkAllNodesAreEqual(networkTopology)) { return null; } List<DatanodeDetails> nodesOnOtherRack = healthyNodes.stream().filter( p -> !excludedNodes.contains(p) && !anchor.getNetworkLocation().equals(p.getNetworkLocation())) .collect(Collectors.toList()); if (!nodesOnOtherRack.isEmpty()) { return nodesOnOtherRack.get(0); } return null; } PipelinePlacementPolicy(final NodeManager nodeManager,
      final PipelineStateManager stateManager, final ConfigurationSource conf); @Override List<DatanodeDetails> chooseDatanodes(
      List<DatanodeDetails> excludedNodes, List<DatanodeDetails> favoredNodes,
      int nodesRequired, final long sizeRequired); @Override List<DatanodeDetails> getResultSet(
      int nodesRequired, List<DatanodeDetails> healthyNodes); @Override DatanodeDetails chooseNode(
      List<DatanodeDetails> healthyNodes); static final String MULTIPLE_RACK_PIPELINE_MSG; }### Answer:
@Test public void testChooseNodeBasedOnRackAwareness() { List<DatanodeDetails> healthyNodes = overWriteLocationInNodes( nodeManager.getNodes(HddsProtos.NodeState.HEALTHY)); DatanodeDetails anchor = placementPolicy.chooseNode(healthyNodes); NetworkTopology topologyWithDifRacks = createNetworkTopologyOnDifRacks(); DatanodeDetails nextNode = placementPolicy.chooseNodeBasedOnRackAwareness( healthyNodes, new ArrayList<>(PIPELINE_PLACEMENT_MAX_NODES_COUNT), topologyWithDifRacks, anchor); Assert.assertNotNull(nextNode); Assert.assertNotEquals(anchor.getNetworkLocation(), nextNode.getNetworkLocation()); }