Search in sources :

Example 16 with Route

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);
}
Also used : ArrayList(java.util.ArrayList) Route(io.hops.hopsworks.alerting.config.dto.Route)

Example 17 with Route

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

Example 18 with 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);
    });
}
Also used : HashMap(java.util.HashMap) Route(io.hops.hopsworks.alerting.config.dto.Route) Test(org.junit.Test)

Example 19 with 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);
}
Also used : AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig) HashMap(java.util.HashMap) Route(io.hops.hopsworks.alerting.config.dto.Route) Test(org.junit.Test)

Example 20 with 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);
}
Also used : AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig) HashMap(java.util.HashMap) Route(io.hops.hopsworks.alerting.config.dto.Route) Test(org.junit.Test)

Aggregations

Route (io.hops.hopsworks.alerting.config.dto.Route)35 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)10 Produces (javax.ws.rs.Produces)10 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)9 ApiOperation (io.swagger.annotations.ApiOperation)9 ArrayList (java.util.ArrayList)9 AlertManagerConfigCtrlCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigCtrlCreateException)8 AlertManagerConfigReadException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigReadException)8 AlertException (io.hops.hopsworks.exceptions.AlertException)8 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)7 AlertManagerClientCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)7 AlertManagerConfigUpdateException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigUpdateException)7 AlertManagerDuplicateEntryException (io.hops.hopsworks.alerting.exceptions.AlertManagerDuplicateEntryException)7 AlertManagerNoSuchElementException (io.hops.hopsworks.alerting.exceptions.AlertManagerNoSuchElementException)7 HashMap (java.util.HashMap)7 Consumes (javax.ws.rs.Consumes)7 Path (javax.ws.rs.Path)7 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)6 Project (io.hops.hopsworks.persistence.entity.project.Project)6 Test (org.junit.Test)6