Search in sources :

Example 16 with ClusterEventBus

use of org.graylog2.events.ClusterEventBus in project graylog2-server by Graylog2.

the class MongoIndexSetServiceTest method setUp.

@Before
public void setUp() throws Exception {
    clusterEventBus = new ClusterEventBus();
    clusterConfigService = new ClusterConfigServiceImpl(objectMapperProvider, mongoRule.getMongoConnection(), nodeId, new ChainingClassLoader(getClass().getClassLoader()), clusterEventBus);
    indexSetService = new MongoIndexSetService(mongoRule.getMongoConnection(), objectMapperProvider, streamService, clusterConfigService, clusterEventBus);
}
Also used : ClusterConfigServiceImpl(org.graylog2.cluster.ClusterConfigServiceImpl) ClusterEventBus(org.graylog2.events.ClusterEventBus) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader) Before(org.junit.Before)

Example 17 with ClusterEventBus

use of org.graylog2.events.ClusterEventBus in project graylog2-server by Graylog2.

the class ClusterEventPeriodicalTest method runHandlesAutoValueCorrectly.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void runHandlesAutoValueCorrectly() throws Exception {
    final DebugEvent event = DebugEvent.create("Node ID", TIME, "test");
    DBObject dbObject = new BasicDBObjectBuilder().add("timestamp", TIME.getMillis()).add("producer", "TEST-PRODUCER").add("consumers", Collections.emptyList()).add("event_class", DebugEvent.class.getCanonicalName()).add("payload", objectMapper.convertValue(event, Map.class)).get();
    final DBCollection collection = mongoConnection.getDatabase().getCollection(ClusterEventPeriodical.COLLECTION_NAME);
    collection.save(dbObject);
    assertThat(collection.count()).isEqualTo(1L);
    clusterEventPeriodical.run();
    assertThat(collection.count()).isEqualTo(1L);
    @SuppressWarnings("unchecked") final List<String> consumers = (List<String>) collection.findOne().get("consumers");
    assertThat(consumers).containsExactly(nodeId.toString());
    verify(serverEventBus, times(1)).post(event);
    verify(clusterEventBus, never()).post(event);
}
Also used : DBCollection(com.mongodb.DBCollection) DebugEvent(org.graylog2.system.debug.DebugEvent) BasicDBObjectBuilder(com.mongodb.BasicDBObjectBuilder) List(java.util.List) DBObject(com.mongodb.DBObject) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 IndexSetConfig (org.graylog2.indexer.indexset.IndexSetConfig)6 Before (org.junit.Before)6 ClusterEventBus (org.graylog2.events.ClusterEventBus)5 ChainingClassLoader (org.graylog2.shared.plugins.ChainingClassLoader)5 Stream (org.graylog2.plugin.streams.Stream)4 ClusterConfigServiceImpl (org.graylog2.cluster.ClusterConfigServiceImpl)3 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)2 DBCollection (com.mongodb.DBCollection)2 DBObject (com.mongodb.DBObject)2 MongoJackObjectMapperProvider (org.graylog2.bindings.providers.MongoJackObjectMapperProvider)2 StreamsChangedEvent (org.graylog2.streams.events.StreamsChangedEvent)2 DebugEvent (org.graylog2.system.debug.DebugEvent)2 BasicDBObjectBuilder (com.mongodb.BasicDBObjectBuilder)1 MongoDatabase (com.mongodb.client.MongoDatabase)1 List (java.util.List)1 WidgetUpdatedEvent (org.graylog2.dashboards.widgets.events.WidgetUpdatedEvent)1 MongoConnection (org.graylog2.database.MongoConnection)1 DefaultIndexSetConfig (org.graylog2.indexer.indexset.DefaultIndexSetConfig)1 IndexSetCreatedEvent (org.graylog2.indexer.indexset.events.IndexSetCreatedEvent)1