use of io.hops.hopsworks.alerting.config.dto.PagerdutyConfig in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testAddPagerdutyToReceiver.
@Test
public void testAddPagerdutyToReceiver() throws AlertManagerConfigUpdateException, AlertManagerDuplicateEntryException, AlertManagerNoSuchElementException, AlertManagerConfigReadException, AlertManagerResponseException, AlertManagerServerException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
PagerdutyConfig pagerdutyConfig = new PagerdutyConfig().withServiceKey("serviceKey");
Receiver receiver = new Receiver("team-DB-pager");
AlertManagerConfig config = alertManagerConfigController.addPagerdutyToReceiver("team-DB-pager", pagerdutyConfig);
alertManagerConfigController.writeAndReload(config);
AlertManagerConfig alertManagerConfig = this.alertManagerConfigController.read();
int index = alertManagerConfig.getReceivers().indexOf(receiver);
Receiver updatedReceiver = alertManagerConfig.getReceivers().get(index);
assert updatedReceiver.getPagerdutyConfigs().contains(pagerdutyConfig);
}
use of io.hops.hopsworks.alerting.config.dto.PagerdutyConfig in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testAddPagerdutyToReceiverValidation.
@Test
public void testAddPagerdutyToReceiverValidation() throws AlertManagerResponseException, AlertManagerServerException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
PagerdutyConfig pagerdutyConfig = new PagerdutyConfig().withServiceKey("serviceKey");
pagerdutyConfig.setRoutingKey("routingKey");
Assert.assertThrows(IllegalArgumentException.class, () -> {
alertManagerConfigController.addPagerdutyToReceiver("team-DB-pager", pagerdutyConfig);
});
PagerdutyConfig pagerdutyConfig1 = new PagerdutyConfig().withServiceKey("<team-DB-key>");
Assert.assertThrows(AlertManagerDuplicateEntryException.class, () -> {
alertManagerConfigController.addPagerdutyToReceiver("team-DB-pager", pagerdutyConfig1);
});
}
use of io.hops.hopsworks.alerting.config.dto.PagerdutyConfig in project hopsworks by logicalclocks.
the class TestAlertManagerConfigTimer method createReceivers.
private List<AlertReceiver> createReceivers() throws JsonProcessingException {
List<AlertReceiver> alertReceivers = new ArrayList<>();
List<EmailConfig> emailConfigs = new ArrayList<>();
emailConfigs.add(new EmailConfig("test@hopsworks.ai"));
List<SlackConfig> slackConfigs = new ArrayList<>();
slackConfigs.add(new SlackConfig().withChannel("@test"));
List<PagerdutyConfig> pagerdutyConfigs = new ArrayList<>();
pagerdutyConfigs.add(new PagerdutyConfig("serviceKey"));
alertReceivers.add(createAlertReceiver(1, new Receiver("global-receiver__email").withEmailConfigs(emailConfigs), AlertType.GLOBAL_ALERT_EMAIL));
alertReceivers.add(createAlertReceiver(2, new Receiver("project1__slack").withSlackConfigs(slackConfigs), AlertType.PROJECT_ALERT));
alertReceivers.add(createAlertReceiver(3, new Receiver("global-receiver__slack").withSlackConfigs(slackConfigs), AlertType.GLOBAL_ALERT_SLACK));
alertReceivers.add(createAlertReceiver(4, new Receiver("project1__pagerduty").withPagerdutyConfigs(pagerdutyConfigs), AlertType.PROJECT_ALERT));
return alertReceivers;
}
use of io.hops.hopsworks.alerting.config.dto.PagerdutyConfig in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testRemovePagerdutyFromReceiver.
@Test
public void testRemovePagerdutyFromReceiver() throws AlertManagerConfigReadException, AlertManagerNoSuchElementException, AlertManagerConfigUpdateException, AlertManagerResponseException, AlertManagerServerException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
PagerdutyConfig pagerdutyConfig = new PagerdutyConfig().withServiceKey("<team-DB-key>");
Receiver receiver = new Receiver("team-DB-pager");
AlertManagerConfig alertManagerConfig = this.alertManagerConfigController.read();
int index = alertManagerConfig.getReceivers().indexOf(receiver);
Receiver updatedReceiver = alertManagerConfig.getReceivers().get(index);
assert updatedReceiver.getPagerdutyConfigs().contains(pagerdutyConfig);
AlertManagerConfig config = alertManagerConfigController.removePagerdutyFromReceiver("team-DB-pager", pagerdutyConfig);
alertManagerConfigController.writeAndReload(config);
alertManagerConfig = this.alertManagerConfigController.read();
index = alertManagerConfig.getReceivers().indexOf(receiver);
updatedReceiver = alertManagerConfig.getReceivers().get(index);
assert !updatedReceiver.getPagerdutyConfigs().contains(pagerdutyConfig);
}
Aggregations