Search in sources :

Example 1 with PagerdutyConfig

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);
}
Also used : AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig) Receiver(io.hops.hopsworks.alerting.config.dto.Receiver) PagerdutyConfig(io.hops.hopsworks.alerting.config.dto.PagerdutyConfig) Test(org.junit.Test)

Example 2 with 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);
    });
}
Also used : PagerdutyConfig(io.hops.hopsworks.alerting.config.dto.PagerdutyConfig) Test(org.junit.Test)

Example 3 with PagerdutyConfig

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;
}
Also used : SlackConfig(io.hops.hopsworks.alerting.config.dto.SlackConfig) AlertReceiver(io.hops.hopsworks.persistence.entity.alertmanager.AlertReceiver) EmailConfig(io.hops.hopsworks.alerting.config.dto.EmailConfig) ArrayList(java.util.ArrayList) AlertReceiver(io.hops.hopsworks.persistence.entity.alertmanager.AlertReceiver) Receiver(io.hops.hopsworks.alerting.config.dto.Receiver) PagerdutyConfig(io.hops.hopsworks.alerting.config.dto.PagerdutyConfig)

Example 4 with PagerdutyConfig

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);
}
Also used : AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig) Receiver(io.hops.hopsworks.alerting.config.dto.Receiver) PagerdutyConfig(io.hops.hopsworks.alerting.config.dto.PagerdutyConfig) Test(org.junit.Test)

Aggregations

PagerdutyConfig (io.hops.hopsworks.alerting.config.dto.PagerdutyConfig)4 Receiver (io.hops.hopsworks.alerting.config.dto.Receiver)3 Test (org.junit.Test)3 AlertManagerConfig (io.hops.hopsworks.alerting.config.dto.AlertManagerConfig)2 EmailConfig (io.hops.hopsworks.alerting.config.dto.EmailConfig)1 SlackConfig (io.hops.hopsworks.alerting.config.dto.SlackConfig)1 AlertReceiver (io.hops.hopsworks.persistence.entity.alertmanager.AlertReceiver)1 ArrayList (java.util.ArrayList)1