use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoIndexRangeServiceTest method findIgnoresLegacyIndexRanges.
@Test
@MongoDBFixtures("MongoIndexRangeServiceTest-LegacyIndexRanges.json")
public void findIgnoresLegacyIndexRanges() throws Exception {
when(indices.waitForRecovery("graylog_1")).thenReturn(HealthStatus.Green);
final DateTime begin = new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC);
final DateTime end = new DateTime(2015, 2, 1, 0, 0, DateTimeZone.UTC);
final SortedSet<IndexRange> indexRanges = indexRangeService.find(begin, end);
assertThat(indexRanges).containsOnly(MongoIndexRange.create(new ObjectId("55e0261a0cc6980000000003"), "graylog_1", new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC), 42));
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoIndexRangeServiceTest method findReturnsIndexRangesWithinGivenRange.
/**
* Test the following constellation:
* <pre>
* [- index range -]
* [- graylog_1 -][- graylog_2 -][- graylog_3 -][- graylog_4 -][- graylog_5 -]
* </pre>
*/
@Test
@MongoDBFixtures("MongoIndexRangeServiceTest-distinct.json")
public void findReturnsIndexRangesWithinGivenRange() throws Exception {
final DateTime begin = new DateTime(2015, 1, 2, 12, 0, DateTimeZone.UTC);
final DateTime end = new DateTime(2015, 1, 4, 12, 0, DateTimeZone.UTC);
final SortedSet<IndexRange> indexRanges = indexRangeService.find(begin, end);
assertThat(indexRanges).containsExactly(MongoIndexRange.create(new ObjectId("55e0261a0cc6980000000002"), "graylog_2", new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 3, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 3, 0, 0, DateTimeZone.UTC), 42), MongoIndexRange.create(new ObjectId("55e0261a0cc6980000000003"), "graylog_3", new DateTime(2015, 1, 3, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 4, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 4, 0, 0, DateTimeZone.UTC), 42), MongoIndexRange.create(new ObjectId("55e0261a0cc6980000000004"), "graylog_4", new DateTime(2015, 1, 4, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 5, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 5, 0, 0, DateTimeZone.UTC), 42));
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class UserServiceImplTest method testLoad.
@Test
@MongoDBFixtures("UserServiceImplTest.json")
public void testLoad() throws Exception {
final User user = userService.load("user1");
assertThat(user).isNotNull();
assertThat(user.getName()).isEqualTo("user1");
assertThat(user.getEmail()).isEqualTo("user1@example.com");
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoIndexRangeServiceTest method calculateRangeReturnsIndexRange.
@Test
@MongoDBFixtures("MongoIndexRangeServiceTest.json")
public void calculateRangeReturnsIndexRange() throws Exception {
final String index = "graylog";
final DateTime min = new DateTime(2015, 1, 1, 1, 0, DateTimeZone.UTC);
final DateTime max = new DateTime(2015, 1, 1, 5, 0, DateTimeZone.UTC);
when(indices.waitForRecovery(index)).thenReturn(HealthStatus.Green);
when(indices.indexRangeStatsOfIndex(index)).thenReturn(IndexRangeStats.create(min, max));
final IndexRange indexRange = indexRangeService.calculateRange(index);
assertThat(indexRange.indexName()).isEqualTo(index);
assertThat(indexRange.begin()).isEqualTo(min);
assertThat(indexRange.end()).isEqualTo(max);
Assertions.assertThat(indexRange.calculatedAt()).isEqualToIgnoringHours(DateTime.now(DateTimeZone.UTC));
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class MongoIndexRangeServiceTest method getReturnsExistingIndexRange.
@Test
@MongoDBFixtures("MongoIndexRangeServiceTest.json")
public void getReturnsExistingIndexRange() throws Exception {
IndexRange indexRange = indexRangeService.get("graylog_1");
assertThat(indexRange.indexName()).isEqualTo("graylog_1");
assertThat(indexRange.begin()).isEqualTo(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC));
assertThat(indexRange.end()).isEqualTo(new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC));
assertThat(indexRange.calculatedAt()).isEqualTo(new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC));
assertThat(indexRange.calculationDuration()).isEqualTo(23);
}
Aggregations