Skip to content

Commit a36827c

Browse files
committed
Move tests to elasticsearch test framework
Closes #10.
1 parent 40f89f7 commit a36827c

File tree

4 files changed

+182
-130
lines changed

4 files changed

+182
-130
lines changed

pom.xml

Lines changed: 104 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@
3131
</parent>
3232

3333
<properties>
34-
<elasticsearch.version>0.90.1</elasticsearch.version>
34+
<elasticsearch.version>0.90.10</elasticsearch.version>
35+
<lucene.version>4.6.0</lucene.version>
36+
<tests.jvms>1</tests.jvms>
37+
<tests.shuffle>true</tests.shuffle>
38+
<tests.output>onerror</tests.output>
39+
<tests.client.ratio></tests.client.ratio>
40+
<es.logger.level>INFO</es.logger.level>
3541
</properties>
3642

3743
<repositories>
@@ -42,6 +48,13 @@
4248
</repositories>
4349

4450
<dependencies>
51+
<dependency>
52+
<groupId>org.apache.lucene</groupId>
53+
<artifactId>lucene-test-framework</artifactId>
54+
<version>${lucene.version}</version>
55+
<scope>test</scope>
56+
</dependency>
57+
4558
<dependency>
4659
<groupId>org.elasticsearch</groupId>
4760
<artifactId>elasticsearch</artifactId>
@@ -65,9 +78,10 @@
6578
</dependency>
6679

6780
<dependency>
68-
<groupId>org.testng</groupId>
69-
<artifactId>testng</artifactId>
70-
<version>6.3.1</version>
81+
<groupId>org.elasticsearch</groupId>
82+
<artifactId>elasticsearch</artifactId>
83+
<version>${elasticsearch.version}</version>
84+
<type>test-jar</type>
7185
<scope>test</scope>
7286
</dependency>
7387

@@ -98,13 +112,95 @@
98112
</configuration>
99113
</plugin>
100114
<plugin>
115+
<groupId>com.carrotsearch.randomizedtesting</groupId>
116+
<artifactId>junit4-maven-plugin</artifactId>
117+
<version>2.0.12</version>
118+
<executions>
119+
<execution>
120+
<id>tests</id>
121+
<phase>test</phase>
122+
<goals>
123+
<goal>junit4</goal>
124+
</goals>
125+
<configuration>
126+
<heartbeat>20</heartbeat>
127+
<jvmOutputAction>pipe,warn</jvmOutputAction>
128+
<leaveTemporary>true</leaveTemporary>
129+
<listeners>
130+
<report-ant-xml mavenExtensions="true"
131+
dir="${project.build.directory}/surefire-reports"/>
132+
<report-text
133+
showThrowable="true"
134+
showStackTraces="true"
135+
showOutput="${tests.output}"
136+
showStatusOk="false"
137+
showStatusError="true"
138+
showStatusFailure="true"
139+
showStatusIgnored="true"
140+
showSuiteSummary="true"
141+
timestamps="false"/>
142+
<report-execution-times file="${basedir}/.local-execution-hints.log"/>
143+
</listeners>
144+
<assertions>
145+
<enable/>
146+
</assertions>
147+
<parallelism>${tests.jvms}</parallelism>
148+
<balancers>
149+
<execution-times>
150+
<fileset dir="${basedir}" includes=".local-execution-hints.log"/>
151+
</execution-times>
152+
</balancers>
153+
<includes>
154+
<include>**/*Tests.class</include>
155+
<include>**/*Test.class</include>
156+
</includes>
157+
<excludes>
158+
<exclude>**/Abstract*.class</exclude>
159+
<exclude>**/*StressTest.class</exclude>
160+
</excludes>
161+
<jvmArgs>
162+
<param>-Xmx512m</param>
163+
<param>-XX:MaxDirectMemorySize=512m</param>
164+
<param>-Des.logger.prefix=</param>
165+
</jvmArgs>
166+
<shuffleOnSlave>${tests.shuffle}</shuffleOnSlave>
167+
<sysouts>${tests.verbose}</sysouts>
168+
<seed>${tests.seed}</seed>
169+
<haltOnFailure>${tests.failfast}</haltOnFailure>
170+
<systemProperties>
171+
<!-- RandomizedTesting library system properties -->
172+
<tests.iters>${tests.iters}</tests.iters>
173+
<tests.maxfailures>${tests.maxfailures}</tests.maxfailures>
174+
<tests.failfast>${tests.failfast}</tests.failfast>
175+
<tests.class>${tests.class}</tests.class>
176+
<tests.method>${tests.method}</tests.method>
177+
<tests.nightly>${tests.nightly}</tests.nightly>
178+
<tests.badapples>${tests.badapples}</tests.badapples>
179+
<tests.weekly>${tests.weekly}</tests.weekly>
180+
<tests.slow>${tests.slow}</tests.slow>
181+
<tests.awaitsfix>${tests.awaitsfix}</tests.awaitsfix>
182+
<tests.slow>${tests.slow}</tests.slow>
183+
<tests.timeoutSuite>${tests.timeoutSuite}</tests.timeoutSuite>
184+
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
185+
<tests.integration>${tests.integration}</tests.integration>
186+
<tests.cluster_seed>${tests.cluster_seed}</tests.cluster_seed>
187+
<tests.client.ratio>${tests.client.ratio}</tests.client.ratio>
188+
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
189+
<es.node.mode>${es.node.mode}</es.node.mode>
190+
<es.logger.level>${es.logger.level}</es.logger.level>
191+
<java.awt.headless>true</java.awt.headless>
192+
</systemProperties>
193+
</configuration>
194+
</execution>
195+
</executions>
196+
</plugin>
197+
<plugin>
198+
<!-- we skip surefire to work with randomized testing above -->
101199
<groupId>org.apache.maven.plugins</groupId>
102200
<artifactId>maven-surefire-plugin</artifactId>
103-
<version>2.11</version>
201+
<version>2.15</version>
104202
<configuration>
105-
<includes>
106-
<include>**/*Tests.java</include>
107-
</includes>
203+
<skipTests>true</skipTests>
108204
</configuration>
109205
</plugin>
110206
<plugin>

