I've got a fairly weird issue that I'm having trouble tracking down. I'm writing a plugin for a weighted average aggregation here. If I run the one integration test I have, WeightedAverageIT, via IntelliJ, the plugin I'm trying to test is loaded and the tests run without error. If I run the same tests from the commandline with gradle 2.13, the tests error out because none of the node plugins are loaded. I'm a bit baffled at how that could be. Any suggestions on where to start digging?
Below is the start of my test. I've also tried making all of the tests no ops and the same result occurred.
public class WeightedAverageIT extends AbstractNumericTestCase {
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(
WeightedAveragePlugin.class,
ExtractFieldScriptPlugin.class,
FieldValueScriptPlugin.class);
}
It doesn't even try to load the plugins. I get errors like Caused by: java.lang.IllegalArgumentException: script_lang not supported [field_value] and Caused by: java.lang.IllegalArgumentException: Unknown NamedWriteable [org.elasticsearch.search.aggregations.InternalAggregation][weightedAverage].
I've put the log of the build output here. Adding a logline to nodePlugins() did not print the logline when running via commandline.
Just not your test plugin.... I'm not sure what is up.
You should be able to connect to the test and debug it if you run gradle with --debug-jvm. That'll pause until you connect. I'd drop a breakpoint in buildTestCluster and then connect and play around.
So I tried debugging, but the --debug-jvm option only debugs the ES nodes. I have fixed the issue with java.lang.IllegalArgumentException: Unknown NamedWriteable [org.elasticsearch.search.aggregations.InternalAggregation][weightedAverage] (I wasn't passing a name to addResultReader). However, it seems like the inner classes from my test ExtractFieldScriptPlugin and FieldValueScriptPlugin, which are modeled after the AvgIT test, are not being loaded when running from the command line.
After some digging I've found that the issue only exists when using the gradle plugin elasticsearch.esplugin. If I use the gradle plugin elasticsearch.build and explicitly define dependencies, then plugins defined in the nodePlugins() are loaded. I'm going to do a bit more digging to try and understand how the integTest task is different between the two gradle plugins.
Well I figured it out. It's this bit of configuration
project.namingConventions {
// Plugins declare integration tests as "Tests" instead of IT.
skipIntegTestInDisguise = true
}
I just had to rename my test to end in Tests rather than IT.
I could've skipped over some configuration, but I'm not sure that fact is made clear in the current plugin author documentation. Since there are no aggregation plugins inside of the elasticsearch project I've been cribbing off of the core aggregation tests.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.