mirror of
https://github.com/apache/sqoop.git
synced 2025-05-03 17:41:49 +08:00
SQOOP-3367: Improve third party tests to be able to execute them in a single JVM
(Szabolcs Vasas via Boglarka Egyed)
This commit is contained in:
parent
816146df56
commit
327aec8bf1
@ -42,6 +42,8 @@
|
|||||||
import org.apache.sqoop.manager.ConnManager;
|
import org.apache.sqoop.manager.ConnManager;
|
||||||
import org.apache.sqoop.util.ExitSecurityException;
|
import org.apache.sqoop.util.ExitSecurityException;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility to import a table into the Hive metastore. Manages the connection
|
* Utility to import a table into the Hive metastore. Manages the connection
|
||||||
* to Hive itself as well as orchestrating the use of the other classes in this
|
* to Hive itself as well as orchestrating the use of the other classes in this
|
||||||
@ -159,7 +161,8 @@ public void importTable(String inputTableName, String outputTableName,
|
|||||||
boolean debugMode = expectedScript != null;
|
boolean debugMode = expectedScript != null;
|
||||||
if (debugMode) {
|
if (debugMode) {
|
||||||
env.add("EXPECTED_SCRIPT=" + expectedScript);
|
env.add("EXPECTED_SCRIPT=" + expectedScript);
|
||||||
env.add("TMPDIR=" + options.getTempDir());
|
String tmpDir = defaultString(options.getWarehouseDir(), "/tmp");
|
||||||
|
env.add("TMPDIR=" + tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate the HQL statements to run.
|
// generate the HQL statements to run.
|
||||||
|
@ -31,6 +31,7 @@ public class OraOopTypesTest extends OraOopTestCase {
|
|||||||
public void ensureTypesAfterExportMappedAsExpected() throws Exception {
|
public void ensureTypesAfterExportMappedAsExpected() throws Exception {
|
||||||
try {
|
try {
|
||||||
setSqoopTargetDirectory(getSqoopTargetDirectory() + "types_test");
|
setSqoopTargetDirectory(getSqoopTargetDirectory() + "types_test");
|
||||||
|
setSqoopGenClassName(OraOopTypesTest.class.getSimpleName());
|
||||||
String tempTableName = "ORACLE_DATATYPES_TEMPLATE";
|
String tempTableName = "ORACLE_DATATYPES_TEMPLATE";
|
||||||
String tableName = "ORACLE_DATATYPES";
|
String tableName = "ORACLE_DATATYPES";
|
||||||
createTableFromSQL("create table " + tempTableName + " ("
|
createTableFromSQL("create table " + tempTableName + " ("
|
||||||
|
@ -86,6 +86,7 @@ public void importTest() throws Exception {
|
|||||||
// Generate test data in oracle
|
// Generate test data in oracle
|
||||||
setSqoopTargetDirectory(getSqoopTargetDirectory()
|
setSqoopTargetDirectory(getSqoopTargetDirectory()
|
||||||
+ OracleUtils.SYSTEMTEST_TABLE_NAME);
|
+ OracleUtils.SYSTEMTEST_TABLE_NAME);
|
||||||
|
setSqoopGenClassName(SystemImportTest.class.getSimpleName());
|
||||||
int numRows = OracleUtils.SYSTEMTEST_NUM_ROWS;
|
int numRows = OracleUtils.SYSTEMTEST_NUM_ROWS;
|
||||||
Connection conn = getTestEnvConnection();
|
Connection conn = getTestEnvConnection();
|
||||||
OraOopOracleQueries.setConnectionTimeZone(conn, "GMT");
|
OraOopOracleQueries.setConnectionTimeZone(conn, "GMT");
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.wrap;
|
import static org.apache.commons.lang3.StringUtils.wrap;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
@ -217,6 +218,7 @@ protected SqoopOptions getSqoopOptions(Configuration conf) {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
// The assumption is that correct HADOOP configuration will have it set to
|
// The assumption is that correct HADOOP configuration will have it set to
|
||||||
// hdfs://namenode
|
// hdfs://namenode
|
||||||
|
resetDefaultTimeZone();
|
||||||
setOnPhysicalCluster(
|
setOnPhysicalCluster(
|
||||||
!CommonArgs.LOCAL_FS.equals(System.getProperty(
|
!CommonArgs.LOCAL_FS.equals(System.getProperty(
|
||||||
CommonArgs.FS_DEFAULT_NAME)));
|
CommonArgs.FS_DEFAULT_NAME)));
|
||||||
@ -711,4 +713,10 @@ public static long timeFromString(String timeStampString) {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void resetDefaultTimeZone() {
|
||||||
|
String timeZoneId = System.getProperty("user.timezone");
|
||||||
|
TimeZone defaultTimeZone = TimeZone.getTimeZone(timeZoneId);
|
||||||
|
TimeZone.setDefault(defaultTimeZone);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,8 +212,7 @@ public void testBlobAvroImportExternal() throws IOException, SQLException {
|
|||||||
ByteBuffer buf = (ByteBuffer) record.get(getColName(0));
|
ByteBuffer buf = (ByteBuffer) record.get(getColName(0));
|
||||||
String returnVal = new String(buf.array());
|
String returnVal = new String(buf.array());
|
||||||
String expectedStart = "externalLob(lf,_lob/large_obj";
|
String expectedStart = "externalLob(lf,_lob/large_obj";
|
||||||
String expectedEnd = getTableNum() + "_m_0000000.lob,68,"
|
String expectedEnd = "_m_0000000.lob,68," + data.length() + ")";
|
||||||
+ data.length() + ")";
|
|
||||||
|
|
||||||
assertNotNull(returnVal);
|
assertNotNull(returnVal);
|
||||||
assertTrue("ExpectedStart: " + expectedStart + ", value: " + returnVal, returnVal.startsWith(expectedStart));
|
assertTrue("ExpectedStart: " + expectedStart + ", value: " + returnVal, returnVal.startsWith(expectedStart));
|
||||||
@ -303,8 +302,7 @@ public void testBlobCompressedAvroImportExternal()
|
|||||||
ByteBuffer buf = (ByteBuffer) record.get(getColName(0));
|
ByteBuffer buf = (ByteBuffer) record.get(getColName(0));
|
||||||
String returnVal = new String(buf.array());
|
String returnVal = new String(buf.array());
|
||||||
String expectedStart = "externalLob(lf,_lob/large_obj";
|
String expectedStart = "externalLob(lf,_lob/large_obj";
|
||||||
String expectedEnd = getTableNum() + "_m_0000000.lob,68,"
|
String expectedEnd = "_m_0000000.lob,68," + data.length() + ")";
|
||||||
+ data.length() + ")";
|
|
||||||
|
|
||||||
assertNotNull(returnVal);
|
assertNotNull(returnVal);
|
||||||
assertTrue("ExpectedStart: " + expectedStart + ", value: " + returnVal, returnVal.startsWith(expectedStart));
|
assertTrue("ExpectedStart: " + expectedStart + ", value: " + returnVal, returnVal.startsWith(expectedStart));
|
||||||
|
2
testdata/hive/scripts/customDelimImport.q
vendored
2
testdata/hive/scripts/customDelimImport.q
vendored
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `CUSTOM_DELIM_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` INT, `DATA_COL2` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\054' LINES TERMINATED BY '\174' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `CUSTOM_DELIM_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` INT, `DATA_COL2` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\054' LINES TERMINATED BY '\174' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/CUSTOM_DELIM_IMPORT' INTO TABLE `CUSTOM_DELIM_IMPORT`;
|
LOAD DATA INPATH 'file:BASEPATH/CUSTOM_DELIM_IMPORT' INTO TABLE `CUSTOM_DELIM_IMPORT`;
|
||||||
|
2
testdata/hive/scripts/dateImport.q
vendored
2
testdata/hive/scripts/dateImport.q
vendored
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `DATE_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `DATE_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/DATE_HIVE_IMPORT' INTO TABLE `DATE_HIVE_IMPORT`;
|
LOAD DATA INPATH 'file:BASEPATH/DATE_HIVE_IMPORT' INTO TABLE `DATE_HIVE_IMPORT`;
|
||||||
|
2
testdata/hive/scripts/decimalMapImport.q
vendored
2
testdata/hive/scripts/decimalMapImport.q
vendored
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `DECIMAL_MAP_HIVE_IMPORT` ( `DATA_COL0` DECIMAL(10, 10), `DATA_COL1` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `DECIMAL_MAP_HIVE_IMPORT` ( `DATA_COL0` DECIMAL(10, 10), `DATA_COL1` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/DECIMAL_MAP_HIVE_IMPORT' INTO TABLE `DECIMAL_MAP_HIVE_IMPORT`;
|
LOAD DATA INPATH 'file:BASEPATH/DECIMAL_MAP_HIVE_IMPORT' INTO TABLE `DECIMAL_MAP_HIVE_IMPORT`;
|
||||||
|
2
testdata/hive/scripts/failingImport.q
vendored
2
testdata/hive/scripts/failingImport.q
vendored
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `DATE_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `DATE_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/DATE_HIVE_IMPORT' INTO TABLE `DATE_HIVE_IMPORT`;
|
LOAD DATA INPATH 'file:BASEPATH/DATE_HIVE_IMPORT' INTO TABLE `DATE_HIVE_IMPORT`;
|
||||||
|
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `FIELD_WITH_NL_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` INT, `DATA_COL2` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `FIELD_WITH_NL_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` INT, `DATA_COL2` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/FIELD_WITH_NL_HIVE_IMPORT' INTO TABLE `FIELD_WITH_NL_HIVE_IMPORT`;
|
LOAD DATA INPATH 'file:BASEPATH/FIELD_WITH_NL_HIVE_IMPORT' INTO TABLE `FIELD_WITH_NL_HIVE_IMPORT`;
|
||||||
|
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `FIELD_WITH_NL_REPLACEMENT_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` INT, `DATA_COL2` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `FIELD_WITH_NL_REPLACEMENT_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` INT, `DATA_COL2` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/FIELD_WITH_NL_REPLACEMENT_HIVE_IMPORT' INTO TABLE `FIELD_WITH_NL_REPLACEMENT_HIVE_IMPORT`;
|
LOAD DATA INPATH 'file:BASEPATH/FIELD_WITH_NL_REPLACEMENT_HIVE_IMPORT' INTO TABLE `FIELD_WITH_NL_REPLACEMENT_HIVE_IMPORT`;
|
||||||
|
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `incrementalHiveAppendEmptyThenFullhive` ( `ID` INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `incrementalHiveAppendEmptyThenFullhive` ( `ID` INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/incrementalHiveAppendEmptyThenFull' INTO TABLE `incrementalHiveAppendEmptyThenFullhive`;
|
LOAD DATA INPATH 'file:BASEPATH/incrementalHiveAppendEmptyThenFull' INTO TABLE `incrementalHiveAppendEmptyThenFullhive`;
|
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `incrementalHiveAppendEmptyThenFullhive` ( `ID` INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `incrementalHiveAppendEmptyThenFullhive` ( `ID` INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/incrementalHiveAppendEmptyThenFull' INTO TABLE `incrementalHiveAppendEmptyThenFullhive`;
|
LOAD DATA INPATH 'file:BASEPATH/incrementalHiveAppendEmptyThenFull' INTO TABLE `incrementalHiveAppendEmptyThenFullhive`;
|
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `incrementalHiveAppendEmptyThenFullhive` ( `ID` INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `incrementalHiveAppendEmptyThenFullhive` ( `ID` INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/incrementalHiveAppendEmptyThenFull' INTO TABLE `incrementalHiveAppendEmptyThenFullhive`;
|
LOAD DATA INPATH 'file:BASEPATH/incrementalHiveAppendEmptyThenFull' INTO TABLE `incrementalHiveAppendEmptyThenFullhive`;
|
2
testdata/hive/scripts/normalImport.q
vendored
2
testdata/hive/scripts/normalImport.q
vendored
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `NORMAL_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` INT, `DATA_COL2` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `NORMAL_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` INT, `DATA_COL2` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/NORMAL_HIVE_IMPORT' INTO TABLE `NORMAL_HIVE_IMPORT`;
|
LOAD DATA INPATH 'file:BASEPATH/NORMAL_HIVE_IMPORT' INTO TABLE `NORMAL_HIVE_IMPORT`;
|
||||||
|
2
testdata/hive/scripts/numericImport.q
vendored
2
testdata/hive/scripts/numericImport.q
vendored
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `NUMERIC_HIVE_IMPORT` ( `DATA_COL0` DOUBLE, `DATA_COL1` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `NUMERIC_HIVE_IMPORT` ( `DATA_COL0` DOUBLE, `DATA_COL1` STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/NUMERIC_HIVE_IMPORT' INTO TABLE `NUMERIC_HIVE_IMPORT`;
|
LOAD DATA INPATH 'file:BASEPATH/NUMERIC_HIVE_IMPORT' INTO TABLE `NUMERIC_HIVE_IMPORT`;
|
||||||
|
2
testdata/hive/scripts/partitionImport.q
vendored
2
testdata/hive/scripts/partitionImport.q
vendored
@ -14,4 +14,4 @@
|
|||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
CREATE TABLE IF NOT EXISTS `PARTITION_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` INT, `DATA_COL2` STRING) PARTITIONED BY (ds STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
CREATE TABLE IF NOT EXISTS `PARTITION_HIVE_IMPORT` ( `DATA_COL0` STRING, `DATA_COL1` INT, `DATA_COL2` STRING) PARTITIONED BY (ds STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE;
|
||||||
LOAD DATA INPATH 'file:BASEPATH/sqoop/warehouse/PARTITION_HIVE_IMPORT' INTO TABLE `PARTITION_HIVE_IMPORT` PARTITION (ds='20110413');
|
LOAD DATA INPATH 'file:BASEPATH/PARTITION_HIVE_IMPORT' INTO TABLE `PARTITION_HIVE_IMPORT` PARTITION (ds='20110413');
|
||||||
|
Loading…
Reference in New Issue
Block a user