@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.
|
org.apache.kudu.client.HostAndPort |
restartTabletLeader(LocatedTablet tablet)
Kills and starts back a tablet server that serves the given tablet's leader.
|
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 |
setMasterFlag(org.apache.kudu.client.HostAndPort hp,
String flag,
String value)
Set a run-time flag for a Kudu master identified by its host and port.
|
void |
setTabletServerFlag(org.apache.kudu.client.HostAndPort hp,
String flag,
String value)
Set a run-time flag for a tablet server identified by its host and port.
|
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.TestRuleapply in class org.junit.rules.ExternalResourcepublic void before()
throws Exception
before in class org.junit.rules.ExternalResourceExceptionpublic void after()
after in class org.junit.rules.ExternalResourcepublic KuduClient getClient()
public AsyncKuduClient getAsyncClient()
public void killTabletLeader(KuduTable table) throws Exception
table - a KuduTable which will get its single tablet's leader killed.Exceptionpublic 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 backExceptionpublic 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 restartExceptionpublic org.apache.kudu.client.HostAndPort restartTabletServer(org.apache.kudu.client.RemoteTablet tablet)
throws Exception
tablet - a RemoteTablet which will get its leader killed and restartedExceptionpublic void setTabletServerFlag(org.apache.kudu.client.HostAndPort hp,
String flag,
String value)
throws IOException
hp - HostAndPort object identifying the target tablet serverflag - a flag to set (prefix dash(es) omitted)value - a stringified representation of the flag's value to setIOExceptionpublic org.apache.kudu.client.HostAndPort restartTabletLeader(LocatedTablet tablet) throws Exception
tablet - a LocatedTablet which is hosted by the target tablet serverExceptionpublic org.apache.kudu.client.HostAndPort restartLeaderMaster()
throws Exception
Exceptionpublic void startMaster(org.apache.kudu.client.HostAndPort hp)
throws Exception
hp - host and port of the master to start backExceptionpublic org.apache.kudu.client.HostAndPort pauseLeaderMaster()
throws Exception
Exceptionpublic void pauseMaster(org.apache.kudu.client.HostAndPort hp)
throws Exception
Exceptionpublic void resumeMaster(org.apache.kudu.client.HostAndPort hp)
throws Exception
Exceptionpublic void setMasterFlag(org.apache.kudu.client.HostAndPort hp,
String flag,
String value)
throws IOException
hp - HostAndPort object identifying the target masterflag - a flag to set (prefix dash(es) omitted)value - a stringified representation of the flag's value to setIOExceptionpublic 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
IOExceptionpublic void startAllMasterServers()
throws IOException
IOExceptionpublic void killAllTabletServers()
throws IOException
IOExceptionpublic void startAllTabletServers()
throws IOException
IOExceptionpublic void kdestroy()
throws IOException
IOExceptionpublic void kinit(String username) throws IOException
username - the username to kinit asIOExceptionpublic void resetClients()
throws IOException
IOExceptionpublic String createJwtFor(String accountId, String subject, boolean isValid) throws IOException
IOExceptionpublic byte[] getClusterCACertDer()
throws IOException
IOException