Browse Source

Clean up more messy tests

After #13834 many tests that used Groovy scripts (for good or bad reason) in their tests have been moved in the lang-groovy module and the issue #13837 has been created to track these messy tests in order to clean them up.

This commit moves more tests back in core, removes the dependency on Groovy, changes the scripts in order to use the mocked script engine, and change the tests  to integration tests.
Tanguy Leroux 9 years ago
parent
commit
3267fc4e0c

+ 0 - 5
buildSrc/src/main/resources/checkstyle_suppressions.xml

@@ -1127,11 +1127,8 @@
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]groovy[/\\]GroovyScriptEngineService.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]BulkTests.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]DoubleTermsTests.java" checks="LineLength" />
-  <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]EquivalenceTests.java" checks="LineLength" />
-  <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]HistogramTests.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]IPv4RangeTests.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]IndexLookupTests.java" checks="LineLength" />
-  <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]IndicesRequestTests.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]LongTermsTests.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]MinDocCountTests.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]MinTests.java" checks="LineLength" />
@@ -1140,8 +1137,6 @@
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]SearchFieldsTests.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]SimpleSortTests.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]StringTermsTests.java" checks="LineLength" />
-  <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]TDigestPercentileRanksTests.java" checks="LineLength" />
-  <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]TDigestPercentilesTests.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]messy[/\\]tests[/\\]package-info.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]groovy[/\\]GroovyScriptTests.java" checks="LineLength" />
   <suppress files="modules[/\\]lang-groovy[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]groovy[/\\]GroovySecurityTests.java" checks="LineLength" />

+ 41 - 18
modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java → core/src/test/java/org/elasticsearch/action/IndicesRequestIT.java

@@ -17,9 +17,8 @@
  * under the License.
  */
 
-package org.elasticsearch.messy.tests;
+package org.elasticsearch.action;
 
-import org.elasticsearch.action.IndicesRequest;
 import org.elasticsearch.action.admin.indices.alias.Alias;
 import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction;
 import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest;
@@ -77,15 +76,15 @@ import org.elasticsearch.action.termvectors.TermVectorsRequest;
 import org.elasticsearch.action.update.UpdateAction;
 import org.elasticsearch.action.update.UpdateRequest;
 import org.elasticsearch.action.update.UpdateResponse;
-import org.elasticsearch.cluster.ClusterName;
 import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
 import org.elasticsearch.common.inject.Inject;
 import org.elasticsearch.common.network.NetworkModule;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.script.MockScriptPlugin;
 import org.elasticsearch.script.Script;
-import org.elasticsearch.script.groovy.GroovyPlugin;
+import org.elasticsearch.script.ScriptService;
 import org.elasticsearch.search.action.SearchTransportService;
 import org.elasticsearch.tasks.Task;
 import org.elasticsearch.test.ESIntegTestCase;
@@ -109,6 +108,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.Function;
 import java.util.function.Supplier;
 
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -120,7 +120,8 @@ import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.instanceOf;
 
 @ClusterScope(scope = Scope.SUITE, numClientNodes = 1, minNumDataNodes = 2)
