private void runTest(final Class<? extends Test> cmd) throws IOException,
InterruptedException, ClassNotFoundException {
MiniHBaseCluster hbaseMiniCluster = null;
MiniDFSCluster dfsCluster = null;
MiniZooKeeperCluster zooKeeperCluster = null;
if (this.miniCluster) {
dfsCluster = new MiniDFSCluster(conf, 2, true, (String[])null);
zooKeeperCluster = new MiniZooKeeperCluster();
int zooKeeperPort = zooKeeperCluster.startup(new File(System.getProperty("java.io.tmpdir")));
// mangle the conf so that the fs parameter points to the minidfs we
// just started up
FileSystem fs = dfsCluster.getFileSystem();
conf.set("fs.default.name", fs.getUri().toString());
conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(zooKeeperPort));
Path parentdir = fs.getHomeDirectory();
conf.set(HConstants.HBASE_DIR, parentdir.toString());
fs.mkdirs(parentdir);
FSUtils.setVersion(fs, parentdir);
hbaseMiniCluster = new MiniHBaseCluster(this.conf, N);
}
try {
if (N == 1) {
// If there is only one client and one HRegionServer, we assume nothing
// has been set up at all.
runNIsOne(cmd);
} else {
// Else, run
runNIsMoreThanOne(cmd);
}
} finally {
if(this.miniCluster) {
if (hbaseMiniCluster != null) hbaseMiniCluster.shutdown();
if (zooKeeperCluster != null) zooKeeperCluster.shutdown();
HBaseTestCase.shutdownDfs(dfsCluster);
}
}
}