@Test
public void spreadsKeyspaceScheduling() throws Exception {

  context.config = TestRepairConfiguration.defaultConfigBuilder()
      .withAutoScheduling(TestRepairConfiguration.defaultAutoSchedulingConfigBuilder()
          .thatIsEnabled()
          .withTimeBeforeFirstSchedule(DELAY_BEFORE_SCHEDULE)
          .withScheduleSpreadPeriod(Duration.ofHours(6))
          .build())
      .build();
  context.storage.addCluster(cluster);
  when(jmxProxy.getKeyspaces()).thenReturn(Lists.newArrayList("keyspace1", "keyspace2", "keyspace3", "keyspace4"));
  when(jmxProxy.getTablesForKeyspace("keyspace1")).thenReturn(
          Sets.newHashSet(Table.builder().withName("sometable").withCompactionStrategy(STCS).build()));
  when(jmxProxy.getTablesForKeyspace("keyspace2")).thenReturn(
          Sets.newHashSet(Table.builder().withName("sometable").withCompactionStrategy(STCS).build()));
  when(jmxProxy.getTablesForKeyspace("keyspace4")).thenReturn(
          Sets.newHashSet(Table.builder().withName("sometable").withCompactionStrategy(STCS).build()));
  clusterRepairAuto.scheduleRepairs(cluster);
  assertThatClusterRepairSchedules(context.storage.getRepairSchedulesForCluster(cluster.getName()))
      .hasScheduleCount(3)
      .repairScheduleForKeyspace("keyspace1")
      .hasNextActivationDateCloseTo(timeOfFirstSchedule())
      .andThen()
      .repairScheduleForKeyspace("keyspace2")
      .hasNextActivationDateCloseTo(timeOfFirstSchedule().plusHours(6))
      .andThen()
      .repairScheduleForKeyspace("keyspace4")
      .hasNextActivationDateCloseTo(timeOfFirstSchedule().plusHours(12));
}