@Test public void testInsufficientResources() { control.replay(); IHostAttributes hostA = hostAttributes(HOST_A, host(HOST_A), rack(RACK_A)); assertVetoes( makeTask(DEFAULT_CPUS + 1, DEFAULT_RAM + 1, DEFAULT_DISK + 1), hostA, CPU.veto(1), DISK.veto(1), RAM.veto(1)); assertVetoes(makeTask(DEFAULT_CPUS + 1, DEFAULT_RAM, DEFAULT_DISK), hostA, CPU.veto(1)); assertVetoes(makeTask(DEFAULT_CPUS, DEFAULT_RAM + 1, DEFAULT_DISK), hostA, RAM.veto(1)); assertVetoes(makeTask(DEFAULT_CPUS, DEFAULT_RAM, DEFAULT_DISK + 1), hostA, DISK.veto(1)); }
@Test public void testVetoScaling() { control.replay(); int maxScore = VetoType.INSUFFICIENT_RESOURCES.getScore(); assertEquals((int) (maxScore * 1.0 / CPU.getRange()), CPU.veto(1).getScore()); assertEquals(maxScore, CPU.veto(CPU.getRange() * 10).getScore()); assertEquals((int) (maxScore * 2.0 / RAM.getRange()), RAM.veto(2).getScore()); assertEquals((int) (maxScore * 200.0 / DISK.getRange()), DISK.veto(200).getScore()); }