Search in sources :

Example 1 with NotificationImpl

use of org.graylog2.notifications.NotificationImpl in project graylog2-server by Graylog2.

the class IndexerClusterCheckerThreadTest method ignoresNonDataNodes.

@Test
public void ignoresNonDataNodes() throws Exception {
    final Set<NodeDiskUsageStats> nodeDiskUsageStats = mockNodeDiskUsageStats(EnumSet.of(MASTER_ELIGIBLE, TRANSFORM));
    when(cluster.getDiskUsageStats()).thenReturn(nodeDiskUsageStats);
    when(cluster.getClusterAllocationDiskSettings()).thenReturn(buildThresholdTriggeredClusterAllocationDiskSettings(ES_NODE_DISK_WATERMARK_LOW, WatermarkSettings.SettingsType.ABSOLUTE));
    Notification notification = new NotificationImpl();
    when(notificationService.buildNow()).thenReturn(notification);
    when(notificationService.isFirst(ES_NODE_DISK_WATERMARK_LOW)).thenReturn(true);
    indexerClusterCheckerThread.checkDiskUsage();
    verify(notificationService, never()).publishIfFirst(any());
}
Also used : NotificationImpl(org.graylog2.notifications.NotificationImpl) NodeDiskUsageStats(org.graylog2.indexer.cluster.health.NodeDiskUsageStats) Notification(org.graylog2.notifications.Notification) Test(org.junit.Test)

Example 2 with NotificationImpl

use of org.graylog2.notifications.NotificationImpl in project graylog2-server by Graylog2.

the class IndexerClusterCheckerThreadTest method notificationCreated.

private void notificationCreated(Notification.Type notificationType, WatermarkSettings.SettingsType watermarkSettingsType) throws Exception {
    Set<NodeDiskUsageStats> nodeDiskUsageStats = mockNodeDiskUsageStats();
    when(cluster.getDiskUsageStats()).thenReturn(nodeDiskUsageStats);
    if (watermarkSettingsType == WatermarkSettings.SettingsType.ABSOLUTE) {
        when(cluster.getClusterAllocationDiskSettings()).thenReturn(buildThresholdTriggeredClusterAllocationDiskSettings(notificationType, WatermarkSettings.SettingsType.ABSOLUTE));
    } else {
        when(cluster.getClusterAllocationDiskSettings()).thenReturn(buildThresholdTriggeredClusterAllocationDiskSettings(notificationType, WatermarkSettings.SettingsType.PERCENTAGE));
    }
    when(notificationService.isFirst(notificationType)).thenReturn(true);
    Notification notification = new NotificationImpl();
    when(notificationService.buildNow()).thenReturn(notification);
    indexerClusterCheckerThread.checkDiskUsage();
    ArgumentCaptor<Notification> argument = ArgumentCaptor.forClass(Notification.class);
    verify(notificationService, times(1)).publishIfFirst(argument.capture());
    Notification publishedNotification = argument.getValue();
    assertThat(publishedNotification.getType()).isEqualTo(notificationType);
}
Also used : NotificationImpl(org.graylog2.notifications.NotificationImpl) NodeDiskUsageStats(org.graylog2.indexer.cluster.health.NodeDiskUsageStats) Notification(org.graylog2.notifications.Notification)

Aggregations

NodeDiskUsageStats (org.graylog2.indexer.cluster.health.NodeDiskUsageStats)2 Notification (org.graylog2.notifications.Notification)2 NotificationImpl (org.graylog2.notifications.NotificationImpl)2 Test (org.junit.Test)1