Massimo Manfredino
Massimo Manfredino

Reputation: 21

Arquillian ContiPerf integration

I have successfully developed a toy unit test on ContiPerf 2. When I try to do the same on an Arquillian unit test, the ContiPerf annotation @PerfTest seems not working, while the annotation @Required goes fine. My test class looks like

@RunWith(Arquillian.class)
public class PerformanceFacadeBeanTest {

    @Rule
    public ContiPerfRule i = new ContiPerfRule();

    @EJB
    private PerformanceFacadeRemote performanceRemote;

    @Deployment
    public static Archive<EnterpriseArchive> createArchive() {
        ...
    }

    @Test
    @InSequence(value=1)
    @PerfTest(invocations = 100, threads = 5)
    @Required(max = 1200, average = 250)
    public void testPerformanceOnCacheLocal() {
    testPerformanceOnCache(performanceLocal);
    }

    private void testPerformanceOnCache(PerformanceFacade performanceFacade) {
    performanceFacade.performOnCache();
    }
}

and the exception I get is

org.databene.contiperf.PerfTestExecutionError: org.junit.internal.runners.model.MultipleFailureException: There were 2 errors:
  java.lang.NullPointerException(null)
  java.lang.NullPointerException(null)
    at org.databene.contiperf.util.ContiPerfUtil.executionError(ContiPerfUtil.java:66)
    at org.databene.contiperf.junit.JUnitInvoker.invoke(JUnitInvoker.java:54)
    at org.databene.contiperf.util.InvokerProxy.invoke(InvokerProxy.java:46)
    at org.databene.contiperf.PerformanceTracker.invoke(PerformanceTracker.java:97)
    at org.databene.contiperf.CountRunner.run(CountRunner.java:52)
    at java.lang.Thread.run(Thread.java:722)

Any thoughts? I can post my pom.xml, if needed.

Upvotes: 1

Views: 511

Answers (1)

Vineet Reynolds
Vineet Reynolds

Reputation: 76709

At the moment, you cannot use ContiPerf2 with Arquillian. Currently, Arquillian uses ThreadLocal instances for book keeping that are not available to threads spawned by the ContiPerf rule. Hence, the NullPointerException since the Arquillian testrunner would fail to locate the ThreadLocal instance in possibly all but one thread. This behavior of Arquillian may change in a future release; no promises in that area though.

I would recommend using JUnitBenchmarks for now, since it was reported to work correctly through a custom Arquillian extension.

Upvotes: 0

Related Questions