From 622d8a830e29baab16540ca942a41b646c32aca4 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Mon, 3 Aug 2015 14:42:34 -0700 Subject: Tests: Rename integ tests to IT suffix This rename effectively moves all integration tests to be run with `mvn verify`. `mvn test` now runs in about 2 mins. This is a follow up to --- .../aggregations/metrics/ValueCountTests.java | 204 --------------------- 1 file changed, 204 deletions(-) delete mode 100644 core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountTests.java (limited to 'core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountTests.java') diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountTests.java deleted file mode 100644 index 0840bd6070..0000000000 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountTests.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.search.aggregations.metrics; - -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.script.Script; -import org.elasticsearch.script.ScriptService.ScriptType; -import org.elasticsearch.search.aggregations.bucket.global.Global; -import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount; -import org.elasticsearch.test.ElasticsearchIntegrationTest; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.elasticsearch.search.aggregations.AggregationBuilders.count; -import static org.elasticsearch.search.aggregations.AggregationBuilders.global; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; - -/** - * - */ -@ElasticsearchIntegrationTest.SuiteScopeTest -public class ValueCountTests extends ElasticsearchIntegrationTest { - - @Override - public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); - createIndex("idx_unmapped"); - for (int i = 0; i < 10; i++) { - client().prepareIndex("idx", "type", ""+i).setSource(jsonBuilder() - .startObject() - .field("value", i+1) - .startArray("values").value(i+2).value(i+3).endArray() - .endObject()) - .execute().actionGet(); - } - client().admin().indices().prepareFlush().execute().actionGet(); - client().admin().indices().prepareRefresh().execute().actionGet(); - ensureSearchable(); - } - - @Test - public void unmapped() throws Exception { - SearchResponse searchResponse = client().prepareSearch("idx_unmapped") - .setQuery(matchAllQuery()) - .addAggregation(count("count").field("value")) - .execute().actionGet(); - - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); - - ValueCount valueCount = searchResponse.getAggregations().get("count"); - assertThat(valueCount, notNullValue()); - assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(0l)); - } - - @Test - public void singleValuedField() throws Exception { - - SearchResponse searchResponse = client().prepareSearch("idx") - .setQuery(matchAllQuery()) - .addAggregation(count("count").field("value")) - .execute().actionGet(); - - assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l)); - - ValueCount valueCount = searchResponse.getAggregations().get("count"); - assertThat(valueCount, notNullValue()); - assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(10l)); - } - - @Test - public void singleValuedField_getProperty() throws Exception { - - SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()) - .addAggregation(global("global").subAggregation(count("count").field("value"))).execute().actionGet(); - - assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l)); - - Global global = searchResponse.getAggregations().get("global"); - assertThat(global, notNullValue()); - assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); - assertThat(global.getAggregations(), notNullValue()); - assertThat(global.getAggregations().asMap().size(), equalTo(1)); - - ValueCount valueCount = global.getAggregations().get("count"); - assertThat(valueCount, notNullValue()); - assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(10l)); - assertThat((ValueCount) global.getProperty("count"), equalTo(valueCount)); - assertThat((double) global.getProperty("count.value"), equalTo(10d)); - assertThat((double) valueCount.getProperty("value"), equalTo(10d)); - } - - @Test - public void singleValuedField_PartiallyUnmapped() throws Exception { - SearchResponse searchResponse = client().prepareSearch("idx", "idx_unmapped") - .setQuery(matchAllQuery()) - .addAggregation(count("count").field("value")) - .execute().actionGet(); - - assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l)); - - ValueCount valueCount = searchResponse.getAggregations().get("count"); - assertThat(valueCount, notNullValue()); - assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(10l)); - } - - @Test - public void multiValuedField() throws Exception { - - SearchResponse searchResponse = client().prepareSearch("idx") - .setQuery(matchAllQuery()) - .addAggregation(count("count").field("values")) - .execute().actionGet(); - - assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l)); - - ValueCount valueCount = searchResponse.getAggregations().get("count"); - assertThat(valueCount, notNullValue()); - assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(20l)); - } - - @Test - public void singleValuedScript() throws Exception { - SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()) - .addAggregation(count("count").script(new Script("doc['value'].value"))).execute().actionGet(); - - assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l)); - - ValueCount valueCount = searchResponse.getAggregations().get("count"); - assertThat(valueCount, notNullValue()); - assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(10l)); - } - - @Test - public void multiValuedScript() throws Exception { - SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()) - .addAggregation(count("count").script(new Script("doc['values'].values"))).execute().actionGet(); - - assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l)); - - ValueCount valueCount = searchResponse.getAggregations().get("count"); - assertThat(valueCount, notNullValue()); - assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(20l)); - } - - @Test - public void singleValuedScriptWithParams() throws Exception { - Map params = new HashMap<>(); - params.put("s", "value"); - SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()) - .addAggregation(count("count").script(new Script("doc[s].value", ScriptType.INLINE, null, params))).execute().actionGet(); - - assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l)); - - ValueCount valueCount = searchResponse.getAggregations().get("count"); - assertThat(valueCount, notNullValue()); - assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(10l)); - } - - @Test - public void multiValuedScriptWithParams() throws Exception { - Map params = new HashMap<>(); - params.put("s", "values"); - SearchResponse searchResponse = client().prepareSearch("idx").setQuery(matchAllQuery()) - .addAggregation(count("count").script(new Script("doc[s].values", ScriptType.INLINE, null, params))).execute().actionGet(); - - assertThat(searchResponse.getHits().getTotalHits(), equalTo(10l)); - - ValueCount valueCount = searchResponse.getAggregations().get("count"); - assertThat(valueCount, notNullValue()); - assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(20l)); - } - -} \ No newline at end of file -- cgit v1.2.3