use of io.hops.hopsworks.alerting.config.dto.Route in project hopsworks by logicalclocks.
the class ConfigUtil method getRoute.
public static Route getRoute(FeatureGroupAlert alert) {
if (alert.getAlertType().isGlobal()) {
return getRoute(alert.getAlertType());
}
Map<String, String> match = getMatch(alert);
List<String> groupBy = new ArrayList<>();
groupBy.add(Constants.LABEL_PROJECT);
groupBy.add(Constants.LABEL_FEATURE_GROUP);
groupBy.add(Constants.LABEL_STATUS);
return new Route(alert.getReceiver().getName()).withContinue(true).withMatch(match).withGroupBy(groupBy);
}
use of io.hops.hopsworks.alerting.config.dto.Route in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testAddRoute.
@Test
public void testAddRoute() throws AlertManagerConfigUpdateException, AlertManagerDuplicateEntryException, AlertManagerResponseException, AlertManagerServerException, AlertManagerConfigReadException, AlertManagerNoSuchElementException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
Map<String, String> matches = new HashMap<>();
matches.put("project", "project3");
Route route = new Route("team-X-mails").withMatch(matches);
AlertManagerConfig config = alertManagerConfigController.addRoute(route);
alertManagerConfigController.writeAndReload(config);
AlertManagerConfig alertManagerConfig = this.alertManagerConfigController.read();
assert alertManagerConfig.getRoute().getRoutes().contains(route);
}
use of io.hops.hopsworks.alerting.config.dto.Route in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testUpdateRouteDuplicate.
@Test
public void testUpdateRouteDuplicate() throws AlertManagerResponseException, AlertManagerServerException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
Map<String, String> matches = new HashMap<>();
matches.put("severity", "critical");
Route routeToUpdate = new Route("team-Y-mails").withMatch(matches);
matches = new HashMap<>();
matches.put("project", "project1");
Route route = new Route("slack_general").withMatch(matches);
Assert.assertThrows(AlertManagerDuplicateEntryException.class, () -> {
alertManagerConfigController.updateRoute(routeToUpdate, route);
});
}
use of io.hops.hopsworks.alerting.config.dto.Route in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testUpdateRoute.
@Test
public void testUpdateRoute() throws AlertManagerConfigUpdateException, AlertManagerDuplicateEntryException, AlertManagerNoSuchElementException, AlertManagerConfigReadException, AlertManagerServerException, AlertManagerResponseException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
Map<String, String> matches = new HashMap<>();
matches.put("severity", "critical");
Route routeToUpdate = new Route("team-Y-mails").withMatch(matches);
matches = new HashMap<>();
matches.put("project", "project3");
Route route = new Route("team-Y-mails").withMatch(matches);
AlertManagerConfig config = alertManagerConfigController.updateRoute(routeToUpdate, route);
alertManagerConfigController.writeAndReload(config);
AlertManagerConfig alertManagerConfig = this.alertManagerConfigController.read();
assert alertManagerConfig.getRoute().getRoutes().contains(route);
}
use of io.hops.hopsworks.alerting.config.dto.Route in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testRemoveRoute.
@Test
public void testRemoveRoute() throws AlertManagerConfigReadException, AlertManagerConfigUpdateException, AlertManagerResponseException, AlertManagerServerException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
Map<String, String> matches = new HashMap<>();
matches.put("project", "project1");
Route route = new Route("slack_general").withMatch(matches);
AlertManagerConfig alertManagerConfig = this.alertManagerConfigController.read();
assert alertManagerConfig.getRoute().getRoutes().contains(route);
AlertManagerConfig config = alertManagerConfigController.removeRoute(route);
alertManagerConfigController.writeAndReload(config);
alertManagerConfig = this.alertManagerConfigController.read();
assert !alertManagerConfig.getRoute().getRoutes().contains(route);
}
Aggregations