5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-04 04:00:53 +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:
Andrew Bayer 2011-07-22 20:04:27 +00:00
parent 3f8252a28c
commit de2fc6c2b3
6 changed files with 60 additions and 9 deletions

View File

@ -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 JDBC. Instructions for configuring the MySQL database are in MySQLAuthTest
and DirectMySQLTest. 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 === Oracle
Install Oracle XE (Express edition) 10.2.0. Instructions for configuring the Install Oracle XE (Express edition) 10.2.0. Instructions for configuring the
database are in OracleManagerTest. Download the ojdbc6_g jar. 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 === PostgreSQL
Install PostgreSQL 8.3.9. Download the postgresql 8.4 jdbc driver. Instructions Install PostgreSQL 8.3.9. Download the postgresql 8.4 jdbc driver. Instructions
for configuring the database are in PostgresqlTest. 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 === Running the Third-party Tests
After the third-party databases are installed and configured, run: After the third-party databases are installed and configured, run:

View File

@ -168,6 +168,12 @@
<property name="sqoop.test.oracle.connectstring" <property name="sqoop.test.oracle.connectstring"
value="jdbc:oracle:thin:@//localhost/xe"/> 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. --> <!-- load ant-contrib tasks to get the "if" task. -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties"> <taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath> <classpath>
@ -558,6 +564,12 @@
<sysproperty key="sqoop.test.oracle.connectstring" <sysproperty key="sqoop.test.oracle.connectstring"
value="${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> <classpath>
<!-- instrumented classes go ahead of normal classes --> <!-- instrumented classes go ahead of normal classes -->
<pathelement location="${cobertura.class.dir}" /> <pathelement location="${cobertura.class.dir}" />

View File

@ -84,6 +84,10 @@ public void setUp() {
SqoopOptions options = new SqoopOptions(MySQLTestUtils.CONNECT_STRING, SqoopOptions options = new SqoopOptions(MySQLTestUtils.CONNECT_STRING,
getTableName()); getTableName());
options.setUsername(MySQLTestUtils.getCurrentUser()); options.setUsername(MySQLTestUtils.getCurrentUser());
LOG.debug("Setting up another DirectMySQLTest: "
+ MySQLTestUtils.CONNECT_STRING);
manager = new DirectMySQLManager(options); manager = new DirectMySQLManager(options);
Connection connection = null; Connection connection = null;

View File

@ -65,7 +65,9 @@ public class MySQLAuthTest extends ImportJobTestCase {
public static final Log LOG = LogFactory.getLog( public static final Log LOG = LogFactory.getLog(
MySQLAuthTest.class.getName()); 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_DATABASE = "sqooppasstest";
static final String AUTH_TEST_USER = "sqooptest"; static final String AUTH_TEST_USER = "sqooptest";
@ -89,6 +91,8 @@ public void setUp() {
options.setUsername(AUTH_TEST_USER); options.setUsername(AUTH_TEST_USER);
options.setPassword(AUTH_TEST_PASS); options.setPassword(AUTH_TEST_PASS);
LOG.debug("Setting up another MySQLAuthTest: " + AUTH_CONNECT_STRING);
manager = new DirectMySQLManager(options); manager = new DirectMySQLManager(options);
Connection connection = null; Connection connection = null;

View File

@ -34,7 +34,9 @@ public final class MySQLTestUtils {
public static final Log LOG = LogFactory.getLog( public static final Log LOG = LogFactory.getLog(
MySQLTestUtils.class.getName()); 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 MYSQL_DATABASE_NAME = "sqooptestdb";
public static final String TABLE_NAME = "EMPLOYEES_MYSQL"; public static final String TABLE_NAME = "EMPLOYEES_MYSQL";

View File

@ -82,7 +82,9 @@ public class PostgresqlTest extends ImportJobTestCase {
public static final Log LOG = LogFactory.getLog( public static final Log LOG = LogFactory.getLog(
PostgresqlTest.class.getName()); 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_USER = "sqooptest";
static final String DATABASE_NAME = "sqooptest"; static final String DATABASE_NAME = "sqooptest";
@ -98,7 +100,7 @@ protected boolean useHsqldbTestServer() {
public void setUp() { public void setUp() {
super.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); SqoopOptions options = new SqoopOptions(CONNECT_STRING, TABLE_NAME);
options.setUsername(DATABASE_USER); options.setUsername(DATABASE_USER);