Search in sources :

Example 1 with UsingDataSet

use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.

the class SearchesTest method countRecordsMetrics.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void countRecordsMetrics() throws Exception {
    CountResult result = searches.count("*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)));
    assertThat(metricRegistry.getTimers()).containsKey(REQUEST_TIMER_NAME);
    assertThat(metricRegistry.getHistograms()).containsKey(RANGES_HISTOGRAM_NAME);
    Timer timer = metricRegistry.timer(REQUEST_TIMER_NAME);
    assertThat(timer.getCount()).isEqualTo(1L);
}
Also used : Timer(com.codahale.metrics.Timer) CountResult(org.graylog2.indexer.results.CountResult) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 2 with UsingDataSet

use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.

the class SearchesTest method fieldHistogramRecordsMetrics.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void fieldHistogramRecordsMetrics() throws Exception {
    final AbsoluteRange range = AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC));
    HistogramResult h = searches.fieldHistogram("*", "n", Searches.DateHistogramInterval.MINUTE, null, range, false);
    assertThat(metricRegistry.getTimers()).containsKey(REQUEST_TIMER_NAME);
    assertThat(metricRegistry.getHistograms()).containsKey(RANGES_HISTOGRAM_NAME);
    Timer timer = metricRegistry.timer(REQUEST_TIMER_NAME);
    assertThat(timer.getCount()).isEqualTo(1L);
    Histogram histogram = metricRegistry.histogram(RANGES_HISTOGRAM_NAME);
    assertThat(histogram.getCount()).isEqualTo(1L);
    assertThat(histogram.getSnapshot().getValues()).containsExactly(86400L);
}
Also used : HistogramResult(org.graylog2.indexer.results.HistogramResult) Histogram(com.codahale.metrics.Histogram) Timer(com.codahale.metrics.Timer) AbsoluteRange(org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 3 with UsingDataSet

use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.

the class SearchesTest method testTerms.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testTerms() throws Exception {
    TermsResult result = searches.terms("n", 25, "*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)));
    assertThat(result.getTotal()).isEqualTo(10L);
    assertThat(result.getMissing()).isEqualTo(2L);
    assertThat(result.getTerms()).hasSize(4).containsEntry("1", 2L).containsEntry("2", 2L).containsEntry("3", 3L).containsEntry("4", 1L);
}
Also used : TermsResult(org.graylog2.indexer.results.TermsResult) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 4 with UsingDataSet

use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.

the class SearchesTest method testTermsStats.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testTermsStats() throws Exception {
    TermsStatsResult r = searches.termsStats("message", "n", Searches.TermsStatsOrder.COUNT, 25, "*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)));
    assertThat(r.getResults()).hasSize(2);
    assertThat(r.getResults().get(0)).hasSize(7).containsEntry("key_field", "ho");
}
Also used : TermsStatsResult(org.graylog2.indexer.results.TermsStatsResult) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 5 with UsingDataSet

use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.

the class SearchesTest method histogramRecordsMetrics.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void histogramRecordsMetrics() throws Exception {
    final AbsoluteRange range = AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC));
    HistogramResult h = searches.histogram("*", Searches.DateHistogramInterval.MINUTE, range);
    assertThat(metricRegistry.getTimers()).containsKey(REQUEST_TIMER_NAME);
    assertThat(metricRegistry.getHistograms()).containsKey(RANGES_HISTOGRAM_NAME);
    Timer timer = metricRegistry.timer(REQUEST_TIMER_NAME);
    assertThat(timer.getCount()).isEqualTo(1L);
    Histogram histogram = metricRegistry.histogram(RANGES_HISTOGRAM_NAME);
    assertThat(histogram.getCount()).isEqualTo(1L);
    assertThat(histogram.getSnapshot().getValues()).containsExactly(86400L);
}
Also used : HistogramResult(org.graylog2.indexer.results.HistogramResult) Histogram(com.codahale.metrics.Histogram) Timer(com.codahale.metrics.Timer) AbsoluteRange(org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Aggregations

UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)94 Test (org.junit.Test)94 DateTime (org.joda.time.DateTime)40 DBCollection (com.mongodb.DBCollection)29 ZonedDateTime (java.time.ZonedDateTime)19 DBObject (com.mongodb.DBObject)15 BasicDBObjectBuilder (com.mongodb.BasicDBObjectBuilder)13 ObjectId (org.bson.types.ObjectId)9 MongoDBServiceTest (org.graylog2.database.MongoDBServiceTest)9 Timer (com.codahale.metrics.Timer)6 Histogram (com.codahale.metrics.Histogram)5 JsonPath (com.jayway.restassured.path.json.JsonPath)5 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)5 HistogramResult (org.graylog2.indexer.results.HistogramResult)5 AbsoluteRange (org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange)5 List (java.util.List)4 TermsResult (org.graylog2.indexer.results.TermsResult)4 User (org.graylog2.plugin.database.users.User)4 LdapSettings (org.graylog2.shared.security.ldap.LdapSettings)4 Map (java.util.Map)3