-public class IndicesRequestTests extends ESIntegTestCase {
+public class IndicesRequestIT extends ESIntegTestCase {
+
     private final List<String> indices = new ArrayList<>();
 
     @Override
@@ -148,7 +149,16 @@ public class IndicesRequestTests extends ESIntegTestCase {
 
     @Override
     protected Collection<Class<? extends Plugin>> nodePlugins() {
-        return pluginList(InterceptingTransportService.TestPlugin.class, GroovyPlugin.class);
+        return pluginList(InterceptingTransportService.TestPlugin.class, CustomScriptPlugin.class);
+    }
+
+    public static class CustomScriptPlugin extends MockScriptPlugin {
+
+        @Override
+        @SuppressWarnings("unchecked")
+        protected Map<String, Function<Map<String, Object>, Object>> pluginScripts() {
+            return Collections.singletonMap("ctx.op='delete'", vars -> ((Map<String, Object>) vars.get("ctx")).put("op", "delete"));
+        }
     }
 
     @Before
@@ -251,7 +261,8 @@ public class IndicesRequestTests extends ESIntegTestCase {
 
         String indexOrAlias = randomIndexOrAlias();
         client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get();
-        UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").script(new Script("ctx.op='delete'"));
+        UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id")
+                .script(new Script("ctx.op='delete'", ScriptService.ScriptType.INLINE, CustomScriptPlugin.NAME, Collections.emptyMap()));
         UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet();
         assertThat(updateResponse.isCreated(), equalTo(false));
 
@@ -360,14 +371,16 @@ public class IndicesRequestTests extends ESIntegTestCase {
     }
 
     public void testFlush() {
-        String[] indexShardActions = new String[]{TransportShardFlushAction.NAME, TransportShardFlushAction.NAME + "[r]", TransportShardFlushAction.NAME + "[p]"};
+        String[] indexShardActions = new String[]{TransportShardFlushAction.NAME, TransportShardFlushAction.NAME + "[r]",
+                TransportShardFlushAction.NAME + "[p]"};
         interceptTransportActions(indexShardActions);
 
         FlushRequest flushRequest = new FlushRequest(randomIndicesOrAliases());
         internalCluster().coordOnlyNodeClient().admin().indices().flush(flushRequest).actionGet();
 
         clearInterceptedActions();
-        String[] indices = new IndexNameExpressionResolver(Settings.EMPTY).concreteIndexNames(client().admin().cluster().prepareState().get().getState(), flushRequest);
+        String[] indices = new IndexNameExpressionResolver(Settings.EMPTY)
+                .concreteIndexNames(client().admin().cluster().prepareState().get().getState(), flushRequest);
         assertIndicesSubset(Arrays.asList(indices), indexShardActions);
     }
 
@@ -383,14 +396,16 @@ public class IndicesRequestTests extends ESIntegTestCase {
     }
 
     public void testRefresh() {
-        String[] indexShardActions = new String[]{TransportShardRefreshAction.NAME, TransportShardRefreshAction.NAME + "[r]", TransportShardRefreshAction.NAME + "[p]"};
+        String[] indexShardActions = new String[]{TransportShardRefreshAction.NAME, TransportShardRefreshAction.NAME + "[r]",
+                TransportShardRefreshAction.NAME + "[p]"};
         interceptTransportActions(indexShardActions);
 
         RefreshRequest refreshRequest = new RefreshRequest(randomIndicesOrAliases());
         internalCluster().coordOnlyNodeClient().admin().indices().refresh(refreshRequest).actionGet();
 
         clearInterceptedActions();
-        String[] indices = new IndexNameExpressionResolver(Settings.EMPTY).concreteIndexNames(client().admin().cluster().prepareState().get().getState(), refreshRequest);
+        String[] indices = new IndexNameExpressionResolver(Settings.EMPTY)
+                .concreteIndexNames(client().admin().cluster().prepareState().get().getState(), refreshRequest);
         assertIndicesSubset(Arrays.asList(indices), indexShardActions);
     }
 
@@ -493,7 +508,9 @@ public class IndicesRequestTests extends ESIntegTestCase {
     public void testPutMapping() {
         interceptTransportActions(PutMappingAction.NAME);
 
-        PutMappingRequest putMappingRequest = new PutMappingRequest(randomUniqueIndicesOrAliases()).type("type").source("field", "type=text");
+        PutMappingRequest putMappingRequest = new PutMappingRequest(randomUniqueIndicesOrAliases())
+                .type("type")
+                .source("field", "type=text");
         internalCluster().coordOnlyNodeClient().admin().indices().putMapping(putMappingRequest).actionGet();
 
         clearInterceptedActions();
@@ -513,7 +530,8 @@ public class IndicesRequestTests extends ESIntegTestCase {
     public void testUpdateSettings() {
         interceptTransportActions(UpdateSettingsAction.NAME);
 
-        UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(randomIndicesOrAliases()).settings(Settings.builder().put("refresh_interval", -1));
+        UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(randomIndicesOrAliases())
+                .settings(Settings.builder().put("refresh_interval", -1));
         internalCluster().coordOnlyNodeClient().admin().indices().updateSettings(updateSettingsRequest).actionGet();
 
         clearInterceptedActions();
@@ -621,8 +639,9 @@ public class IndicesRequestTests extends ESIntegTestCase {
             }
             for (TransportRequest internalRequest : requests) {
                 assertThat(internalRequest, instanceOf(IndicesRequest.class));
-                assertThat(internalRequest.getClass().getName(), ((IndicesRequest)internalRequest).indices(), equalTo(originalRequest.indices()));
-                assertThat(((IndicesRequest)internalRequest).indicesOptions(), equalTo(originalRequest.indicesOptions()));
+                IndicesRequest indicesRequest = (IndicesRequest) internalRequest;
+                assertThat(internalRequest.getClass().getName(), indicesRequest.indices(), equalTo(originalRequest.indices()));
+                assertThat(indicesRequest.indicesOptions(), equalTo(originalRequest.indicesOptions()));
             }
         }
     }
@@ -736,12 +755,16 @@ public class IndicesRequestTests extends ESIntegTestCase {
         }
 
         @Override
-        public <Request extends TransportRequest> void registerRequestHandler(String action, Supplier<Request> request, String executor, boolean forceExecution, boolean canTripCircuitBreaker, TransportRequestHandler<Request> handler) {
-            super.registerRequestHandler(action, request, executor, forceExecution, canTripCircuitBreaker, new InterceptingRequestHandler<>(action, handler));
+        public <Request extends TransportRequest> void registerRequestHandler(String action, Supplier<Request> request, String executor,
+                                                                              boolean forceExecution, boolean canTripCircuitBreaker,
+                                                                              TransportRequestHandler<Request> handler) {
+            super.registerRequestHandler(action, request, executor, forceExecution, canTripCircuitBreaker, new
+                    InterceptingRequestHandler<>(action, handler));
         }
 
         @Override
-        public <Request extends TransportRequest> void registerRequestHandler(String action, Supplier<Request> requestFactory, String executor, TransportRequestHandler<Request> handler) {
+        public <Request extends TransportRequest> void registerRequestHandler(String action, Supplier<Request> requestFactory, String
+                executor, TransportRequestHandler<Request> handler) {
             super.registerRequestHandler(action, requestFactory, executor, new InterceptingRequestHandler<>(action, handler));
         }
 

+ 17 - 1
core/src/test/java/org/elasticsearch/search/aggregations/AggregationTestScriptsPlugin.java

@@ -21,16 +21,30 @@ package org.elasticsearch.search.aggregations;
 
 import org.elasticsearch.index.fielddata.ScriptDocValues;
 import org.elasticsearch.script.MockScriptPlugin;
+import org.elasticsearch.script.Script;
 
 import java.util.HashMap;
 import java.util.Map;
 import java.util.function.Function;
 
+import static java.util.Collections.singletonMap;
+import static org.elasticsearch.script.ScriptService.ScriptType;
+
 /**
  * This class contains various mocked scripts that are used in aggregations integration tests.
  */
 public class AggregationTestScriptsPlugin extends MockScriptPlugin {
 
+    // Equivalent to:
+    //
+    // List values = doc['values'].values;
+    // double[] res = new double[values.size()];
+    // for (int i = 0; i < res.length; i++) {
+    //      res[i] = values.get(i) - dec;
+    // };
+    // return res;
+    public static final Script DECREMENT_ALL_VALUES = new Script("decrement all values", ScriptType.INLINE, NAME, singletonMap("dec", 1));
+
     @Override
     protected Map<String, Function<Map<String, Object>, Object>> pluginScripts() {
         Map<String, Function<Map<String, Object>, Object>> scripts = new HashMap<>();
@@ -68,7 +82,7 @@ public class AggregationTestScriptsPlugin extends MockScriptPlugin {
             return doc.get("values");
         });
 
-        scripts.put("decrement all values", vars -> {
+        scripts.put(DECREMENT_ALL_VALUES.getScript(), vars -> {
             int dec = (int) vars.get("dec");
             Map<?, ?> doc = (Map) vars.get("doc");
             ScriptDocValues.Longs values = (ScriptDocValues.Longs) doc.get("values");
@@ -80,6 +94,8 @@ public class AggregationTestScriptsPlugin extends MockScriptPlugin {
             return res;
         });
 
+        scripts.put("_value * -1", vars -> (double) vars.get("_value") * -1);
+
         return scripts;
     }
 }

+ 76 - 18
modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/EquivalenceTests.java → core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java

@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.elasticsearch.messy.tests;
+package org.elasticsearch.search.aggregations;
 
 import com.carrotsearch.hppc.IntHashSet;
 import org.elasticsearch.action.index.IndexRequestBuilder;
@@ -28,9 +28,9 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.index.query.RangeQueryBuilder;
 import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.script.MockScriptPlugin;
 import org.elasticsearch.script.Script;
 import org.elasticsearch.script.ScriptService.ScriptType;
-import org.elasticsearch.script.groovy.GroovyPlugin;
 import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
 import org.elasticsearch.search.aggregations.bucket.filter.Filter;
 import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
@@ -49,6 +49,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Function;
 
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 import static org.elasticsearch.search.aggregations.AggregationBuilders.extendedStats;
@@ -71,11 +72,22 @@ import static org.hamcrest.core.IsNull.notNullValue;
  * Additional tests that aim at testing more complex aggregation trees on larger random datasets, so that things like
  * the growth of dynamic arrays is tested.
  */
-public class EquivalenceTests extends ESIntegTestCase {
+public class EquivalenceIT extends ESIntegTestCase {
 
     @Override
     protected Collection<Class<? extends Plugin>> nodePlugins() {
-        return Collections.singleton(GroovyPlugin.class);
+        return Collections.singleton(CustomScriptPlugin.class);
+    }
+
+    public static class CustomScriptPlugin extends MockScriptPlugin {
+        @Override
+        protected Map<String, Function<Map<String, Object>, Object>> pluginScripts() {
+            return Collections.singletonMap("floor(_value / interval)", vars -> {
+                Double value = (Double) vars.get("_value");
+                Integer interval = (Integer) vars.get("interval");
+                return Math.floor(value / interval.doubleValue());
+            });
+        }
     }
 
     // Make sure that unordered, reversed, disjoint and/or overlapping ranges are supported
@@ -102,7 +114,9 @@ public class EquivalenceTests extends ESIntegTestCase {
             source = source.endArray().endObject();
             client().prepareIndex("idx", "type").setSource(source).execute().actionGet();
         }
-        assertNoFailures(client().admin().indices().prepareRefresh("idx").setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute().get());
+        assertNoFailures(client().admin().indices().prepareRefresh("idx").
+                setIndicesOptions(IndicesOptions.lenientExpandOpen())
+                .get());
 
         final int numRanges = randomIntBetween(1, 20);
         final double[][] ranges = new double[numRanges][];
@@ -234,20 +248,48 @@ public class EquivalenceTests extends ESIntegTestCase {
         }
         indexRandom(true, indexingRequests);
 
-        assertNoFailures(client().admin().indices().prepareRefresh("idx").setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute().get());
+        assertNoFailures(client().admin().indices().prepareRefresh("idx")
+                .setIndicesOptions(IndicesOptions.lenientExpandOpen())
+                .execute().get());
 
         TermsAggregatorFactory.ExecutionMode[] globalOrdinalModes = new TermsAggregatorFactory.ExecutionMode[] {
                 TermsAggregatorFactory.ExecutionMode.GLOBAL_ORDINALS_HASH, TermsAggregatorFactory.ExecutionMode.GLOBAL_ORDINALS
         };
 
         SearchResponse resp = client().prepareSearch("idx")
-                .addAggregation(terms("long").field("long_values").size(maxNumTerms).collectMode(randomFrom(SubAggCollectionMode.values())).subAggregation(min("min").field("num")))
-                .addAggregation(terms("double").field("double_values").size(maxNumTerms).collectMode(randomFrom(SubAggCollectionMode.values())).subAggregation(max("max").field("num")))
-                .addAggregation(terms("string_map").field("string_values").collectMode(randomFrom(SubAggCollectionMode.values()))
-                        .executionHint(TermsAggregatorFactory.ExecutionMode.MAP.toString()).size(maxNumTerms)
-                        .subAggregation(stats("stats").field("num")))
-                .addAggregation(terms("string_global_ordinals").field("string_values").collectMode(randomFrom(SubAggCollectionMode.values())).executionHint(globalOrdinalModes[randomInt(globalOrdinalModes.length - 1)].toString()).size(maxNumTerms).subAggregation(extendedStats("stats").field("num")))
-                .addAggregation(terms("string_global_ordinals_doc_values").field("string_values.doc_values").collectMode(randomFrom(SubAggCollectionMode.values())).executionHint(globalOrdinalModes[randomInt(globalOrdinalModes.length - 1)].toString()).size(maxNumTerms).subAggregation(extendedStats("stats").field("num")))
+                    .addAggregation(
+                            terms("long")
+                                    .field("long_values")
+                                    .size(maxNumTerms)
+                                    .collectMode(randomFrom(SubAggCollectionMode.values()))
+                                    .subAggregation(min("min").field("num")))
+                    .addAggregation(
+                            terms("double")
+                                    .field("double_values")
+                                    .size(maxNumTerms)
+                                    .collectMode(randomFrom(SubAggCollectionMode.values()))
+                                    .subAggregation(max("max").field("num")))
+                    .addAggregation(
+                            terms("string_map")
+                                    .field("string_values")
+                                    .collectMode(randomFrom(SubAggCollectionMode.values()))
+                                    .executionHint(TermsAggregatorFactory.ExecutionMode.MAP.toString())
+                                    .size(maxNumTerms)
+                                    .subAggregation(stats("stats").field("num")))
+                    .addAggregation(
+                            terms("string_global_ordinals")
+                                    .field("string_values")
+                                    .collectMode(randomFrom(SubAggCollectionMode.values()))
+                                    .executionHint(globalOrdinalModes[randomInt(globalOrdinalModes.length - 1)].toString())
+                                    .size(maxNumTerms)
+                                    .subAggregation(extendedStats("stats").field("num")))
+                    .addAggregation(
+                            terms("string_global_ordinals_doc_values")
+                                    .field("string_values.doc_values")
+                                    .collectMode(randomFrom(SubAggCollectionMode.values()))
+                                    .executionHint(globalOrdinalModes[randomInt(globalOrdinalModes.length - 1)].toString())
+                                    .size(maxNumTerms)
+                                    .subAggregation(extendedStats("stats").field("num")))
                 .execute().actionGet();
         assertAllSuccessful(resp);
         assertEquals(numDocs, resp.getHits().getTotalHits());
@@ -304,15 +346,25 @@ public class EquivalenceTests extends ESIntegTestCase {
             source = source.endArray().endObject();
             client().prepareIndex("idx", "type").setSource(source).execute().actionGet();
         }
-        assertNoFailures(client().admin().indices().prepareRefresh("idx").setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute().get());
+        assertNoFailures(client().admin().indices().prepareRefresh("idx")
+                .setIndicesOptions(IndicesOptions.lenientExpandOpen())
+                .execute().get());
 
         Map<String, Object> params = new HashMap<>();
         params.put("interval", interval);
+
         SearchResponse resp = client().prepareSearch("idx")
                 .addAggregation(
-                        terms("terms").field("values").collectMode(randomFrom(SubAggCollectionMode.values()))
-                                .script(new Script("floor(_value / interval)", ScriptType.INLINE, null, params)).size(maxNumTerms))
-                .addAggregation(histogram("histo").field("values").interval(interval).minDocCount(1))
+                        terms("terms")
+                                .field("values")
+                                .collectMode(randomFrom(SubAggCollectionMode.values()))
+                                .script(new Script("floor(_value / interval)", ScriptType.INLINE, CustomScriptPlugin.NAME, params))
+                                .size(maxNumTerms))
+                .addAggregation(
+                        histogram("histo")
+                                .field("values")
+                                .interval(interval)
+                                .minDocCount(1))
                 .execute().actionGet();
 
         assertSearchResponse(resp);
@@ -341,7 +393,13 @@ public class EquivalenceTests extends ESIntegTestCase {
         }
         indexRandom(true, indexingRequests);
 
-        SearchResponse response = client().prepareSearch("idx").addAggregation(terms("terms").field("double_value").collectMode(randomFrom(SubAggCollectionMode.values())).subAggregation(percentiles("pcts").field("double_value"))).execute().actionGet();
+        SearchResponse response = client().prepareSearch("idx")
+                .addAggregation(
+                        terms("terms")
+                                .field("double_value")
+                                .collectMode(randomFrom(SubAggCollectionMode.values()))
+                                .subAggregation(percentiles("pcts").field("double_value")))
+                .execute().actionGet();
         assertAllSuccessful(response);
         assertEquals(numDocs, response.getHits().getTotalHits());
     }

+ 82 - 21
modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java → core/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramIT.java

@@ -16,15 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.elasticsearch.messy.tests;
+package org.elasticsearch.search.aggregations.bucket;
 
 import com.carrotsearch.hppc.LongHashSet;
 import org.elasticsearch.action.index.IndexRequestBuilder;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.script.MockScriptPlugin;
 import org.elasticsearch.script.Script;
-import org.elasticsearch.script.groovy.GroovyPlugin;
+import org.elasticsearch.script.ScriptService.ScriptType;
+import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
 import org.elasticsearch.search.aggregations.bucket.filter.Filter;
 import org.elasticsearch.search.aggregations.bucket.histogram.ExtendedBounds;
 import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
@@ -38,8 +40,12 @@ import org.hamcrest.Matchers;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
 
+import static java.util.Collections.emptyMap;
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
 import static org.elasticsearch.search.aggregations.AggregationBuilders.filter;
@@ -56,11 +62,8 @@ import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.lessThanOrEqualTo;
 import static org.hamcrest.core.IsNull.notNullValue;
 
-/**
- *
- */
 @ESIntegTestCase.SuiteScopeTestCase
-public class HistogramTests extends ESIntegTestCase {
+public class HistogramIT extends ESIntegTestCase {
 
     private static final String SINGLE_VALUED_FIELD_NAME = "l_value";
     private static final String MULTI_VALUED_FIELD_NAME = "l_values";
@@ -72,7 +75,32 @@ public class HistogramTests extends ESIntegTestCase {
 
     @Override
     protected Collection<Class<? extends Plugin>> nodePlugins() {
-        return Collections.singleton(GroovyPlugin.class);
+        return Collections.singleton(CustomScriptPlugin.class);
+    }
+
+    public static class CustomScriptPlugin extends MockScriptPlugin {
+
+        @Override
+        protected Map<String, Function<Map<String, Object>, Object>> pluginScripts() {
+            Map<String, Function<Map<String, Object>, Object>> scripts = new HashMap<>();
+
+            scripts.put("_value + 1", vars -> {
+                long value = (long) vars.get("_value");
+                return value + 1L;
+            });
+
+            scripts.put("doc['l_value'].value", vars -> {
+                Map<?, ?> doc = (Map) vars.get("doc");
+                return doc.get(SINGLE_VALUED_FIELD_NAME);
+            });
+
+            scripts.put("doc['l_values']", vars -> {
+                Map<?, ?> doc = (Map) vars.get("doc");
+                return doc.get(MULTI_VALUED_FIELD_NAME);
+            });
+
+            return scripts;
+        }
     }
 
     @Override
@@ -349,15 +377,19 @@ public class HistogramTests extends ESIntegTestCase {
                 }
             }
             assertThat(sum.getValue(), equalTo((double) s));
-            assertThat((long) propertiesKeys[i], equalTo((long) i * interval));
-            assertThat((long) propertiesDocCounts[i], equalTo(valueCounts[i]));
-            assertThat((double) propertiesCounts[i], equalTo((double) s));
+            assertEquals(propertiesKeys[i], (long) i * interval);
+            assertThat(propertiesDocCounts[i], equalTo(valueCounts[i]));
+            assertThat(propertiesCounts[i], equalTo((double) s));
         }
     }
 
     public void testSingleValuedFieldOrderedBySubAggregationAsc() throws Exception {
         SearchResponse response = client().prepareSearch("idx")
-                .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.aggregation("sum", true))
+                .addAggregation(
+                        histogram("histo")
+                                .field(SINGLE_VALUED_FIELD_NAME)
+                                .interval(interval)
+                                .order(Histogram.Order.aggregation("sum", true))
                         .subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
                 .execute().actionGet();
 
@@ -397,7 +429,11 @@ public class HistogramTests extends ESIntegTestCase {
 
     public void testSingleValuedFieldOrderedBySubAggregationDesc() throws Exception {
         SearchResponse response = client().prepareSearch("idx")
-                .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.aggregation("sum", false))
+                .addAggregation(
+                        histogram("histo")
+                                .field(SINGLE_VALUED_FIELD_NAME)
+                                .interval(interval)
+                                .order(Histogram.Order.aggregation("sum", false))
                         .subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)))
                 .execute().actionGet();
 
@@ -437,7 +473,11 @@ public class HistogramTests extends ESIntegTestCase {
 
     public void testSingleValuedFieldOrderedByMultiValuedSubAggregationDesc() throws Exception {
         SearchResponse response = client().prepareSearch("idx")
-                .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.aggregation("stats.sum", false))
+                .addAggregation(
+                        histogram("histo")
+                                .field(SINGLE_VALUED_FIELD_NAME)
+                                .interval(interval)
+                                .order(Histogram.Order.aggregation("stats.sum", false))
                         .subAggregation(stats("stats").field(SINGLE_VALUED_FIELD_NAME)))
                 .execute().actionGet();
 
@@ -478,9 +518,13 @@ public class HistogramTests extends ESIntegTestCase {
     public void testSingleValuedFieldOrderedBySubAggregationDescDeepOrderPath() throws Exception {
         boolean asc = randomBoolean();
         SearchResponse response = client().prepareSearch("idx")
-                .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval).order(Histogram.Order.aggregation("filter>max", asc))
+                .addAggregation(
+                        histogram("histo")
+                                .field(SINGLE_VALUED_FIELD_NAME)
+                                .interval(interval)
+                                .order(Histogram.Order.aggregation("filter>max", asc))
                         .subAggregation(filter("filter", matchAllQuery())
-                                .subAggregation(max("max").field(SINGLE_VALUED_FIELD_NAME))))
+                        .subAggregation(max("max").field(SINGLE_VALUED_FIELD_NAME))))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -515,7 +559,11 @@ public class HistogramTests extends ESIntegTestCase {
 
     public void testSingleValuedFieldWithValueScript() throws Exception {
         SearchResponse response = client().prepareSearch("idx")
-                .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).script(new Script("_value + 1")).interval(interval))
+                .addAggregation(
+                        histogram("histo")
+                                .field(SINGLE_VALUED_FIELD_NAME)
+                                .script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap()))
+                                .interval(interval))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -588,7 +636,11 @@ public class HistogramTests extends ESIntegTestCase {
 
     public void testMultiValuedFieldWithValueScript() throws Exception {
         SearchResponse response = client().prepareSearch("idx")
-                .addAggregation(histogram("histo").field(MULTI_VALUED_FIELD_NAME).script(new Script("_value + 1")).interval(interval))
+                .addAggregation(
+                        histogram("histo")
+                                .field(MULTI_VALUED_FIELD_NAME)
+                                .script(new Script("_value + 1", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap()))
+                                .interval(interval))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -621,7 +673,10 @@ public class HistogramTests extends ESIntegTestCase {
 
     public void testScriptSingleValue() throws Exception {
         SearchResponse response = client().prepareSearch("idx")
-                .addAggregation(histogram("histo").script(new Script("doc['" + SINGLE_VALUED_FIELD_NAME + "'].value")).interval(interval))
+                .addAggregation(
+                        histogram("histo")
+                            .script(new Script("doc['l_value'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap()))
+                            .interval(interval))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -642,7 +697,10 @@ public class HistogramTests extends ESIntegTestCase {
 
     public void testScriptMultiValued() throws Exception {
         SearchResponse response = client().prepareSearch("idx")
-                .addAggregation(histogram("histo").script(new Script("doc['" + MULTI_VALUED_FIELD_NAME + "']")).interval(interval))
+                .addAggregation(
+                        histogram("histo")
+                                .script(new Script("doc['l_values']", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap()))
+                                .interval(interval))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -701,8 +759,11 @@ public class HistogramTests extends ESIntegTestCase {
         SearchResponse response = client()
                 .prepareSearch("idx", "idx_unmapped")
                 .addAggregation(
-                        histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(interval)
-                                .extendedBounds(new ExtendedBounds((long) -1 * 2 * interval, (long) valueCounts.length * interval))).execute().actionGet();
+                        histogram("histo")
+                                .field(SINGLE_VALUED_FIELD_NAME)
+                                .interval(interval)
+                                .extendedBounds(new ExtendedBounds((long) -1 * 2 * interval, (long) valueCounts.length * interval)))
+                .get();
 
         assertSearchResponse(response);
 

+ 71 - 20
modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/CardinalityTests.java → core/src/test/java/org/elasticsearch/search/aggregations/metrics/CardinalityIT.java

@@ -17,14 +17,15 @@
  * under the License.
  */
 
-package org.elasticsearch.messy.tests;
+package org.elasticsearch.search.aggregations.metrics;
 
 import org.elasticsearch.action.index.IndexRequestBuilder;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.index.fielddata.ScriptDocValues;
 import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.script.MockScriptPlugin;
 import org.elasticsearch.script.Script;
-import org.elasticsearch.script.groovy.GroovyPlugin;
 import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
 import org.elasticsearch.search.aggregations.bucket.global.Global;
 import org.elasticsearch.search.aggregations.bucket.terms.Terms;
@@ -33,9 +34,14 @@ import org.elasticsearch.test.ESIntegTestCase;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Function;
 
+import static java.util.Collections.emptyMap;
 import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.script.ScriptService.ScriptType;
 import static org.elasticsearch.search.aggregations.AggregationBuilders.cardinality;
 import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
 import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
@@ -45,11 +51,44 @@ import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.Matchers.notNullValue;
 
 @ESIntegTestCase.SuiteScopeTestCase
-public class CardinalityTests extends ESIntegTestCase {
+public class CardinalityIT extends ESIntegTestCase {
 
     @Override
     protected Collection<Class<? extends Plugin>> nodePlugins() {
-        return Collections.singleton(GroovyPlugin.class);
+        return Collections.singleton(CustomScriptPlugin.class);
+    }
+
+    public static class CustomScriptPlugin extends MockScriptPlugin {
+
+        @Override
+        protected Map<String, Function<Map<String, Object>, Object>> pluginScripts() {
+            Map<String, Function<Map<String, Object>, Object>> scripts = new HashMap<>();
+
+            scripts.put("_value", vars -> vars.get("_value"));
+
+            scripts.put("doc['str_value'].value", vars -> {
+                Map<?, ?> doc = (Map) vars.get("doc");
+                return doc.get("str_value");
+            });
+
+            scripts.put("doc['str_values'].values", vars -> {
+                Map<?, ?> doc = (Map) vars.get("doc");
+                ScriptDocValues.Strings strValue = (ScriptDocValues.Strings) doc.get("str_values");
+                return strValue.getValues();
+            });
+
+            scripts.put("doc[' + singleNumericField() + '].value", vars -> {
+                Map<?, ?> doc = (Map) vars.get("doc");
+                return doc.get(singleNumericField());
+            });
+
+            scripts.put("doc[' + multiNumericField(false) + '].values", vars -> {
+                Map<?, ?> doc = (Map) vars.get("doc");
+                return ((ScriptDocValues<?>) doc.get(multiNumericField(false))).getValues();
+            });
+
+            return scripts;
+        }
     }
 
     @Override
@@ -123,11 +162,11 @@ public class CardinalityTests extends ESIntegTestCase {
             assertThat(count.getValue(), greaterThan(0L));
         }
     }
-     private String singleNumericField() {
+     private static String singleNumericField() {
         return randomBoolean() ? "l_value" : "d_value";
     }
 
-    private String multiNumericField(boolean hash) {
+    private static String multiNumericField(boolean hash) {
         return randomBoolean() ? "l_values" : "d_values";
     }
 
@@ -264,7 +303,9 @@ public class CardinalityTests extends ESIntegTestCase {
     public void testSingleValuedStringScript() throws Exception {
         SearchResponse response = client().prepareSearch("idx").setTypes("type")
                 .addAggregation(
-                        cardinality("cardinality").precisionThreshold(precisionThreshold).script(new Script("doc['str_value'].value")))
+                        cardinality("cardinality")
+                                .precisionThreshold(precisionThreshold)
+                                .script(new Script("doc['str_value'].value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -278,7 +319,9 @@ public class CardinalityTests extends ESIntegTestCase {
     public void testMultiValuedStringScript() throws Exception {
         SearchResponse response = client().prepareSearch("idx").setTypes("type")
                 .addAggregation(
-                        cardinality("cardinality").precisionThreshold(precisionThreshold).script(new Script("doc['str_values'].values")))
+                        cardinality("cardinality")
+                                .precisionThreshold(precisionThreshold)
+                                .script(new Script("doc['str_values'].values", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -290,10 +333,9 @@ public class CardinalityTests extends ESIntegTestCase {
     }
 
     public void testSingleValuedNumericScript() throws Exception {
+        Script script = new Script("doc[' + singleNumericField() + '].value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap());
         SearchResponse response = client().prepareSearch("idx").setTypes("type")
-                .addAggregation(
-                        cardinality("cardinality").precisionThreshold(precisionThreshold).script(
-                                new Script("doc['" + singleNumericField() + "'].value")))
+                .addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).script(script))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -305,10 +347,9 @@ public class CardinalityTests extends ESIntegTestCase {
     }
 
     public void testMultiValuedNumericScript() throws Exception {
+        Script script = new Script("doc[' + multiNumericField(false) + '].values", ScriptType.INLINE, CustomScriptPlugin.NAME, null);
         SearchResponse response = client().prepareSearch("idx").setTypes("type")
-                .addAggregation(
-                        cardinality("cardinality").precisionThreshold(precisionThreshold).script(
-                                new Script("doc['" + multiNumericField(false) + "'].values")))
+                .addAggregation(cardinality("cardinality").precisionThreshold(precisionThreshold).script(script))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -322,7 +363,10 @@ public class CardinalityTests extends ESIntegTestCase {
     public void testSingleValuedStringValueScript() throws Exception {
         SearchResponse response = client().prepareSearch("idx").setTypes("type")
                 .addAggregation(
-                        cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_value").script(new Script("_value")))
+                        cardinality("cardinality")
+                                .precisionThreshold(precisionThreshold)
+                                .field("str_value")
+                                .script(new Script("_value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -336,7 +380,10 @@ public class CardinalityTests extends ESIntegTestCase {
     public void testMultiValuedStringValueScript() throws Exception {
         SearchResponse response = client().prepareSearch("idx").setTypes("type")
                 .addAggregation(
-                        cardinality("cardinality").precisionThreshold(precisionThreshold).field("str_values").script(new Script("_value")))
+                        cardinality("cardinality")
+                                .precisionThreshold(precisionThreshold)
+                                .field("str_values")
+                                .script(new Script("_value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -350,8 +397,10 @@ public class CardinalityTests extends ESIntegTestCase {
     public void testSingleValuedNumericValueScript() throws Exception {
         SearchResponse response = client().prepareSearch("idx").setTypes("type")
                 .addAggregation(
-                        cardinality("cardinality").precisionThreshold(precisionThreshold).field(singleNumericField())
-                                .script(new Script("_value")))
+                        cardinality("cardinality")
+                                .precisionThreshold(precisionThreshold)
+                                .field(singleNumericField())
+                                .script(new Script("_value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
                 .execute().actionGet();
 
         assertSearchResponse(response);
@@ -365,8 +414,10 @@ public class CardinalityTests extends ESIntegTestCase {
     public void testMultiValuedNumericValueScript() throws Exception {
         SearchResponse response = client().prepareSearch("idx").setTypes("type")
                 .addAggregation(
-                        cardinality("cardinality").precisionThreshold(precisionThreshold).field(multiNumericField(false))
-                                .script(new Script("_value")))
+                        cardinality("cardinality")
+                                .precisionThreshold(precisionThreshold)
+                                .field(multiNumericField(false))
+                                .script(new Script("_value", ScriptType.INLINE, CustomScriptPlugin.NAME, emptyMap())))
                 .execute().actionGet();
 
         assertSearchResponse(response);

+ 1 - 12
core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentileRanksIT.java

@@ -450,18 +450,7 @@ public class HDRPercentileRanksIT extends AbstractNumericTestCase {
     @Override
     public void testScriptMultiValuedWithParams() throws Exception {
         int sigDigits = randomSignificantDigits();
-        Map<String, Object> params = new HashMap<>();
-        params.put("dec", 1);
-
-        // Equivalent to:
-        //
-        // List values = doc['values'].values;
-        // double[] res = new double[values.size()];
-        // for (int i = 0; i < res.length; i++) {
-        //      res[i] = values.get(i) - dec;
-        // };
-        // return res;
-        Script script = new Script("decrement all values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+        Script script = AggregationTestScriptsPlugin.DECREMENT_ALL_VALUES;
 
         final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
         SearchResponse searchResponse = client()

+ 1 - 12
core/src/test/java/org/elasticsearch/search/aggregations/metrics/HDRPercentilesIT.java

@@ -436,18 +436,7 @@ public class HDRPercentilesIT extends AbstractNumericTestCase {
 
     @Override
     public void testScriptMultiValuedWithParams() throws Exception {
-        Map<String, Object> params = new HashMap<>();
-        params.put("dec", 1);
-
-        // Equivalent to:
-        //
-        // List values = doc['values'].values;
-        // double[] res = new double[values.size()];
-        // for (int i = 0; i < res.length; i++) {
-        //      res[i] = values.get(i) - dec;
-        // };
-        // return res;
-        Script script = new Script("decrement all values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+        Script script = AggregationTestScriptsPlugin.DECREMENT_ALL_VALUES;
 
         final double[] pcts = randomPercentiles();
         int sigDigits = randomSignificantDigits();

+ 67 - 45
modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java → core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java

@@ -16,21 +16,22 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.elasticsearch.messy.tests;
+package org.elasticsearch.search.aggregations.metrics;
 
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.common.logging.Loggers;
 import org.elasticsearch.common.util.CollectionUtils;
+import org.elasticsearch.index.fielddata.ScriptDocValues;
 import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.script.MockScriptPlugin;
 import org.elasticsearch.script.Script;
 import org.elasticsearch.script.ScriptService.ScriptType;
-import org.elasticsearch.script.groovy.GroovyPlugin;
+import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
 import org.elasticsearch.search.aggregations.bucket.filter.Filter;
 import org.elasticsearch.search.aggregations.bucket.global.Global;
 import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
 import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Order;
 import org.elasticsearch.search.aggregations.bucket.terms.Terms;
-import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
 import org.elasticsearch.search.aggregations.metrics.percentiles.Percentile;
 import org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanks;
 import org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanksAggregationBuilder;
@@ -42,7 +43,9 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Function;
 
+import static java.util.Collections.emptyMap;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
 import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 import static org.elasticsearch.search.aggregations.AggregationBuilders.filter;
@@ -57,13 +60,11 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.hamcrest.Matchers.sameInstance;
 
-/**
- *
- */
-public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
+public class TDigestPercentileRanksIT extends AbstractNumericTestCase {
+
     @Override
     protected Collection<Class<? extends Plugin>> nodePlugins() {
-        return Collections.singleton(GroovyPlugin.class);
+        return Collections.singleton(AggregationTestScriptsPlugin.class);
     }
 
     private static double[] randomPercents(long minValue, long maxValue) {
@@ -84,7 +85,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
             }
         }
         Arrays.sort(percents);
-        Loggers.getLogger(TDigestPercentileRanksTests.class).info("Using values={}", Arrays.toString(percents));
+        Loggers.getLogger(TDigestPercentileRanksIT.class).info("Using values={}", Arrays.toString(percents));
         return percents;
     }
 
@@ -198,8 +199,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
         PercentileRanks values = global.getAggregations().get("percentile_ranks");
         assertThat(values, notNullValue());
         assertThat(values.getName(), equalTo("percentile_ranks"));
-        assertThat((PercentileRanks) global.getProperty("percentile_ranks"), sameInstance(values));
-
+        assertThat(global.getProperty("percentile_ranks"), sameInstance(values));
     }
 
     public void testSingleValuedFieldOutsideRange() throws Exception {
@@ -238,9 +238,12 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentileRanks("percentile_ranks"))
-                        .field("value").script(new Script("_value - 1"))
-                        .values(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentileRanks("percentile_ranks"))
+                                .field("value")
+                                .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+                                .values(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -256,10 +259,12 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentileRanks("percentile_ranks"))
-                        .field("value")
-                                .script(new Script("_value - dec", ScriptType.INLINE, null, params))
-                        .values(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentileRanks("percentile_ranks"))
+                                .field("value")
+                                .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+                                .values(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -289,9 +294,12 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentileRanks("percentile_ranks"))
-                        .field("values").script(new Script("_value - 1"))
-                        .values(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentileRanks("percentile_ranks"))
+                                .field("values")
+                                .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+                                .values(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -304,9 +312,12 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercents(-maxValues, -minValues);
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentileRanks("percentile_ranks"))
-                        .field("values").script(new Script("_value * -1"))
-                        .values(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentileRanks("percentile_ranks"))
+                                .field("values")
+                                .script(new Script("_value * -1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+                                .values(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -322,10 +333,12 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentileRanks("percentile_ranks"))
-                        .field("values")
-                                .script(new Script("_value - dec", ScriptType.INLINE, null, params))
-                        .values(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentileRanks("percentile_ranks"))
+                                .field("values")
+                                .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+                                .values(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -339,9 +352,11 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercents(minValue, maxValue);
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentileRanks("percentile_ranks"))
-                        .script(new Script("doc['value'].value"))
-                        .values(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentileRanks("percentile_ranks"))
+                                .script(new Script("doc['value'].value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+                                .values(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -354,13 +369,17 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
     public void testScriptSingleValuedWithParams() throws Exception {
         Map<String, Object> params = new HashMap<>();
         params.put("dec", 1);
+
+        Script script = new Script("doc['value'].value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+
         final double[] pcts = randomPercents(minValue - 1, maxValue - 1);
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentileRanks("percentile_ranks"))
-                        .script(
-                                new Script("doc['value'].value - dec", ScriptType.INLINE, null, params))
-                        .values(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentileRanks("percentile_ranks"))
+                                .script(script)
+                                .values(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -372,11 +391,14 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
     @Override
     public void testScriptMultiValued() throws Exception {
         final double[] pcts = randomPercents(minValues, maxValues);
+        Script script = new Script("doc['values'].values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentileRanks("percentile_ranks"))
-                        .script(new Script("doc['values'].values"))
-                        .values(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentileRanks("percentile_ranks"))
+                                .script(script)
+                                .values(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -387,16 +409,16 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase {
 
     @Override
     public void testScriptMultiValuedWithParams() throws Exception {
-        Map<String, Object> params = new HashMap<>();
-        params.put("dec", 1);
+        Script script = AggregationTestScriptsPlugin.DECREMENT_ALL_VALUES;
+
         final double[] pcts = randomPercents(minValues - 1, maxValues - 1);
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentileRanks("percentile_ranks"))
-                                .script(new Script(
-                                        "List values = doc['values'].values; double[] res = new double[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = values.get(i) - dec; }; return res;",
-                                        ScriptType.INLINE, null, params))
-                        .values(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentileRanks("percentile_ranks"))
+                                .script(script)
+                                .values(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);

+ 67 - 48
modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java → core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java

@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.elasticsearch.messy.tests;
+package org.elasticsearch.search.aggregations.metrics;
 
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.common.logging.Loggers;
@@ -24,13 +24,12 @@ import org.elasticsearch.common.util.CollectionUtils;
 import org.elasticsearch.plugins.Plugin;
 import org.elasticsearch.script.Script;
 import org.elasticsearch.script.ScriptService.ScriptType;
-import org.elasticsearch.script.groovy.GroovyPlugin;
+import org.elasticsearch.search.aggregations.AggregationTestScriptsPlugin;
 import org.elasticsearch.search.aggregations.bucket.filter.Filter;
 import org.elasticsearch.search.aggregations.bucket.global.Global;
 import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
 import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Order;
 import org.elasticsearch.search.aggregations.bucket.terms.Terms;
-import org.elasticsearch.search.aggregations.metrics.AbstractNumericTestCase;
 import org.elasticsearch.search.aggregations.metrics.percentiles.Percentile;
 import org.elasticsearch.search.aggregations.metrics.percentiles.Percentiles;
 import org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesAggregationBuilder;
@@ -43,6 +42,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import static java.util.Collections.emptyMap;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
 import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 import static org.elasticsearch.search.aggregations.AggregationBuilders.filter;
@@ -57,13 +57,11 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.hamcrest.Matchers.sameInstance;
 
-/**
- *
- */
-public class TDigestPercentilesTests extends AbstractNumericTestCase {
+public class TDigestPercentilesIT extends AbstractNumericTestCase {
+
     @Override
     protected Collection<Class<? extends Plugin>> nodePlugins() {
-        return Collections.singleton(GroovyPlugin.class);
+        return Collections.singleton(AggregationTestScriptsPlugin.class);
     }
 
     private static double[] randomPercentiles() {
@@ -83,7 +81,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
             }
         }
         Arrays.sort(percentiles);
-        Loggers.getLogger(TDigestPercentilesTests.class).info("Using percentiles={}", Arrays.toString(percentiles));
+        Loggers.getLogger(TDigestPercentilesIT.class).info("Using percentiles={}", Arrays.toString(percentiles));
         return percentiles;
     }
 
@@ -197,8 +195,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
         Percentiles percentiles = global.getAggregations().get("percentiles");
         assertThat(percentiles, notNullValue());
         assertThat(percentiles.getName(), equalTo("percentiles"));
-        assertThat((Percentiles) global.getProperty("percentiles"), sameInstance(percentiles));
-
+        assertThat(global.getProperty("percentiles"), sameInstance(percentiles));
     }
 
     @Override
@@ -222,9 +219,12 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercentiles();
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentiles("percentiles"))
-.field("value").script(new Script("_value - 1"))
-                        .percentiles(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentiles("percentiles"))
+                                    .field("value")
+                                    .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+                                    .percentiles(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -240,10 +240,12 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercentiles();
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentiles("percentiles"))
-.field("value")
-                                .script(new Script("_value - dec", ScriptType.INLINE, null, params))
-                        .percentiles(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentiles("percentiles"))
+                                    .field("value")
+                                    .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+                                .percentiles(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -257,9 +259,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercentiles();
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentiles("percentiles"))
-                        .field("values")
-                        .percentiles(pcts))
+                .addAggregation(randomCompression(percentiles("percentiles")).field("values").percentiles(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -273,9 +273,12 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercentiles();
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentiles("percentiles"))
-.field("values").script(new Script("_value - 1"))
-                        .percentiles(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentiles("percentiles"))
+                                    .field("values")
+                                .script(new Script("_value - 1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+                                .percentiles(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -288,9 +291,12 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercentiles();
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentiles("percentiles"))
-                        .field("values").script(new Script("_value * -1"))
-                        .percentiles(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentiles("percentiles"))
+                                    .field("values")
+                                    .script(new Script("_value * -1", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap()))
+                                    .percentiles(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -306,10 +312,12 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
         final double[] pcts = randomPercentiles();
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentiles("percentiles"))
-.field("values")
-                                .script(new Script("_value - dec", ScriptType.INLINE, null, params))
-                        .percentiles(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentiles("percentiles"))
+                                    .field("values")
+                                    .script(new Script("_value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params))
+                                    .percentiles(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -320,12 +328,15 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
 
     @Override
     public void testScriptSingleValued() throws Exception {
+        Script script = new Script("doc['value'].value", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
         final double[] pcts = randomPercentiles();
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentiles("percentiles"))
-.script(new Script("doc['value'].value"))
-                        .percentiles(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentiles("percentiles"))
+                                    .script(script)
+                                    .percentiles(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -338,13 +349,17 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
     public void testScriptSingleValuedWithParams() throws Exception {
         Map<String, Object> params = new HashMap<>();
         params.put("dec", 1);
+
+        Script script = new Script("doc['value'].value - dec", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, params);
+
         final double[] pcts = randomPercentiles();
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentiles("percentiles"))
-                        .script(
-                                new Script("doc['value'].value - dec", ScriptType.INLINE, null, params))
-                        .percentiles(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentiles("percentiles"))
+                                .script(script)
+                                .percentiles(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -356,11 +371,15 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
     @Override
     public void testScriptMultiValued() throws Exception {
         final double[] pcts = randomPercentiles();
+        Script script = new Script("doc['values'].values", ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, emptyMap());
+
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentiles("percentiles"))
-.script(new Script("doc['values'].values"))
-                        .percentiles(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentiles("percentiles"))
+                                    .script(script)
+                                    .percentiles(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);
@@ -371,16 +390,16 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase {
 
     @Override
     public void testScriptMultiValuedWithParams() throws Exception {
-        Map<String, Object> params = new HashMap<>();
-        params.put("dec", 1);
+        Script script = AggregationTestScriptsPlugin.DECREMENT_ALL_VALUES;
+
         final double[] pcts = randomPercentiles();
         SearchResponse searchResponse = client().prepareSearch("idx")
                 .setQuery(matchAllQuery())
-                .addAggregation(randomCompression(percentiles("percentiles"))
-                                .script(new Script(
-                                        "List values = doc['values'].values; double[] res = new double[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = values.get(i) - dec; }; return res;",
-                                        ScriptType.INLINE, null, params))
-                        .percentiles(pcts))
+                .addAggregation(
+                        randomCompression(
+                                percentiles("percentiles"))
+                                    .script(script)
+                                    .percentiles(pcts))
                 .execute().actionGet();
 
         assertHitCount(searchResponse, 10);

+ 0 - 6
modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/package-info.java

@@ -37,22 +37,18 @@
 /* List of renames that took place:
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/AvgTests.java
   renamed:    core/src/test/java/org/elasticsearch/document/BulkIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BulkTests.java
-  renamed:    core/src/test/java/org/elasticsearch/search/aggregations/metrics/CardinalityIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/CardinalityTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ChildQuerySearchTests.java
   renamed:    core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ContextAndHeaderTransportTests.java
   ^^^^^ note: the methods from this test using mustache were moved to the mustache module under its messy tests package.
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateHistogramTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateRangeIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateRangeTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/bucket/DoubleTermsIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DoubleTermsTests.java
-  renamed:    core/src/test/java/org/elasticsearch/search/aggregations/EquivalenceIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/EquivalenceTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ExtendedStatsTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/FunctionScoreTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/geo/GeoDistanceIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoDistanceTests.java
-  renamed:    core/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/bucket/IPv4RangeIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IPv4RangeTests.java
   renamed:    core/src/test/java/org/elasticsearch/script/IndexLookupIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexLookupTests.java
   renamed:    core/src/test/java/org/elasticsearch/script/IndexedScriptIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexedScriptTests.java
-  renamed:    core/src/test/java/org/elasticsearch/action/IndicesRequestIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/InnerHitsTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/bucket/LongTermsIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/LongTermsTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MaxTests.java
@@ -72,8 +68,6 @@
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/metrics/StatsIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StatsTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SumTests.java
-  renamed:    core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentileRanksIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java
-  renamed:    core/src/test/java/org/elasticsearch/search/aggregations/metrics/TDigestPercentilesIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java
   renamed:    core/src/test/java/org/elasticsearch/search/aggregations/bucket/TopHitsIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TopHitsTests.java
   renamed:    core/src/test/java/org/elasticsearch/index/mapper/TransformOnIndexMapperIT.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TransformOnIndexMapperTests.java
   renamed:    core/src/main/java/org/elasticsearch/script/groovy/GroovyScriptCompilationException.java -> plugins/lang-groovy/src/test/java/org/elasticsearch/script/groovy/GroovyRestIT.java