@Test
public void instanceOnlyRunsGpuTasks() {

    AgentInstance instance = createAgentInstance(INSTANCE_GROUP_ID);
    when(agentManagementService.findAgentInstance(INSTANCE_ID)).thenReturn(Optional.of(instance));
    AgentInstanceGroup agentInstanceGroup = createAgentInstanceGroup(InstanceGroupLifecycleState.Active, Tier.Flex, 1);
    when(agentManagementService.findInstanceGroup(INSTANCE_GROUP_ID)).thenReturn(Optional.of(agentInstanceGroup));
    JobDescriptor<BatchJobExt> descriptor = oneTaskBatchJobDescriptor()
            .but(jd -> jd.getContainer().but(c -> c.toBuilder().withContainerResources(
                    c.getContainerResources().toBuilder().withGpu(0).build()
            )));
    Job<BatchJobExt> gpuBatchJob = JobGenerator.batchJobs(descriptor).getValue();
    TaskRequest taskRequest = createTaskRequest(gpuBatchJob);
    Result result = agentManagementConstraint.evaluate(taskRequest,
            createVirtualMachineCurrentStateMock(INSTANCE_ID), mock(TaskTrackerState.class));
    assertThat(result.isSuccessful()).isFalse();
    assertThat(result.getFailureReason()).isEqualToIgnoringCase("Instance group does not run non gpu tasks");
}