5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-04 03:11:00 +08:00

SQOOP-152. Support for test against cluster.

This change allows Sqoop unit tests to be run against a real cluster.

(Konstantin Boudnik via arvind)

From: Arvind Prabhakar <arvind@cloudera.com>

git-svn-id: https://svn.apache.org/repos/asf/incubator/sqoop/trunk@1150012 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Bayer 2011-07-22 20:04:28 +00:00
parent d920b8a0e8
commit 0b1f47c459

View File

@ -43,7 +43,20 @@ public class HsqldbTestServer {
// singleton server instance.
private static Server server;
private static final String DATABASE_NAME = "db1";
// if -Dhsql.server.host hasn't been set to something like
// hsql://localhost.localdomain/ a defaul in-mem DB will be used
private static final String IN_MEM = "mem:";
public static String getServerHost() {
String host = System.getProperty("hsql.server.host", IN_MEM);
if (!host.endsWith("/")) { host += "/"; }
return host;
}
private static boolean inMemoryDB = IN_MEM.equals(getServerHost());
// Database name can be altered too
private static final String DATABASE_NAME =
System.getProperty("hsql.database.name", "db1");
// hsqldb always capitalizes table and column names
private static final String DUMMY_TABLE_NAME = "TWOINTTABLE";
@ -54,7 +67,8 @@ public class HsqldbTestServer {
private static final String EMPLOYEE_TABLE_NAME = "EMPLOYEES";
private static final String DB_URL = "jdbc:hsqldb:mem:" + DATABASE_NAME;
private static final String DB_URL = "jdbc:hsqldb:"
+ getServerHost() + DATABASE_NAME;
private static final String DRIVER_CLASS = "org.hsqldb.jdbcDriver";
// all user-created HSQLDB tables are in the "PUBLIC" schema when connected
@ -87,8 +101,13 @@ public static String getDatabaseName() {
public void start() {
if (null == server) {
LOG.info("Starting new hsqldb server; database=" + DATABASE_NAME);
String tmpDir = System.getProperty("test.build.data", "/tmp/");
String dbLocation = tmpDir + "/sqoop/testdb.file";
if (inMemoryDB) {dbLocation = IN_MEM; }
server = new Server();
server.putPropertiesFromString("database.0=mem:" + DATABASE_NAME
server.setDatabaseName(0, DATABASE_NAME);
server.putPropertiesFromString("database.0=" + dbLocation
+ ";no_system_exit=true");
server.start();
}