@Test public void thereIsAHostDown() throws GangliaException { hostList.add(largeHostDown); notifier.updateThresholdsInfo(); Map<String, List<AbstractThreshold>> t = notifier.getSurpassedThresholds(); assertTrue(t.containsKey(largeHostDown.getIp())); assertEquals("host_down", t.get(largeHostDown.getIp()).get(0).getName()); }
@Test public void shouldNotAddEqualThresholds() { assertEquals(0, notifier.getThresholdSize()); SingleThreshold threshold1 = new SingleThreshold("load_one", SingleThreshold.MAX, 3); SingleThreshold threshold2 = new SingleThreshold("load_one", SingleThreshold.MAX, 3); notifier.addThreshold("default", threshold1); notifier.addThreshold("default", threshold2); assertEquals(1, notifier.getThresholdSize()); }
@Test public void thereAreSurpassedThreshold() throws GangliaException { SingleThreshold t = new SingleThreshold("load_one", SingleThreshold.MAX, 0); notifier.addThreshold("default", t); notifier.updateThresholdsInfo(); assertTrue(notifier.thereAreSurpassedThresholds()); }
@Test public void shouldEvaluateMultipleThresholdsInSingleHost() throws GangliaException { SingleThreshold threshold1 = new SingleThreshold("load_one", SingleThreshold.MIN, 1.5); SingleThreshold threshold2 = new SingleThreshold("mem_total", SingleThreshold.MAX, 50000); notifier.addThreshold("default", threshold1); notifier.addThreshold("small", threshold2); notifier.updateThresholdsInfo(); Map<String, List<AbstractThreshold>> list1 = notifier.getSurpassedThresholds(); assertEquals("surpassed thresholds", 1, list1.size()); List<AbstractThreshold> list = list1.get(extraLargeHost.getIp()); assertEquals("hosts with surpassed thresholds", 1, list.size()); }
@Test public void shouldNotifySingleThresholdInMultipleHosts() throws GangliaException { SingleThreshold threshold = new SingleThreshold("load_one", SingleThreshold.MAX, 0.8); notifier.addThreshold("default", threshold); notifier.updateThresholdsInfo(); Map<String, List<AbstractThreshold>> list1 = notifier.getSurpassedThresholds(); System.out.println(list1); assertEquals(2, list1.size()); List<AbstractThreshold> list; list = list1.get(extraLargeHost.getIp()); assertTrue(list.contains(threshold)); list = list1.get(mediumHost.getIp()); assertTrue(list.contains(threshold)); }
@Test public void shouldAddOneDoubleThreshold() { DoubleThreshold threshold = new DoubleThreshold("load_five", DoubleThreshold.BETWEEN, 1, 1.1); notifier.addThreshold("default", threshold); assertEquals(1, notifier.getThresholdSize()); }
@Test public void shouldAddOneSingleThreshold() { SingleThreshold threshold = new SingleThreshold("load_one", SingleThreshold.MAX, 3); notifier.addThreshold("default", threshold); assertEquals(1, notifier.getThresholdSize()); }