Skip to content

Commit

Permalink
Use single tablet server replica for Kudu tests
Browse files Browse the repository at this point in the history
Using 3 tablet servers is overkill and makes the tests take longer.
It takes ~10 seconds to initialize the docker instance for each
tablet server. This change reduces the runtime of Kudu tests
from 9:40 min to 4 min on an Macbook Pro M1 laptop.
  • Loading branch information
martint committed Aug 7, 2023
1 parent 4ccd023 commit 55fa990
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
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

0 comments on commit 55fa990

Please sign in to comment.