mirror of
https://github.com/apache/sqoop.git
synced 2025-05-03 02:51:00 +08:00
SQOOP-164. Allow unit tests to use external dbs.
Modified the thirdparty tests to pick host URL from system properties. From: Arvind Prabhakar <arvind@cloudera.com> git-svn-id: https://svn.apache.org/repos/asf/incubator/sqoop/trunk@1150010 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3f8252a28c
commit
de2fc6c2b3
@ -72,16 +72,43 @@ Install MySQL server and client 5.0. Download MySQL Connector/J 5.0.8 for
|
||||
JDBC. Instructions for configuring the MySQL database are in MySQLAuthTest
|
||||
and DirectMySQLTest.
|
||||
|
||||
Use the system property sqoop.test.mysql.connectstring.host_url to specify the
|
||||
URL for the MySQL host used for testing. Specify this property on the command
|
||||
line or via the build.properties file. For example:
|
||||
|
||||
sqoop.test.mysql.connectstring.host_url=jdbc:mysql://host.example.com/
|
||||
|
||||
If not specified, the default value used for this property is:
|
||||
jdbc:mysql://localhost/
|
||||
|
||||
=== Oracle
|
||||
|
||||
Install Oracle XE (Express edition) 10.2.0. Instructions for configuring the
|
||||
database are in OracleManagerTest. Download the ojdbc6_g jar.
|
||||
|
||||
Use the system property sqoop.test.oracle.connectstring to specify the
|
||||
connection string for Oracle host used for testing. Specify this property on the
|
||||
command line or via the build.properties file. For example:
|
||||
|
||||
sqoop.test.oracle.connectstring=jdbc:oracle:thin:@//host.example.com/xe
|
||||
|
||||
If not specified, the default value used for this property is:
|
||||
jdbc:oracle:thin:@//localhost/xe
|
||||
|
||||
=== PostgreSQL
|
||||
|
||||
Install PostgreSQL 8.3.9. Download the postgresql 8.4 jdbc driver. Instructions
|
||||
for configuring the database are in PostgresqlTest.
|
||||
|
||||
Use the system property sqoop.test.postgresql.connectstring.host_url to specify
|
||||
the URL for the PostgreSQL host used for testing. Specify this property on the
|
||||
command line or via the build.properties file. For example:
|
||||
|
||||
sqoop.test.postgresql.connectstring.host_url=jdbc:postgresql://sqoop-dbs.sf.cloudera.com/
|
||||
|
||||
If not specified, the default value used for this property is:
|
||||
jdbc:postgresql://localhost/
|
||||
|
||||
=== Running the Third-party Tests
|
||||
|
||||
After the third-party databases are installed and configured, run:
|
||||
|
14
build.xml
14
build.xml
@ -162,12 +162,18 @@
|
||||
|
||||
<!--this is the naming policy for artifacts we want pulled down-->
|
||||
<property name="ivy.artifact.retrieve.pattern"
|
||||
value="${name}/[conf]/[artifact]-[revision](-[classifier]).[ext]"/>
|
||||
value="${name}/[conf]/[artifact]-[revision](-[classifier]).[ext]"/>
|
||||
|
||||
<!--test related properties -->
|
||||
<property name="sqoop.test.oracle.connectstring"
|
||||
value="jdbc:oracle:thin:@//localhost/xe"/>
|
||||
|
||||
<property name="sqoop.test.mysql.connectstring.host_url"
|
||||
value="jdbc:mysql://localhost/"/>
|
||||
|
||||
<property name="sqoop.test.postgresql.connectstring.host_url"
|
||||
value="jdbc:postgresql://localhost/"/>
|
||||
|
||||
<!-- load ant-contrib tasks to get the "if" task. -->
|
||||
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
|
||||
<classpath>
|
||||
@ -558,6 +564,12 @@
|
||||
<sysproperty key="sqoop.test.oracle.connectstring"
|
||||
value="${sqoop.test.oracle.connectstring}"/>
|
||||
|
||||
<sysproperty key="sqoop.test.mysql.connectstring.host_url"
|
||||
value="${sqoop.test.mysql.connectstring.host_url}"/>
|
||||
|
||||
<sysproperty key="sqoop.test.postgresql.connectstring.host_url"
|
||||
value="${sqoop.test.postgresql.connectstring.host_url}"/>
|
||||
|
||||
<classpath>
|
||||
<!-- instrumented classes go ahead of normal classes -->
|
||||
<pathelement location="${cobertura.class.dir}" />
|
||||
|
@ -84,6 +84,10 @@ public void setUp() {
|
||||
SqoopOptions options = new SqoopOptions(MySQLTestUtils.CONNECT_STRING,
|
||||
getTableName());
|
||||
options.setUsername(MySQLTestUtils.getCurrentUser());
|
||||
|
||||
LOG.debug("Setting up another DirectMySQLTest: "
|
||||
+ MySQLTestUtils.CONNECT_STRING);
|
||||
|
||||
manager = new DirectMySQLManager(options);
|
||||
|
||||
Connection connection = null;
|
||||
@ -94,7 +98,7 @@ public void setUp() {
|
||||
connection.setAutoCommit(false);
|
||||
st = connection.createStatement();
|
||||
|
||||
// create the database table and populate it with data.
|
||||
// create the database table and populate it with data.
|
||||
st.executeUpdate("DROP TABLE IF EXISTS " + getTableName());
|
||||
st.executeUpdate("CREATE TABLE " + getTableName() + " ("
|
||||
+ "id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, "
|
||||
|
@ -65,7 +65,9 @@ public class MySQLAuthTest extends ImportJobTestCase {
|
||||
public static final Log LOG = LogFactory.getLog(
|
||||
MySQLAuthTest.class.getName());
|
||||
|
||||
static final String HOST_URL = "jdbc:mysql://localhost/";
|
||||
static final String HOST_URL = System.getProperty(
|
||||
"sqoop.test.mysql.connectstring.host_url",
|
||||
"jdbc:mysql://localhost/");
|
||||
|
||||
static final String AUTH_TEST_DATABASE = "sqooppasstest";
|
||||
static final String AUTH_TEST_USER = "sqooptest";
|
||||
@ -89,6 +91,8 @@ public void setUp() {
|
||||
options.setUsername(AUTH_TEST_USER);
|
||||
options.setPassword(AUTH_TEST_PASS);
|
||||
|
||||
LOG.debug("Setting up another MySQLAuthTest: " + AUTH_CONNECT_STRING);
|
||||
|
||||
manager = new DirectMySQLManager(options);
|
||||
|
||||
Connection connection = null;
|
||||
@ -99,7 +103,7 @@ public void setUp() {
|
||||
connection.setAutoCommit(false);
|
||||
st = connection.createStatement();
|
||||
|
||||
// create the database table and populate it with data.
|
||||
// create the database table and populate it with data.
|
||||
st.executeUpdate("DROP TABLE IF EXISTS " + AUTH_TABLE_NAME);
|
||||
st.executeUpdate("CREATE TABLE " + AUTH_TABLE_NAME + " ("
|
||||
+ "id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, "
|
||||
@ -286,7 +290,7 @@ public void doZeroTimestampTest(int testNum, boolean expectSuccess,
|
||||
connection.setAutoCommit(false);
|
||||
st = connection.createStatement();
|
||||
|
||||
// create the database table and populate it with data.
|
||||
// create the database table and populate it with data.
|
||||
st.executeUpdate("DROP TABLE IF EXISTS " + TABLE_NAME);
|
||||
st.executeUpdate("CREATE TABLE " + TABLE_NAME + " ("
|
||||
+ "id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, "
|
||||
|
@ -34,7 +34,9 @@ public final class MySQLTestUtils {
|
||||
public static final Log LOG = LogFactory.getLog(
|
||||
MySQLTestUtils.class.getName());
|
||||
|
||||
public static final String HOST_URL = "jdbc:mysql://localhost/";
|
||||
public static final String HOST_URL = System.getProperty(
|
||||
"sqoop.test.mysql.connectstring.host_url",
|
||||
"jdbc:mysql://localhost/");
|
||||
|
||||
public static final String MYSQL_DATABASE_NAME = "sqooptestdb";
|
||||
public static final String TABLE_NAME = "EMPLOYEES_MYSQL";
|
||||
@ -81,7 +83,7 @@ public static String getCurrentUser() {
|
||||
if (0 != ret) {
|
||||
LOG.error("whoami exited with error status " + ret);
|
||||
// suppress original return value from this method.
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
continue; // loop around.
|
||||
|
@ -82,7 +82,9 @@ public class PostgresqlTest extends ImportJobTestCase {
|
||||
public static final Log LOG = LogFactory.getLog(
|
||||
PostgresqlTest.class.getName());
|
||||
|
||||
static final String HOST_URL = "jdbc:postgresql://localhost/";
|
||||
static final String HOST_URL = System.getProperty(
|
||||
"sqoop.test.postgresql.connectstring.host_url",
|
||||
"jdbc:postgresql://localhost/");
|
||||
|
||||
static final String DATABASE_USER = "sqooptest";
|
||||
static final String DATABASE_NAME = "sqooptest";
|
||||
@ -98,7 +100,7 @@ protected boolean useHsqldbTestServer() {
|
||||
public void setUp() {
|
||||
super.setUp();
|
||||
|
||||
LOG.debug("Setting up another postgresql test...");
|
||||
LOG.debug("Setting up another postgresql test: " + CONNECT_STRING);
|
||||
|
||||
SqoopOptions options = new SqoopOptions(CONNECT_STRING, TABLE_NAME);
|
||||
options.setUsername(DATABASE_USER);
|
||||
|
Loading…
Reference in New Issue
Block a user