use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoIndexRangeServiceTest method findReturnsNothingBeforeBegin.
@Test
@MongoDBFixtures("MongoIndexRangeServiceTest.json")
public void findReturnsNothingBeforeBegin() throws Exception {
final DateTime begin = new DateTime(2016, 1, 1, 0, 0, DateTimeZone.UTC);
final DateTime end = new DateTime(2016, 1, 2, 0, 0, DateTimeZone.UTC);
Set<IndexRange> indexRanges = indexRangeService.find(begin, end);
assertThat(indexRanges).isEmpty();
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoIndexRangeServiceTest method testCalculateRangeWithEmptyIndex.
@Test
@MongoDBFixtures("MongoIndexRangeServiceTest-EmptyCollection.json")
public void testCalculateRangeWithEmptyIndex() throws Exception {
final String index = "graylog";
when(indices.indexRangeStatsOfIndex(index)).thenReturn(IndexRangeStats.EMPTY);
when(indices.waitForRecovery(index)).thenReturn(HealthStatus.Green);
final IndexRange range = indexRangeService.calculateRange(index);
assertThat(range).isNotNull();
assertThat(range.indexName()).isEqualTo(index);
assertThat(range.begin()).isEqualTo(new DateTime(0L, DateTimeZone.UTC));
assertThat(range.end()).isEqualTo(new DateTime(0L, DateTimeZone.UTC));
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoIndexRangeServiceTest method testHandleIndexReopeningWhenNotManaged.
@Test
@MongoDBFixtures("MongoIndexRangeServiceTest.json")
public void testHandleIndexReopeningWhenNotManaged() throws Exception {
final DateTime begin = new DateTime(2016, 1, 1, 0, 0, DateTimeZone.UTC);
final DateTime end = new DateTime(2016, 1, 15, 0, 0, DateTimeZone.UTC);
when(indexSetRegistry.isManagedIndex("graylog_3")).thenReturn(false);
when(indices.indexRangeStatsOfIndex("graylog_3")).thenReturn(IndexRangeStats.EMPTY);
localEventBus.post(IndicesReopenedEvent.create(Collections.singleton("graylog_3")));
final SortedSet<IndexRange> indexRanges = indexRangeService.find(begin, end);
assertThat(indexRanges).isEmpty();
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoIndexRangeServiceTest method testHandleIndexReopening.
@Test
@MongoDBFixtures("MongoIndexRangeServiceTest.json")
public void testHandleIndexReopening() throws Exception {
final DateTime begin = new DateTime(2016, 1, 1, 0, 0, DateTimeZone.UTC);
final DateTime end = new DateTime(2016, 1, 15, 0, 0, DateTimeZone.UTC);
when(indices.indexRangeStatsOfIndex("graylog_3")).thenReturn(IndexRangeStats.create(begin, end));
when(indexSetRegistry.isManagedIndex("graylog_3")).thenReturn(true);
when(indices.waitForRecovery("graylog_3")).thenReturn(HealthStatus.Green);
localEventBus.post(IndicesReopenedEvent.create(Collections.singleton("graylog_3")));
final SortedSet<IndexRange> indexRanges = indexRangeService.find(begin, end);
assertThat(indexRanges).hasSize(1);
assertThat(indexRanges.first().indexName()).isEqualTo("graylog_3");
assertThat(indexRanges.first().begin()).isEqualTo(begin);
assertThat(indexRanges.first().end()).isEqualTo(end);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoInputStatusServiceTest method handleDeleteEvent_WhenStoppingInputDoesNothing.
@Test
@MongoDBFixtures("input-status.json")
public void handleDeleteEvent_WhenStoppingInputDoesNothing() throws Exception {
final String deletedInput = "54e3deadbeefdeadbeef0001";
final InputDeleted inputDeletedEvent = new InputDeleted() {
@Override
public String id() {
return deletedInput;
}
};
cut.handleInputDeleted(inputDeletedEvent);
// The record should not be removed from the DB
assertThat(cut.get(deletedInput).isPresent(), is(true));
}
Aggregations