@Test
public void testHashSpreadUniformlyAmongSubclusters() throws YarnException {

  SubClusterId chosen;
  Map<SubClusterId, AtomicLong> counter = new HashMap<>();
  for (SubClusterId id : getActiveSubclusters().keySet()) {
    counter.put(id, new AtomicLong(0));
  }
  long jobPerSub = 100;
  ApplicationSubmissionContext applicationSubmissionContext =
      mock(ApplicationSubmissionContext.class);
  for (int i = 0; i < jobPerSub * numSubclusters; i++) {
    when(applicationSubmissionContext.getQueue()).thenReturn("queue" + i);
    chosen = ((FederationRouterPolicy) getPolicy())
        .getHomeSubcluster(applicationSubmissionContext, null);
    counter.get(chosen).addAndGet(1);
  }
  // hash spread the jobs equally among the subclusters
  for (AtomicLong a : counter.values()) {
    Assert.assertEquals(a.get(), jobPerSub);
  }
}