Skip to content

Commit

Permalink
Move tests to elasticsearch test framework
Browse files Browse the repository at this point in the history
Closes fabric8io#16.
  • Loading branch information
dadoonet committed Mar 12, 2014
1 parent f39ba93 commit 6aa36aa
Show file tree
Hide file tree
Showing 22 changed files with 610 additions and 224 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/.project
/.classpath
*.vmoptions
.local-execution-hints.log
95 changes: 95 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ governing permissions and limitations under the License. -->
<tests.shuffle>true</tests.shuffle>
<tests.output>onerror</tests.output>
<tests.client.ratio></tests.client.ratio>
<es.plugin.port>9300</es.plugin.port>
<es.logger.level>INFO</es.logger.level>
</properties>

Expand Down Expand Up @@ -145,6 +146,7 @@ governing permissions and limitations under the License. -->
<directory>src/test/resources</directory>
<filtering>true</filtering>
<includes>
<include>plugin-test.properties</include>
<include>elasticsearch.yml</include>
</includes>
</testResource>
Expand All @@ -166,10 +168,103 @@ governing permissions and limitations under the License. -->
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>junit4-maven-plugin</artifactId>
<version>2.0.14</version>
<executions>
<execution>
<id>tests</id>
<phase>test</phase>
<goals>
<goal>junit4</goal>
</goals>
<configuration>
<heartbeat>20</heartbeat>
<jvmOutputAction>pipe,warn</jvmOutputAction>
<leaveTemporary>true</leaveTemporary>
<listeners>
<report-ant-xml mavenExtensions="true"
dir="${project.build.directory}/surefire-reports"/>
<report-text
showThrowable="true"
showStackTraces="true"
showOutput="${tests.output}"
showStatusOk="false"
showStatusError="true"
showStatusFailure="true"
showStatusIgnored="true"
showSuiteSummary="true"
timestamps="false"/>
<report-execution-times file="${basedir}/.local-execution-hints.log"/>
</listeners>
<assertions>
<enable/>
</assertions>
<parallelism>${tests.jvms}</parallelism>
<balancers>
<execution-times>
<fileset dir="${basedir}" includes=".local-execution-hints.log"/>
</execution-times>
</balancers>
<includes>
<include>**/*Tests.class</include>
<include>**/*Test.class</include>
</includes>
<excludes>
<exclude>**/Abstract*.class</exclude>
<exclude>**/*StressTest.class</exclude>
</excludes>
<argLine>
${tests.jvm.argline}
</argLine>
<jvmArgs>
<param>-Xmx512m</param>
<param>-Xss256k</param>
<param>-XX:MaxDirectMemorySize=512m</param>
<param>-Des.logger.prefix=</param>
</jvmArgs>
<shuffleOnSlave>${tests.shuffle}</shuffleOnSlave>
<sysouts>${tests.verbose}</sysouts>
<seed>${tests.seed}</seed>
<haltOnFailure>${tests.failfast}</haltOnFailure>
<systemProperties>
<!-- RandomizedTesting library system properties -->
<tests.jvm.argline>${tests.jvm.argline}</tests.jvm.argline>
<tests.iters>${tests.iters}</tests.iters>
<tests.maxfailures>${tests.maxfailures}</tests.maxfailures>
<tests.failfast>${tests.failfast}</tests.failfast>
<tests.class>${tests.class}</tests.class>
<tests.method>${tests.method}</tests.method>
<tests.nightly>${tests.nightly}</tests.nightly>
<tests.badapples>${tests.badapples}</tests.badapples>
<tests.weekly>${tests.weekly}</tests.weekly>
<tests.slow>${tests.slow}</tests.slow>
<tests.gce>${tests.gce}</tests.gce>
<tests.awaitsfix>${tests.awaitsfix}</tests.awaitsfix>
<tests.slow>${tests.slow}</tests.slow>
<tests.timeoutSuite>${tests.timeoutSuite}</tests.timeoutSuite>
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
<tests.integration>${tests.integration}</tests.integration>
<tests.cluster_seed>${tests.cluster_seed}</tests.cluster_seed>
<tests.client.ratio>${tests.client.ratio}</tests.client.ratio>
<es.node.local>false</es.node.local>
<es.node.mode>network</es.node.mode>
<es.config>${es.config}</es.config>
<es.logger.level>${es.logger.level}</es.logger.level>
<java.awt.headless>true</java.awt.headless>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.discovery.zen.ping.unicast.UnicastHostsProvider;
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
import org.elasticsearch.transport.TransportService;

import java.io.IOException;
Expand Down Expand Up @@ -225,8 +224,9 @@ public List<DiscoveryNode> buildDynamicNodes() {
// ip_private is a single IP Address. We need to build a TransportAddress from it
TransportAddress[] addresses = transportService.addressesFromString(address);

// If user has set `es_port` metadata, we don't need to ping all ports
// we only limit to 1 addresses, makes no sense to ping 100 ports
for (int i = 0; (i < addresses.length && i < UnicastZenPing.LIMIT_PORTS_COUNT); i++) {
for (int i = 0; i < addresses.length; i++) {
logger.trace("adding {}, type {}, image {}, address {}, transport_address {}, status {}", name, type,
image, ip_private, addresses[i], status);
cachedDiscoNodes.add(new DiscoveryNode("#cloud-" + name + "-" + i, addresses[i], Version.CURRENT));
Expand All @@ -248,11 +248,9 @@ public List<DiscoveryNode> buildDynamicNodes() {
return cachedDiscoNodes;
}

private boolean checkProperty(String name, String value) {
private void checkProperty(String name, String value) {
if (!Strings.hasText(value)) {
logger.warn("cloud.gce.{} is not set.", name);
return false;
}
return true;
}
}
61 changes: 61 additions & 0 deletions src/test/java/org/elasticsearch/cloud/gce/AbstractGceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.cloud.gce;

import com.carrotsearch.randomizedtesting.annotations.TestGroup;
import org.elasticsearch.test.ElasticsearchIntegrationTest;

import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
*
*/
public abstract class AbstractGceTest extends ElasticsearchIntegrationTest {

/**
* Annotation for tests that require GCE to run. GCE tests are disabled by default.
* <p/>
* To enable test add -Dtests.gce=true -Des.config=/path/to/elasticsearch.yml
* <p/>
* The elasticsearch.yml file should contain the following keys
* <pre>
cloud:
gce:
project_id: es-cloud
zone: europe-west1-a
discovery:
type: gce
* </pre>
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@TestGroup(enabled = false, sysProperty = SYSPROP_GCE)
public @interface GceTest {
}

/**
*/
public static final String SYSPROP_GCE = "tests.gce";

}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6aa36aa

Please sign in to comment.