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

Use single tablet server replica for Kudu tests #18549

Merged
merged 1 commit into from
Aug 7, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void testShowCreateTable()
" comment varchar COMMENT '' WITH ( nullable = true )\n" +
")\n" +
"WITH (\n" +
" number_of_replicas = 3,\n" +
" number_of_replicas = 1,\n" +
" partition_by_hash_buckets = 2,\n" +
" partition_by_hash_columns = ARRAY['row_uuid'],\n" +
" partition_by_range_columns = ARRAY['row_uuid'],\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void testShowCreateTable()
" comment varchar COMMENT '' WITH ( nullable = true )\n" +
")\n" +
"WITH (\n" +
" number_of_replicas = 3,\n" +
" number_of_replicas = 1,\n" +
" partition_by_hash_buckets = 2,\n" +
" partition_by_hash_columns = ARRAY['row_uuid'],\n" +
" partition_by_range_columns = ARRAY['row_uuid'],\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.trino.plugin.kudu;

import com.google.common.collect.ImmutableList;
import com.google.common.io.Closer;
import com.google.common.net.HostAndPort;
import io.trino.testing.ResourcePresence;
Expand All @@ -28,7 +27,6 @@
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import java.util.List;

import static java.lang.String.format;

Expand All @@ -41,15 +39,14 @@ public class TestingKuduServer

private static final Integer KUDU_MASTER_PORT = 7051;
private static final Integer KUDU_TSERVER_PORT = 7050;
private static final Integer NUMBER_OF_REPLICA = 3;

private static final String TOXIPROXY_IMAGE = "ghcr.io/shopify/toxiproxy:2.4.0";
private static final String TOXIPROXY_NETWORK_ALIAS = "toxiproxy";

private final Network network;
private final ToxiproxyContainer toxiProxy;
private final GenericContainer<?> master;
private final List<GenericContainer<?>> tServers;
private final GenericContainer<?> tabletServer;

private boolean stopped;

Expand All @@ -67,14 +64,14 @@ public TestingKuduServer()
public TestingKuduServer(String kuduVersion)
{
network = Network.newNetwork();
ImmutableList.Builder<GenericContainer<?>> tServersBuilder = ImmutableList.builder();

String hostIP = getHostIPAddress();

String masterContainerAlias = "kudu-master";
this.master = new GenericContainer<>(format("%s:%s", KUDU_IMAGE, kuduVersion))
.withExposedPorts(KUDU_MASTER_PORT)
.withCommand("master")
.withEnv("MASTER_ARGS", "--default_num_replicas=1")
.withNetwork(network)
.withNetworkAliases(masterContainerAlias);

Expand All @@ -83,24 +80,19 @@ public TestingKuduServer(String kuduVersion)
.withNetworkAliases(TOXIPROXY_NETWORK_ALIAS);
toxiProxy.start();

for (int instance = 0; instance < NUMBER_OF_REPLICA; instance++) {
String instanceName = "kudu-tserver-" + instance;
ToxiproxyContainer.ContainerProxy proxy = toxiProxy.getProxy(instanceName, KUDU_TSERVER_PORT);
GenericContainer<?> tableServer = new GenericContainer<>(format("%s:%s", KUDU_IMAGE, kuduVersion))
.withExposedPorts(KUDU_TSERVER_PORT)
.withCommand("tserver")
.withEnv("KUDU_MASTERS", format("%s:%s", masterContainerAlias, KUDU_MASTER_PORT))
.withEnv("TSERVER_ARGS", format("--fs_wal_dir=/var/lib/kudu/tserver --logtostderr --use_hybrid_clock=false --rpc_bind_addresses=%s:%s --rpc_advertised_addresses=%s:%s", instanceName, KUDU_TSERVER_PORT, hostIP, proxy.getProxyPort()))
.withNetwork(network)
.withNetworkAliases(instanceName)
.dependsOn(master);

tServersBuilder.add(tableServer);
}
this.tServers = tServersBuilder.build();
master.start();
String instanceName = "kudu-tserver";
ToxiproxyContainer.ContainerProxy proxy = toxiProxy.getProxy(instanceName, KUDU_TSERVER_PORT);
tabletServer = new GenericContainer<>(format("%s:%s", KUDU_IMAGE, kuduVersion))
.withExposedPorts(KUDU_TSERVER_PORT)
.withCommand("tserver")
.withEnv("KUDU_MASTERS", format("%s:%s", masterContainerAlias, KUDU_MASTER_PORT))
.withEnv("TSERVER_ARGS", format("--fs_wal_dir=/var/lib/kudu/tserver --logtostderr --use_hybrid_clock=false --rpc_bind_addresses=%s:%s --rpc_advertised_addresses=%s:%s", instanceName, KUDU_TSERVER_PORT, hostIP, proxy.getProxyPort()))
.withNetwork(network)
.withNetworkAliases(instanceName)
.dependsOn(master);

tServers.forEach(GenericContainer::start);
master.start();
tabletServer.start();
}

public HostAndPort getMasterAddress()
Expand All @@ -116,7 +108,7 @@ public void close()
{
try (Closer closer = Closer.create()) {
closer.register(master::stop);
tServers.forEach(tabletServer -> closer.register(tabletServer::stop));
closer.register(tabletServer::stop);
closer.register(toxiProxy::stop);
closer.register(network::close);
}
Expand Down