src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineTests.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,31 @@
2323
import org.elasticsearch.common.collect.MapBuilder;
2424
import org.elasticsearch.common.settings.ImmutableSettings;
2525
import org.elasticsearch.script.ExecutableScript;
26-
import org.testng.annotations.AfterClass;
27-
import org.testng.annotations.BeforeClass;
28-
import org.testng.annotations.Test;
26+
import org.elasticsearch.test.ElasticsearchTestCase;
27+
import org.junit.After;
28+
import org.junit.Before;
29+
import org.junit.Test;
2930

3031
import java.util.HashMap;
3132
import java.util.List;
3233
import java.util.Map;
3334

34-
import static org.hamcrest.MatcherAssert.assertThat;
3535
import static org.hamcrest.Matchers.equalTo;
3636
import static org.hamcrest.Matchers.instanceOf;
3737

3838
/**
3939
*
4040
*/
41-
public class JavaScriptScriptEngineTests {
41+
public class JavaScriptScriptEngineTests extends ElasticsearchTestCase {
4242

4343
private JavaScriptScriptEngineService se;
4444

45-
@BeforeClass
45+
@Before
4646
public void setup() {
4747
se = new JavaScriptScriptEngineService(ImmutableSettings.Builder.EMPTY_SETTINGS);
4848
}
4949

50-
@AfterClass
50+
@After
5151
public void close() {
5252
se.close();
5353
}

src/test/java/org/elasticsearch/script/javascript/JavaScriptScriptMultiThreadedTest.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,24 @@
1919

2020
package org.elasticsearch.script.javascript;
2121

22-
import org.elasticsearch.common.logging.ESLogger;
23-
import org.elasticsearch.common.logging.Loggers;
2422
import org.elasticsearch.common.settings.ImmutableSettings;
2523
import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom;
2624
import org.elasticsearch.script.ExecutableScript;
27-
import org.testng.annotations.Test;
25+
import org.elasticsearch.test.ElasticsearchTestCase;
26+
import org.junit.Test;
2827

2928
import java.util.HashMap;
3029
import java.util.Map;
3130
import java.util.concurrent.CountDownLatch;
3231
import java.util.concurrent.CyclicBarrier;
3332
import java.util.concurrent.atomic.AtomicBoolean;
3433

35-
import static org.hamcrest.MatcherAssert.assertThat;
3634
import static org.hamcrest.Matchers.equalTo;
3735

3836
/**
3937
*
4038
*/
41-
@Test
42-
public class JavaScriptScriptMultiThreadedTest {
43-
44-
protected final ESLogger logger = Loggers.getLogger(getClass());
39+
public class JavaScriptScriptMultiThreadedTest extends ElasticsearchTestCase {
4540

4641
@Test
4742
public void testExecutableNoRuntimeParams() throws Exception {

0 commit comments

Comments
 (0)