Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate its #163

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@
<artifactId>druid-server</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.druid</groupId>
<artifactId>druid-server</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down Expand Up @@ -418,6 +424,11 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<scope>compile</scope>
</dependency>

<!-- Tests -->
<dependency>
Expand Down Expand Up @@ -669,6 +680,7 @@
-Xmx128m
-Duser.timezone=UTC
-Dfile.encoding=UTF-8
-Ddruid.test.config.type=docker
-Ddruid.test.config.dockerIp=${env.DOCKER_IP}
-Ddruid.test.config.extraDatasourceNameSuffix=${extra.datasource.name.suffix}
-Ddruid.zk.service.host=${env.DOCKER_IP}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class ConfigFileConfigProvider implements IntegrationTestingConfigProvide
private String zookeeperHosts; // comma-separated list of host:port
private String kafkaHost;
private String schemaRegistryHost;
private Map<String, String> props = null;
private final Map<String, String> props;
private String username;
private String password;
private String cloudBucket;
Expand All @@ -78,22 +78,32 @@ public class ConfigFileConfigProvider implements IntegrationTestingConfigProvide
private String streamEndpoint;

@JsonCreator
ConfigFileConfigProvider(@JsonProperty("configFile") String configFile)
public ConfigFileConfigProvider(@JsonProperty("configFile") String configFile)
{
loadProperties(configFile);
this(readProperties(configFile));
}

private void loadProperties(String configFile)
public ConfigFileConfigProvider(Map<String, String> properties)
{
this.props = properties;
loadProperties();
}

private static Map<String, String> readProperties(String configFile)
{
ObjectMapper jsonMapper = new ObjectMapper();
try {
props = jsonMapper.readValue(
return jsonMapper.readValue(
new File(configFile), JacksonUtils.TYPE_REFERENCE_MAP_STRING_STRING
);
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
}

private void loadProperties()
{
routerHost = props.get("router_host");
// there might not be a router; we want routerHost to be null in that case
routerUrl = props.get("router_url");
Expand Down Expand Up @@ -254,6 +264,16 @@ private void loadProperties(String configFile)
LOG.info("Username: [%s]", username);
}

public String getZkConnectionString()
{
return zookeeperHosts;
}

public boolean isEmbeddedCluster()
{
return false;
}

@Override
public IntegrationTestingConfig get()
{
Expand Down Expand Up @@ -408,7 +428,7 @@ public String getHistoricalHost()
@Override
public String getZookeeperHosts()
{
return zookeeperHosts;
return getZkConnectionString();
}

@Override
Expand Down Expand Up @@ -554,6 +574,12 @@ public boolean isDocker()
{
return false;
}

@Override
public boolean isEmbeddedCluster()
{
return ConfigFileConfigProvider.this.isEmbeddedCluster();
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.apache.druid.testing;

import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;

import java.util.HashMap;
import java.util.Map;

public class EmbeddedClusterConfigProvider extends ConfigFileConfigProvider
{
private final EmbeddedDruidCluster embeddedDruidCluster;

@JsonCreator
public EmbeddedClusterConfigProvider(
@JacksonInject EmbeddedDruidCluster embeddedDruidCluster
)
{
super(buildProperties());
this.embeddedDruidCluster = embeddedDruidCluster;

embeddedDruidCluster.start();
}

@Override
public String getZkConnectionString()
{
return embeddedDruidCluster.getZkConnectionString();
}

@Override
public boolean isEmbeddedCluster()
{
return true;
}

private static Map<String, String> buildProperties()
{
final Map<String, String> props = new HashMap<>();
props.put("router_url", "http://localhost:8082");
props.put("router_tls_url", "http://localhost:8082");

props.put("broker_url", "http://localhost:8082");
props.put("broker_tls_url", "http://localhost:8082");

props.put("historical_host", "localhost");
props.put("historical_port", "8083");

props.put("coordinator_host", "localhost");
props.put("coordinator_port", "8081");

props.put("indexer_host", "localhost");
props.put("indexer_port", "8081");

props.put("coordinator_two_host", "");
props.put("coordinator_two_port", "");

props.put("overlord_two_host", "");
props.put("overlord_two_port", "");

props.put("middlemanager_host", "localhost");
props.put("middlemanager_port", "");

return props;
}
}
Loading
Loading