本文整理汇总了Java中org.elasticsearch.test.ElasticsearchIntegrationTest类的典型用法代码示例。如果您正苦于以下问题:Java ElasticsearchIntegrationTest类的具体用法?Java ElasticsearchIntegrationTest怎么用?Java ElasticsearchIntegrationTest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ElasticsearchIntegrationTest类属于org.elasticsearch.test包,在下文中一共展示了ElasticsearchIntegrationTest类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReportsCounters
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsCounters() {
String metricName = "com.codahale.metrics.elasticsearch.test.counter";
Counter counter = registry.counter(metricName);
counter.inc();
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all")
.setTypes(MetricElasticsearchTypes.COUNTER).setSize(20)
.setQuery(QueryBuilders.matchAllQuery()), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
Assert.assertEquals(1, searchHitSource.get("count"));
}
示例2: testReportsTimers
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsTimers() {
String metricName = "com.codahale.metrics.elasticsearch.test.timer";
Timer timer = registry.timer(metricName);
timer.update(1000, TimeUnit.MILLISECONDS);
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all")
.setTypes(MetricElasticsearchTypes.TIMER).setSize(20)
.setQuery(QueryBuilders.matchAllQuery()), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
Assert.assertEquals(1, searchHitSource.get("count"));
}
示例3: testReportsMeters
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsMeters() {
String metricName = "com.codahale.metrics.elasticsearch.test.meter";
Meter meter = registry.meter(metricName);
meter.mark();
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all").setSize(20)
.setTypes(MetricElasticsearchTypes.METER)
.setQuery(QueryBuilders.matchAllQuery()), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
Assert.assertEquals(1, searchHitSource.get("count"));
}
示例4: testReportsHistograms
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsHistograms() {
String metricName = "com.codahale.metrics.elasticsearch.test.histogram";
Histogram histogram = registry.histogram(metricName);
histogram.update(1);
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all").setSize(20)
.setTypes(MetricElasticsearchTypes.HISTOGRAM)
.setQuery(QueryBuilders.matchAllQuery()), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
Assert.assertEquals(1, searchHitSource.get("count"));
}
示例5: testReportsCounters
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsCounters() {
String metricName = "com.codahale.metrics.elasticsearch.test.counter";
Counter counter = registry.counter(metricName);
counter.inc();
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all")
.setTypes(MetricElasticsearchTypes.COUNTER)
.setQuery(QueryBuilders.matchAllQuery()), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
Assert.assertEquals(1, searchHitSource.get("count"));
}
示例6: testReportsTimers
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsTimers() {
String metricName = "com.codahale.metrics.elasticsearch.test.timer";
Timer timer = registry.timer(metricName);
timer.update(1000, TimeUnit.MILLISECONDS);
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all")
.setTypes(MetricElasticsearchTypes.TIMER)
.setQuery(QueryBuilders.matchAllQuery()), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
Assert.assertEquals(1, searchHitSource.get("count"));
}
示例7: testReportsMeters
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsMeters() {
String metricName = "com.codahale.metrics.elasticsearch.test.meter";
Meter meter = registry.meter(metricName);
meter.mark();
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all")
.setTypes(MetricElasticsearchTypes.METER)
.setQuery(QueryBuilders.matchAllQuery()), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
Assert.assertEquals(1, searchHitSource.get("count"));
}
示例8: testReportsHistograms
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsHistograms() {
String metricName = "com.codahale.metrics.elasticsearch.test.histogram";
Histogram histogram = registry.histogram(metricName);
histogram.update(1);
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all")
.setTypes(MetricElasticsearchTypes.HISTOGRAM)
.setQuery(QueryBuilders.matchAllQuery()), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
Assert.assertEquals(1, searchHitSource.get("count"));
}
示例9: testReportsWithAlternateTimestampField
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsWithAlternateTimestampField() {
reporter.stop();
reporter = ElasticsearchHttpReporter
.forRegistryAndIndexPrefix(registry, "test")
.withTimestampFieldName("@timeywimey")
.withClock(Clock.defaultClock()).prefixedWith(prefix)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.withBulkRequestLimit(10).filter(MetricFilter.ALL)
.build("localhost:9201");
reporter.start(1, TimeUnit.SECONDS);
String metricName = "com.codahale.metrics.elasticsearch.test.counter";
Counter counter = registry.counter(metricName);
counter.inc();
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all")
.setTypes(MetricElasticsearchTypes.COUNTER).setSize(20)
.setQuery(QueryBuilders.matchAllQuery()), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
Assert.assertEquals(1, searchHitSource.get("count"));
Assert.assertEquals(true, searchHitSource.containsKey("@timeywimey"));
}
示例10: setUp
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.setUp();
reporter = ElasticsearchTransportReporter
.forRegistryAndIndexPrefix(registry, "test")
.withClock(Clock.defaultClock()).prefixedWith(prefix)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.withBulkRequestLimit(10).filter(MetricFilter.ALL)
.build(ElasticsearchIntegrationTest.client());
reporter.start(1, TimeUnit.SECONDS);
}
示例11: testReportsWithAlternateTimestampField
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsWithAlternateTimestampField() {
reporter.stop();
reporter = ElasticsearchTransportReporter
.forRegistryAndIndexPrefix(registry, "test")
.withTimestampFieldName("@timeywimey")
.withClock(Clock.defaultClock()).prefixedWith(prefix)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.withBulkRequestLimit(10).filter(MetricFilter.ALL)
.build(ElasticsearchIntegrationTest.client());
reporter.start(1, TimeUnit.SECONDS);
String metricName = "com.codahale.metrics.elasticsearch.test.counter";
Counter counter = registry.counter(metricName);
counter.inc();
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all")
.setTypes(MetricElasticsearchTypes.COUNTER)
.setQuery(QueryBuilders.matchAllQuery()), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
Assert.assertEquals(1, searchHitSource.get("count"));
Assert.assertEquals(true, searchHitSource.containsKey("@timeywimey"));
}
示例12: testReportsWithBulkRequestLimit
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
@Test
public void testReportsWithBulkRequestLimit() {
DecimalFormat formatter = new DecimalFormat("00");
String metricNamePrefix = "com.codahale.metrics.elasticsearch.test.counter";
for (int i = 0; i < 15; i++) {
Counter counter = registry.counter(metricNamePrefix
+ formatter.format(i));
counter.inc();
}
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = nestedAggregationWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all")
.setTypes(MetricElasticsearchTypes.COUNTER)
.setQuery(QueryBuilders.matchAllQuery())
.setSize(0)
.addAggregation(
AggregationBuilders
.terms("timestamps")
.size(50)
.field("@timestamp")
.order(Order.term(true))
.subAggregation(
AggregationBuilders
.terms("names")
.size(50)
.field("@name")
.order(Order.term(true)))),
15);
InternalTerms timestamps = searchResponse.getAggregations().get(
"timestamps");
Collection<Bucket> timestampBuckets = timestamps.getBuckets();
Assert.assertEquals(true, timestampBuckets.size() > 0);
for (Bucket bucket : timestampBuckets) {
InternalTerms names = bucket.getAggregations().get("names");
if(names.getBuckets().size() >= 15) {
for (int i = 0; i < names.getBuckets().size(); i++) {
Assert.assertEquals(
prefix + "." + metricNamePrefix + formatter.format(i),
((Bucket) names.getBuckets().toArray()[i]).getKey());
}
return;
}
}
Assert.fail("Insufficient metrics reported");
}
示例13: testReportsGaugeOfType
import org.elasticsearch.test.ElasticsearchIntegrationTest; //导入依赖的package包/类
private <T> void testReportsGaugeOfType(Class<T> type, final T value) {
String metricName = "com.codahale.metrics.elasticsearch.test.guage."
+ type.getSimpleName().toLowerCase();
registry.register(metricName, new Gauge<T>() {
@Override
public T getValue() {
return value;
}
});
waitForReporter();
flushAndRefresh();
SearchResponse searchResponse = searchWithTimeout(
new SearchRequestBuilder(ElasticsearchIntegrationTest.client())
.setIndices("_all")
.setTypes(MetricElasticsearchTypes.GAUGE)
.setQuery(
QueryBuilders.matchPhraseQuery("@name", prefix
+ "." + metricName)), 1);
Assert.assertEquals(true, searchResponse.getHits().getHits().length > 0);
Map<String, Object> searchHitSource = searchResponse.getHits()
.getHits()[0].getSource();
Assert.assertEquals(prefix + "." + metricName,
searchHitSource.get("@name"));
if (value instanceof Float) {
// Note: Elasticsearch returns Float value as Double
Assert.assertEquals(Double.valueOf(value.toString()),
(Double) searchHitSource.get("floatValue"));
} else if (value instanceof Double) {
Assert.assertEquals((Double) value,
(Double) searchHitSource.get("doubleValue"));
} else if (value instanceof Byte) {
// Note: Elasticsearch returns Byte value as Integer
Assert.assertEquals(((Byte) value).intValue(),
((Integer) searchHitSource.get("byteValue")).intValue());
} else if (value instanceof Short) {
// Note: Elasticsearch returns Short value as Integer
Assert.assertEquals(((Short) value).intValue(),
((Integer) searchHitSource.get("shortValue")).intValue());
} else if (value instanceof Integer) {
Assert.assertEquals((Integer) value,
(Integer) searchHitSource.get("integerValue"));
} else if (value instanceof Long) {
Assert.assertEquals((Long) value,
(Long) searchHitSource.get("longValue"));
} else {
Assert.assertEquals((String) value,
(String) searchHitSource.get("stringValue"));
}
}