@Test
public void testScaleUpForActiveAndPhasedOutInstanceGroups() {

    AgentInstanceGroup activeInstanceGroup = createPartition("activeInstanceGroup", InstanceGroupLifecycleState.Active, "r4.16xlarge", 0, 0, 10);
    AgentInstanceGroup phasedOutInstanceGroup = createPartition("phasedOutInstanceGroup", InstanceGroupLifecycleState.PhasedOut, "r4.16xlarge", 0, 0, 10);
    List<AgentInstanceGroup> instanceGroups = Lists.newArrayList(phasedOutInstanceGroup, activeInstanceGroup);
    when(agentManagementService.getInstanceGroups()).thenReturn(instanceGroups);
    when(agentManagementService.getAgentInstances("activeInstanceGroup")).thenReturn(Collections.emptyList());
    when(agentManagementService.getAgentInstances("phasedOutInstanceGroup")).thenReturn(Collections.emptyList());
    when(agentManagementService.scaleUp(eq("activeInstanceGroup"), anyInt())).thenReturn(Completable.complete());
    testScheduler.advanceTimeBy(6, TimeUnit.MINUTES);
    ClusterAgentAutoScaler clusterAgentAutoScaler = new ClusterAgentAutoScaler(titusRuntime, configuration,
            agentManagementService, v3JobOperations, schedulingService, testScheduler);
    clusterAgentAutoScaler.doAgentScaling().await();
    verify(agentManagementService, times(1)).scaleUp(eq("activeInstanceGroup"), eq(5));
    verify(agentManagementService, times(0)).scaleUp(eq("phasedOutInstanceGroup"), anyInt());
}