In an external plugin, there are errors when I run tests


#1

Hi, I want to test my custom es plugin (6.4.0)
every time I run gradle test, this error occurs.

Exception thrown by subscriber method onHeartbeat(com.carrotsearch.ant.tasks.junit4.events.aggregated.HeartBeatEvent) on subscriber com.carrotsearch.gradle.junit4.TestProgressLogger@437b66e when dispatching event: com.carrotsearch.ant.tasks.junit4.events.aggregated.HeartBeatEvent@593ec899
java.lang.NullPointerException: Cannot get property 'className' on null object
        at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60)
        at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)
        at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:47)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
        at com.carrotsearch.gradle.junit4.TestProgressLogger.onHeartbeat(TestProgressLogger.groovy:161)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:95)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:154)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber$1.run(Subscriber.java:80)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:456)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:76)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:119)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.EventBus.post(EventBus.java:215)
        at com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatingListener.slowHeartBeat(AggregatingListener.java:76)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:95)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:154)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber$1.run(Subscriber.java:80)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:456)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:76)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:119)
        at com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.EventBus.post(EventBus.java:215)
        at com.carrotsearch.ant.tasks.junit4.LocalSlaveStreamHandler$3.run(LocalSlaveStreamHandler.java:149)

Tests succeed. but I want to remove this errors.

+++++

Here is my environment.

  Gradle Version        : 4.9
  OS Info               : Mac OS X 10.12.6 (x86_64)
  JDK Version           : Oracle Corporation 10.0.2 [OpenJDK 64-Bit Server VM 10.0.2+13]
  JAVA_HOME             : /Users/user/.sdkman/candidates/java/10.0.2-open

(Ryan Ernst) #2

What do your tests look like? Are they all using junit? The class name comes back from the JUnit description of the class that randomized runner gets programmatically.


#3

Hi, Here is my test.

public class PluginEnvironmentTests extends ESTestCase {

    public void testGetPluginSettings() {
        // given
        Setting<String> clusterName = new Setting<>("plugin.cluster.name", s -> "elasticsearch", Function.identity(),
                Setting.Property.NodeScope);
        PluginEnvironment environment = new PluginEnvironment(clusterName);

        // when
        List<Setting<?>> PluginSettings = environment.getPluginSettings();

        // then
        assertEquals(PluginSettings.size(), 15);
        assertEquals(PluginSettings.get(0), environment.getClusterName());
        assertEquals(PluginSettings.get(1), environment.getInterval());
        assertEquals(PluginSettings.get(2), environment.getEnabled());
        assertEquals(PluginSettings.get(3), environment.getHosts());
        ...
    }

}

(Ryan Ernst) #4

What does your classpath look like?


#5

I copied my test class path.

${projectRoot}/src/test/java/${myPackagePath}/PluginEnvironmentTests.java

and I do not set special classpath var anywhere.


(Ryan Ernst) #6

I'm not sure what you mean by that being your classpath. The classpath should contain jar files, not a java file. You need to include all the jars that are dependencies of the elasticsearch test framework jar.


#7

Now I understand what you mean.
Thanks for your help. I solved my issue.
I added the test framework jar in my build script.


(system) #8

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.