@Test(expectedExceptions = RuntimeException.class,
    expectedExceptionsMessageRegExp = ".*amount of " + Constants.GPUS + ".*requested exceeds.*")
public void testValidateTonyConfTooManyGpusAcrossAllTasks() {

  Configuration conf = new Configuration();
  conf.setInt(TonyConfigurationKeys.getResourceKey(Constants.WORKER_JOB_NAME, Constants.GPUS), 1);
  conf.setInt(TonyConfigurationKeys.getResourceKey(Constants.PS_JOB_NAME, Constants.GPUS), 1);
  conf.setInt(TonyConfigurationKeys.getInstancesKey(Constants.WORKER_JOB_NAME), 3);
  conf.setInt(TonyConfigurationKeys.getInstancesKey(Constants.PS_JOB_NAME), 3);
  conf.setInt(TonyConfigurationKeys.getMaxTotalResourceKey(Constants.GPUS), 5);
  TonyClient.validateTonyConf(conf);
}