Merge pull request #1507 from rasahner/feature-IntTestConfig

integration-tests: add ability to get configuration information from a file
This commit is contained in:
Fangjin Yang 2015-07-17 16:23:54 -07:00
commit 0655e61d61
7 changed files with 228 additions and 5 deletions

View File

@ -31,18 +31,49 @@ docker info
Running Integration tests
=========================
## Running tests using mvn
## Starting docker tests
To run all the tests using mvn run the following command -
To run all the tests using docker and mvn run the following command -
```
mvn verify -P integration-tests
```
To run only a single test using mvn run following command -
To run only a single test using mvn run the following command -
```
mvn verify -P integration-tests -Dit.test=<test_name>
```
## Configure and run integration tests using existing cluster
To run tests on any druid cluster that is already running, create a configuration file:
{
"broker_host": "<broker_ip>",
"broker_port": "<broker_port>",
"router_host": "<router_ip>",
"router_port": "<router_port>",
"indexer_host": "<indexer_ip>",
"indexer_port": "<indexer_port>",
"coordinator_host": "<coordinator_ip>",
"coordinator_port": "<coordinator_port>",
"middle_manager_host": "<middle_manager_ip>",
"zookeeper_hosts": "<comma-separated list of zookeeper_ip:zookeeper_port>",
}
Set the environment variable CONFIG_FILE to the name of the configuration file -
```
export CONFIG_FILE=<config file name>
```
To run all the tests using mvn run the following command -
```
mvn verify -P int-tests-config-file
```
To run only a single test using mvn run the following command -
```
mvn verify -P int-tests-config-file -Dit.test=<test_name>
```
Writing a New Test
===============

View File

@ -147,6 +147,39 @@
</plugins>
</build>
</profile>
<profile>
<id>int-tests-config-file</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<argLine>
-Duser.timezone=UTC
-Dfile.encoding=UTF-8
-Dtestrunfactory=org.testng.DruidTestRunnerFactory
-Ddruid.test.config.type=configFile
-Ddruid.test.config.configFile=${env.CONFIG_FILE}
</argLine>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,112 @@
/*
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Metamarkets 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 io.druid.testing;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.IOException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
public class ConfigFileConfigProvider implements IntegrationTestingConfigProvider
{
private String routerHost = "";
private String brokerHost = "";
private String coordinatorHost = "";
private String indexerHost = "";
private String middleManagerHost = "";
private String zookeeperHosts = "";
private Map<String, String> props = null;
@JsonCreator
ConfigFileConfigProvider(@JsonProperty("configFile") String configFile){
loadProperties(configFile);
}
private void loadProperties(String configFile)
{
ObjectMapper jsonMapper = new ObjectMapper();
try {
props = jsonMapper.readValue(
new File(configFile), new TypeReference<Map<String, String>>()
{
}
);
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
routerHost = props.get("router_host") + ":" + props.get("router_port");
brokerHost = props.get("broker_host") + ":" + props.get("broker_port");
coordinatorHost = props.get("coordinator_host") + ":" + props.get("coordinator_port");
indexerHost = props.get("indexer_host") + ":" + props.get("indexer_port");
middleManagerHost = props.get("middle_manager_host");
zookeeperHosts = props.get("zookeeper_hosts");
}
@Override
public IntegrationTestingConfig get()
{
return new IntegrationTestingConfig()
{
@Override
public String getCoordinatorHost()
{
return coordinatorHost;
}
@Override
public String getIndexerHost()
{
return indexerHost;
}
@Override
public String getRouterHost()
{
return routerHost;
}
@Override
public String getBrokerHost()
{
return brokerHost;
}
@Override
public String getMiddleManagerHost()
{
return middleManagerHost;
}
@Override
public String getZookeeperHosts()
{
return zookeeperHosts;
}
};
}
}

View File

@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import javax.validation.constraints.NotNull;
public class DockerConfigProvider implements IntegrationTestingConfigProvider
public class DockerConfigProvider implements IntegrationTestingConfigProvider
{
@JsonProperty
@ -63,6 +63,12 @@ public class DockerConfigProvider implements IntegrationTestingConfigProvider
{
return dockerIp;
}
@Override
public String getZookeeperHosts()
{
return dockerIp + ":2181";
}
};
}
}

View File

@ -30,4 +30,6 @@ public interface IntegrationTestingConfig
public String getBrokerHost();
public String getMiddleManagerHost();
public String getZookeeperHosts();
}

View File

@ -23,7 +23,8 @@ import com.google.inject.Provider;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = DockerConfigProvider.class)
@JsonSubTypes(value = {
@JsonSubTypes.Type(name = "docker", value = DockerConfigProvider.class)
@JsonSubTypes.Type(name = "docker", value = DockerConfigProvider.class),
@JsonSubTypes.Type(name = "configFile", value = ConfigFileConfigProvider.class)
})
public interface IntegrationTestingConfigProvider extends Provider<IntegrationTestingConfig>
{

View File

@ -0,0 +1,38 @@
/*
* Druid - a distributed column store.
*
* Licensed 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 io.druid.testing.clients;
import com.google.inject.Inject;
import io.druid.testing.IntegrationTestingConfig;
public class ZookeeperTestClient
{
private final String hosts;
@Inject
ZookeeperTestClient(
IntegrationTestingConfig config
)
{
this.hosts = config.getZookeeperHosts();
}
public String getZookeeperHosts()
{
return hosts;
}
}