SamCat
SamCat

Reputation: 23

elasticsearch ElasticsearchIntegrationTest

I have written an integration test for ElasticSearch by extending ElasticsearchIntegrationTest. Top section of the test below:

import org.junit.*;
import static org.junit.Assert.assertEquals;

import org.elasticsearch.test.ElasticsearchIntegrationTest;

public class ProductSearchTest extends ElasticsearchIntegrationTest

I'm seeing this error from JUnit when trying to run the test via maven

java.lang.NoSuchMethodError: com.carrotsearch.randomizedtesting.RandomizedContext.runWithPrivateRandomness(Lcom/carrotsearch/randomizedtesting/Randomness;Ljava/util/concurrent/Callable;)Ljava/lang/Object; at __randomizedtesting.SeedInfo.seed([9DE685AB75B54F0A:10B1B129F9E3CB67]:0)

I've included the dependencies in the pom as described on the elasticsearch site

<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-test-framework</artifactId>
    <version>4.10.2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>1.4.0</version>
    <scope>test</scope>
    <type>test-jar</type>
</dependency>
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>1.4.0</version>
    <scope>test</scope>
</dependency>

Has anyone seen this before? It looks like i'm missing a dependency (i've tried adding a couple of the carrotsearch maven dependencies into the pom without success). Alternatively, does anyone have the integration tests working with the versions I am using, so at least if I expend hours trying to locate the dependency issue I can be confident it will work once identified.

Thank you for your time.

Upvotes: 2

Views: 2366

Answers (1)

Andrei Stefan
Andrei Stefan

Reputation: 52366

Indeed, it seems there is a mismatch between the randomizedtesting jar Lucene uses and the one ES uses. Try this in your pom.xml:

    <dependency>
        <groupId>org.apache.lucene</groupId>
        <artifactId>lucene-test-framework</artifactId>
        <version>4.10.2</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>randomizedtesting-runner</artifactId>
                <groupId>
                    com.carrotsearch.randomizedtesting
                </groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>1.4.0</version>
        <scope>test</scope>
        <type>test-jar</type>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>1.4.0</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.carrotsearch.randomizedtesting</groupId>
        <artifactId>randomizedtesting-runner</artifactId>
        <version>2.1.10</version>
        <scope>test</scope>
    </dependency>

Upvotes: 4

Related Questions