mirror of
https://github.com/apache/sqoop.git
synced 2025-05-02 17:22:25 +08:00
SQOOP-3394: External Hive table tests should use unique external dir names
(Boglarka Egyed via Szabolcs Vasas)
This commit is contained in:
parent
1f7b0bf841
commit
15097756c7
@ -48,15 +48,15 @@ public class S3TestUtils {
|
|||||||
|
|
||||||
private static final String BUCKET_TEMP_DIR = "/tmp/";
|
private static final String BUCKET_TEMP_DIR = "/tmp/";
|
||||||
|
|
||||||
private static final String EXTERNAL_TABLE_DIR = "/externaldir";
|
|
||||||
|
|
||||||
private static final String TARGET_DIR_NAME_PREFIX = "/testdir";
|
private static final String TARGET_DIR_NAME_PREFIX = "/testdir";
|
||||||
|
private static final String HIVE_EXTERNAL_DIR_NAME_PREFIX = "/externaldir";
|
||||||
|
|
||||||
private static final String TEMPORARY_ROOTDIR_SUFFIX = "_temprootdir";
|
private static final String TEMPORARY_ROOTDIR_SUFFIX = "_temprootdir";
|
||||||
|
|
||||||
public static final String HIVE_EXTERNAL_TABLE_NAME = "test_external_table";
|
public static final String HIVE_EXTERNAL_TABLE_NAME = "test_external_table";
|
||||||
|
|
||||||
private static String targetDirName = TARGET_DIR_NAME_PREFIX;
|
private static String targetDirName;
|
||||||
|
private static String hiveExternalTableDirName;
|
||||||
|
|
||||||
private static final String[] COLUMN_NAMES = {"ID", "SUPERHERO", "COMICS", "DEBUT"};
|
private static final String[] COLUMN_NAMES = {"ID", "SUPERHERO", "COMICS", "DEBUT"};
|
||||||
private static final String[] COLUMN_TYPES = { "INT", "VARCHAR(25)", "VARCHAR(25)", "INT"};
|
private static final String[] COLUMN_TYPES = { "INT", "VARCHAR(25)", "VARCHAR(25)", "INT"};
|
||||||
@ -87,19 +87,27 @@ private static String getTemporaryCredentialsProviderClass() {
|
|||||||
return TEMPORARY_CREDENTIALS_PROVIDER_CLASS;
|
return TEMPORARY_CREDENTIALS_PROVIDER_CLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setUniqueTargetDirName() {
|
private static String generateUniqueDirName(String dirPrefix) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
targetDirName = targetDirName + "-" + uuid;
|
return dirPrefix + "-" + uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void resetTargetDirName() {
|
private static void resetTargetDirName() {
|
||||||
targetDirName = TARGET_DIR_NAME_PREFIX;
|
targetDirName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void resetHiveExternalDirName() {
|
||||||
|
hiveExternalTableDirName = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTargetDirName() {
|
private static String getTargetDirName() {
|
||||||
return targetDirName;
|
return targetDirName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getHiveExternalTableDirName() {
|
||||||
|
return hiveExternalTableDirName;
|
||||||
|
}
|
||||||
|
|
||||||
public static Path getTargetDirPath() {
|
public static Path getTargetDirPath() {
|
||||||
String targetPathString = getBucketTempDirPath() + getTargetDirName();
|
String targetPathString = getBucketTempDirPath() + getTargetDirName();
|
||||||
return new Path(targetPathString);
|
return new Path(targetPathString);
|
||||||
@ -111,7 +119,7 @@ private static Path getBucketTempDirPath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Path getExternalTableDirPath() {
|
public static Path getExternalTableDirPath() {
|
||||||
String externalTableDir = getBucketTempDirPath() + EXTERNAL_TABLE_DIR;
|
String externalTableDir = getBucketTempDirPath() + getHiveExternalTableDirName();
|
||||||
return new Path(externalTableDir);
|
return new Path(externalTableDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +136,7 @@ public static FileSystem setupS3ImportTestCase(S3CredentialGenerator s3Credentia
|
|||||||
|
|
||||||
FileSystem s3Client = FileSystem.get(hadoopConf);
|
FileSystem s3Client = FileSystem.get(hadoopConf);
|
||||||
|
|
||||||
setUniqueTargetDirName();
|
targetDirName = generateUniqueDirName(TARGET_DIR_NAME_PREFIX);
|
||||||
|
|
||||||
cleanUpDirectory(s3Client, getTargetDirPath());
|
cleanUpDirectory(s3Client, getTargetDirPath());
|
||||||
|
|
||||||
@ -157,6 +165,7 @@ private static void setHadoopConfigParametersForS3UnitTests(Configuration hadoop
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static HiveMiniCluster setupS3ExternalHiveTableImportTestCase(S3CredentialGenerator s3CredentialGenerator) {
|
public static HiveMiniCluster setupS3ExternalHiveTableImportTestCase(S3CredentialGenerator s3CredentialGenerator) {
|
||||||
|
hiveExternalTableDirName = generateUniqueDirName(HIVE_EXTERNAL_DIR_NAME_PREFIX);
|
||||||
HiveMiniCluster hiveMiniCluster = new HiveMiniCluster(new NoAuthenticationConfiguration());
|
HiveMiniCluster hiveMiniCluster = new HiveMiniCluster(new NoAuthenticationConfiguration());
|
||||||
hiveMiniCluster.start();
|
hiveMiniCluster.start();
|
||||||
S3TestUtils.setS3CredentialsInConf(hiveMiniCluster.getConfig(), s3CredentialGenerator);
|
S3TestUtils.setS3CredentialsInConf(hiveMiniCluster.getConfig(), s3CredentialGenerator);
|
||||||
@ -425,5 +434,6 @@ public static void tearDownS3IncrementalImportTestCase(FileSystem s3Client) {
|
|||||||
public static void tearDownS3ExternalHiveTableImportTestCase(FileSystem s3Client) {
|
public static void tearDownS3ExternalHiveTableImportTestCase(FileSystem s3Client) {
|
||||||
cleanUpTargetDir(s3Client);
|
cleanUpTargetDir(s3Client);
|
||||||
cleanUpDirectory(s3Client, getExternalTableDirPath());
|
cleanUpDirectory(s3Client, getExternalTableDirPath());
|
||||||
|
resetHiveExternalDirName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user