@InterfaceAudience.Public
@InterfaceStability.Evolving
public class KuduTestHarness
extends org.junit.rules.ExternalResource
public static class TestFoo { @Rule public KuduTestHarness harness = new KuduTestHarness(); ... }
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SLEEP |
Constructor and Description |
---|
KuduTestHarness() |
KuduTestHarness(org.apache.kudu.test.cluster.MiniKuduCluster.MiniKuduClusterBuilder clusterBuilder) |
Modifier and Type | Method and Description |
---|---|
void |
after() |
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
void |
before() |
String |
createJwtFor(String accountId,
String subject,
boolean isValid) |
org.apache.kudu.client.HostAndPort |
findLeaderMasterServer()
Find the host and port of the leader master.
|
org.apache.kudu.client.HostAndPort |
findLeaderTabletServer(LocatedTablet tablet)
Finds the RPC port of the given tablet's leader tserver.
|
AsyncKuduClient |
getAsyncClient() |
static org.apache.kudu.test.cluster.MiniKuduCluster.MiniKuduClusterBuilder |
getBaseClusterBuilder()
Returns the base MiniKuduClusterBuilder used when creating a
KuduTestHarness with the default constructor.
|
KuduClient |
getClient() |
byte[] |
getClusterCACertDer() |
String |
getClusterRoot() |
String |
getMasterAddressesAsString()
Return the comma-separated list of "host:port" pairs that describes the master
config for this cluster.
|
List<org.apache.kudu.client.HostAndPort> |
getMasterServers() |
String |
getPrincipal() |
List<org.apache.kudu.client.HostAndPort> |
getTabletServers() |
void |
kdestroy()
Removes all credentials for all principals from the Kerberos credential cache.
|
void |
killAllMasterServers()
Kills all the master servers.
|
void |
killAllTabletServers()
Kills all the tablet servers.
|
org.apache.kudu.client.HostAndPort |
killLeaderMasterServer()
Helper method to easily kill the leader master.
|
void |
killTabletLeader(KuduTable table)
Helper method to easily kill a tablet server that serves the given table's only tablet's
leader.
|
org.apache.kudu.client.HostAndPort |
killTabletLeader(LocatedTablet tablet)
Helper method to kill a tablet server that serves the given tablet's leader
replica.
|
org.apache.kudu.client.HostAndPort |
killTabletLeader(org.apache.kudu.client.RemoteTablet tablet)
Helper method to kill a tablet server that hosts the given tablet's leader
replica.
|
void |
kinit(String username)
Re-initialize Kerberos credentials for the given username, writing them
into the Kerberos credential cache.
|
org.apache.kudu.client.HostAndPort |
pauseLeaderMaster()
Finds and pauses the leader master.
|
void |
pauseMaster(org.apache.kudu.client.HostAndPort hp)
Pauses the specified master.
|
void |
resetClients()
Resets the clients so that their state is completely fresh, including meta
cache, connections, open tables, sessions and scanners, and propagated timestamp.
|
org.apache.kudu.client.HostAndPort |
restartLeaderMaster()
Kills and restarts the leader master.
|
void |
restartTabletServer(KuduTable table)
Picks at random a tablet server that serves tablets from the passed table and restarts it.
|
org.apache.kudu.client.HostAndPort |
restartTabletServer(org.apache.kudu.client.RemoteTablet tablet)
Kills a tablet server that serves the given tablet's leader and restarts it.
|
void |
resumeMaster(org.apache.kudu.client.HostAndPort hp)
Resumes the specified master.
|
void |
startAllMasterServers()
Starts all the master servers.
|
void |
startAllTabletServers()
Starts all the tablet servers.
|
void |
startMaster(org.apache.kudu.client.HostAndPort hp)
Start master which has previously been registered at the specified
host and port.
|
void |
startTabletServer(org.apache.kudu.client.HostAndPort hp)
Start tablet server which has previously been registered at the specified
host and port.
|
public static final int DEFAULT_SLEEP
public KuduTestHarness(org.apache.kudu.test.cluster.MiniKuduCluster.MiniKuduClusterBuilder clusterBuilder)
public KuduTestHarness()
public static org.apache.kudu.test.cluster.MiniKuduCluster.MiniKuduClusterBuilder getBaseClusterBuilder()
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
apply
in interface org.junit.rules.TestRule
apply
in class org.junit.rules.ExternalResource
public void before() throws Exception
before
in class org.junit.rules.ExternalResource
Exception
public void after()
after
in class org.junit.rules.ExternalResource
public KuduClient getClient()
public AsyncKuduClient getAsyncClient()
public void killTabletLeader(KuduTable table) throws Exception
table
- a KuduTable which will get its single tablet's leader killed.Exception
public org.apache.kudu.client.HostAndPort killTabletLeader(org.apache.kudu.client.RemoteTablet tablet) throws Exception
tablet
- a RemoteTablet which will get its leader killedException
- if no leader replica found after a few retries,
or if the tablet server isn't runningpublic org.apache.kudu.client.HostAndPort killTabletLeader(LocatedTablet tablet) throws Exception
tablet
- a LocatedTablet which will get its leader killedException
- if no leader replica found or if the tablet server isn't
runningpublic org.apache.kudu.client.HostAndPort findLeaderTabletServer(LocatedTablet tablet) throws Exception
tablet
- a LocatedTabletException
- if unable to find a tablet server with leader replicapublic void startTabletServer(org.apache.kudu.client.HostAndPort hp) throws Exception
hp
- host and port of the tablet server to start backException
public org.apache.kudu.client.HostAndPort findLeaderMasterServer() throws Exception
Exception
- if we are unable to find the leader masterpublic org.apache.kudu.client.HostAndPort killLeaderMasterServer() throws Exception
Exception
- if there is an error finding or killing the leader master.public void restartTabletServer(KuduTable table) throws Exception
table
- table to query for a TS to restartException
public org.apache.kudu.client.HostAndPort restartTabletServer(org.apache.kudu.client.RemoteTablet tablet) throws Exception
tablet
- a RemoteTablet which will get its leader killed and restartedException
public org.apache.kudu.client.HostAndPort restartLeaderMaster() throws Exception
Exception
public void startMaster(org.apache.kudu.client.HostAndPort hp) throws Exception
hp
- host and port of the master to start backException
public org.apache.kudu.client.HostAndPort pauseLeaderMaster() throws Exception
Exception
public void pauseMaster(org.apache.kudu.client.HostAndPort hp) throws Exception
Exception
public void resumeMaster(org.apache.kudu.client.HostAndPort hp) throws Exception
Exception
public String getMasterAddressesAsString()
public List<org.apache.kudu.client.HostAndPort> getMasterServers()
public List<org.apache.kudu.client.HostAndPort> getTabletServers()
public String getClusterRoot()
public String getPrincipal()
public void killAllMasterServers() throws IOException
IOException
public void startAllMasterServers() throws IOException
IOException
public void killAllTabletServers() throws IOException
IOException
public void startAllTabletServers() throws IOException
IOException
public void kdestroy() throws IOException
IOException
public void kinit(String username) throws IOException
username
- the username to kinit asIOException
public void resetClients() throws IOException
IOException
public String createJwtFor(String accountId, String subject, boolean isValid) throws IOException
IOException
public byte[] getClusterCACertDer() throws IOException
IOException