Skip to content

Commit c065e38

Browse files
committed
Move tests to elasticsearch test framework
Closes #6.
1 parent de2ae17 commit c065e38

File tree

5 files changed

+178
-120
lines changed

5 files changed

+178
-120
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/target
66
.DS_Store
77
*.iml
8+
.local-execution-hints.log

pom.xml

+104-8
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
</parent>
3131

3232
<properties>
33-
<elasticsearch.version>0.90.0.Beta1</elasticsearch.version>
33+
<elasticsearch.version>0.90.10</elasticsearch.version>
34+
<lucene.version>4.6.0</lucene.version>
35+
<tests.jvms>1</tests.jvms>
36+
<tests.shuffle>true</tests.shuffle>
37+
<tests.output>onerror</tests.output>
38+
<tests.client.ratio></tests.client.ratio>
39+
<es.logger.level>INFO</es.logger.level>
3440
</properties>
3541

3642
<repositories>
@@ -41,6 +47,13 @@
4147
</repositories>
4248

4349
<dependencies>
50+
<dependency>
51+
<groupId>org.apache.lucene</groupId>
52+
<artifactId>lucene-test-framework</artifactId>
53+
<version>${lucene.version}</version>
54+
<scope>test</scope>
55+
</dependency>
56+
4457
<dependency>
4558
<groupId>org.elasticsearch</groupId>
4659
<artifactId>elasticsearch</artifactId>
@@ -63,9 +76,10 @@
6376
</dependency>
6477

6578
<dependency>
66-
<groupId>org.testng</groupId>
67-
<artifactId>testng</artifactId>
68-
<version>6.3.1</version>
79+
<groupId>org.elasticsearch</groupId>
80+
<artifactId>elasticsearch</artifactId>
81+
<version>${elasticsearch.version}</version>
82+
<type>test-jar</type>
6983
<scope>test</scope>
7084
</dependency>
7185

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

src/test/java/org/elasticsearch/script/python/PythonScriptEngineTests.java

+11-8
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,34 @@
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.Map;
3233

33-
import static org.hamcrest.MatcherAssert.assertThat;
3434
import static org.hamcrest.Matchers.equalTo;
3535
import static org.hamcrest.Matchers.instanceOf;
3636

3737
/**
3838
*
3939
*/
40-
@Test
41-
public class PythonScriptEngineTests {
40+
public class PythonScriptEngineTests extends ElasticsearchTestCase {
4241

4342
private PythonScriptEngineService se;
4443

45-
@BeforeClass
44+
@Before
4645
public void setup() {
4746
se = new PythonScriptEngineService(ImmutableSettings.Builder.EMPTY_SETTINGS);
4847
}
4948

50-
@AfterClass
49+
@After
5150
public void close() {
51+
// We need to clear some system properties
52+
System.clearProperty("python.cachedir.skip");
53+
System.clearProperty("python.console.encoding");
5254
se.close();
5355
}
5456

@@ -95,6 +97,7 @@ public void testObjectMapInter() {
9597

9698
@Test
9799
public void testAccessListInScript() {
100+
98101
Map<String, Object> vars = new HashMap<String, Object>();
99102
Map<String, Object> obj2 = MapBuilder.<String, Object>newMapBuilder().put("prop2", "value2").map();
100103
Map<String, Object> obj1 = MapBuilder.<String, Object>newMapBuilder().put("prop1", "value1").put("obj2", obj2).map();

src/test/java/org/elasticsearch/script/python/PythonScriptMultiThreadedTest.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,32 @@
1919

2020
package org.elasticsearch.script.python;
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.After;
27+
import org.junit.Test;
2828

2929
import java.util.HashMap;
3030
import java.util.Map;
3131
import java.util.concurrent.CountDownLatch;
3232
import java.util.concurrent.CyclicBarrier;
3333
import java.util.concurrent.atomic.AtomicBoolean;
3434

35-
import static org.hamcrest.MatcherAssert.assertThat;
3635
import static org.hamcrest.Matchers.equalTo;
3736

3837
/**
3938
*
4039
*/
41-
@Test
42-
public class PythonScriptMultiThreadedTest {
40+
public class PythonScriptMultiThreadedTest extends ElasticsearchTestCase {
4341

44-
protected final ESLogger logger = Loggers.getLogger(getClass());
42+
@After
43+
public void close() {
44+
// We need to clear some system properties
45+
System.clearProperty("python.cachedir.skip");
46+
System.clearProperty("python.console.encoding");
47+
}
4548

4649
@Test
4750
public void testExecutableNoRuntimeParams() throws Exception {

0 commit comments

Comments
 (0)