mirror of
https://github.com/apache/sqoop.git
synced 2025-05-02 12:19:27 +08:00
SQOOP-3405: Refactor: break up Parameterized tests on a per database basis
(Fero Szabo via Szabolcs Vasas)
This commit is contained in:
parent
65b51b959e
commit
0a7407613b
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob;
|
||||
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
|
||||
public interface DatabaseAdapterFactory {
|
||||
|
||||
DatabaseAdapter createAdapter();
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MySQLImportJobTestConfiguration implements ImportJobTestConfiguration, AvroTestConfiguration, ParquetTestConfiguration {
|
||||
public class MysqlImportJobTestConfiguration implements ImportJobTestConfiguration, AvroTestConfiguration, ParquetTestConfiguration {
|
||||
|
||||
@Override
|
||||
public String[] getTypes() {
|
@ -21,7 +21,7 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MSSQLServerImportJobTestConfiguration implements ImportJobTestConfiguration, AvroTestConfiguration, ParquetTestConfiguration {
|
||||
public class SqlServerImportJobTestConfiguration implements ImportJobTestConfiguration, AvroTestConfiguration, ParquetTestConfiguration {
|
||||
|
||||
@Override
|
||||
public String[] getTypes() {
|
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob.numerictypes;
|
||||
|
||||
import org.apache.sqoop.importjob.configuration.MysqlImportJobTestConfiguration;
|
||||
import org.apache.sqoop.testcategories.thirdpartytest.MysqlTest;
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.MysqlDatabaseAdapter;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category(MysqlTest.class)
|
||||
public class MysqlNumericTypesImportTest extends NumericTypesImportTestBase {
|
||||
|
||||
@Override
|
||||
public DatabaseAdapter createAdapter() {
|
||||
return new MysqlDatabaseAdapter();
|
||||
}
|
||||
|
||||
public MysqlNumericTypesImportTest() {
|
||||
super(new MysqlImportJobTestConfiguration(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY);
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob;
|
||||
package org.apache.sqoop.importjob.numerictypes;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@ -25,46 +25,31 @@
|
||||
import org.apache.parquet.schema.MessageType;
|
||||
import org.apache.parquet.schema.OriginalType;
|
||||
import org.apache.sqoop.SqoopOptions;
|
||||
import org.apache.sqoop.importjob.DatabaseAdapterFactory;
|
||||
import org.apache.sqoop.importjob.configuration.AvroTestConfiguration;
|
||||
import org.apache.sqoop.importjob.configuration.MSSQLServerImportJobTestConfiguration;
|
||||
import org.apache.sqoop.importjob.configuration.MySQLImportJobTestConfiguration;
|
||||
import org.apache.sqoop.importjob.configuration.OracleImportJobTestConfiguration;
|
||||
import org.apache.sqoop.importjob.configuration.ParquetTestConfiguration;
|
||||
import org.apache.sqoop.importjob.configuration.PostgresqlImportJobTestConfigurationForNumeric;
|
||||
import org.apache.sqoop.testcategories.thirdpartytest.ThirdPartyTest;
|
||||
import org.apache.sqoop.testutil.ArgumentArrayBuilder;
|
||||
import org.apache.sqoop.testutil.AvroTestUtils;
|
||||
import org.apache.sqoop.testutil.ImportJobTestCase;
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.MSSQLServerDatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.MySqlDatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.OracleDatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.PostgresDatabaseAdapter;
|
||||
import org.apache.sqoop.importjob.configuration.OracleImportJobTestConfigurationForNumber;
|
||||
import org.apache.sqoop.importjob.configuration.PostgresqlImportJobTestConfigurationPaddingShouldSucceed;
|
||||
import org.apache.sqoop.util.ParquetReader;
|
||||
import org.apache.sqoop.util.BlockJUnit4ClassRunnerWithParametersFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.apache.sqoop.SqoopOptions.FileLayout.AvroDataFile;
|
||||
import static org.apache.sqoop.SqoopOptions.FileLayout.ParquetFile;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
@Parameterized.UseParametersRunnerFactory(BlockJUnit4ClassRunnerWithParametersFactory.class)
|
||||
@Category(ThirdPartyTest.class)
|
||||
/**
|
||||
* This test covers the behavior of the Avro import for fixed point decimal types, i.e. NUMBER, NUMERIC
|
||||
@ -80,9 +65,9 @@
|
||||
* 2. Decimal padding during avro or parquet import
|
||||
* In case of Oracle and Postgres, Sqoop has to pad the values with 0s to avoid errors.
|
||||
*/
|
||||
public class NumericTypesImportTest<T extends AvroTestConfiguration & ParquetTestConfiguration> extends ImportJobTestCase {
|
||||
public abstract class NumericTypesImportTestBase<T extends AvroTestConfiguration & ParquetTestConfiguration> extends ImportJobTestCase implements DatabaseAdapterFactory {
|
||||
|
||||
public static final Log LOG = LogFactory.getLog(NumericTypesImportTest.class.getName());
|
||||
public static final Log LOG = LogFactory.getLog(NumericTypesImportTestBase.class.getName());
|
||||
|
||||
private Configuration conf = new Configuration();
|
||||
|
||||
@ -93,30 +78,17 @@ public class NumericTypesImportTest<T extends AvroTestConfiguration & ParquetTes
|
||||
|
||||
// Constants for the basic test case, that doesn't use extra arguments
|
||||
// that are required to avoid errors, i.e. padding and default precision and scale.
|
||||
private final static boolean SUCCEED_WITHOUT_EXTRA_ARGS = false;
|
||||
private final static boolean FAIL_WITHOUT_EXTRA_ARGS = true;
|
||||
protected final static boolean SUCCEED_WITHOUT_EXTRA_ARGS = false;
|
||||
protected final static boolean FAIL_WITHOUT_EXTRA_ARGS = true;
|
||||
|
||||
// Constants for the test case that has padding specified but not default precision and scale.
|
||||
private final static boolean SUCCEED_WITH_PADDING_ONLY = false;
|
||||
private final static boolean FAIL_WITH_PADDING_ONLY = true;
|
||||
protected final static boolean SUCCEED_WITH_PADDING_ONLY = false;
|
||||
protected final static boolean FAIL_WITH_PADDING_ONLY = true;
|
||||
|
||||
private Path tableDirPath;
|
||||
|
||||
@Parameters(name = "Adapter: {0}| Config: {1}| failWithoutExtraArgs: {2}| failWithPadding: {3}")
|
||||
public static Iterable<? extends Object> testConfigurations() {
|
||||
DatabaseAdapter postgresAdapter = new PostgresDatabaseAdapter();
|
||||
OracleDatabaseAdapter oracleDatabaseAdapter = new OracleDatabaseAdapter();
|
||||
return Arrays.asList(
|
||||
new Object[] {oracleDatabaseAdapter, new OracleImportJobTestConfigurationForNumber(), FAIL_WITHOUT_EXTRA_ARGS, FAIL_WITH_PADDING_ONLY},
|
||||
new Object[] {oracleDatabaseAdapter, new OracleImportJobTestConfiguration(), FAIL_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY},
|
||||
new Object[] { new MySqlDatabaseAdapter(), new MySQLImportJobTestConfiguration(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY},
|
||||
new Object[] { new MSSQLServerDatabaseAdapter(), new MSSQLServerImportJobTestConfiguration(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY},
|
||||
new Object[] { postgresAdapter, new PostgresqlImportJobTestConfigurationForNumeric(), FAIL_WITHOUT_EXTRA_ARGS, FAIL_WITH_PADDING_ONLY},
|
||||
new Object[] { postgresAdapter, new PostgresqlImportJobTestConfigurationPaddingShouldSucceed(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY}
|
||||
);
|
||||
}
|
||||
|
||||
public NumericTypesImportTest(DatabaseAdapter adapter, T configuration, boolean failWithoutExtraArgs, boolean failWithPaddingOnly) {
|
||||
this.adapter = adapter;
|
||||
public NumericTypesImportTestBase(T configuration, boolean failWithoutExtraArgs, boolean failWithPaddingOnly) {
|
||||
this.adapter = createAdapter();
|
||||
this.configuration = configuration;
|
||||
this.failWithoutExtraArgs = failWithoutExtraArgs;
|
||||
this.failWithPadding = failWithPaddingOnly;
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob.numerictypes;
|
||||
|
||||
import org.apache.sqoop.importjob.configuration.AvroTestConfiguration;
|
||||
import org.apache.sqoop.importjob.configuration.OracleImportJobTestConfiguration;
|
||||
import org.apache.sqoop.importjob.configuration.OracleImportJobTestConfigurationForNumber;
|
||||
import org.apache.sqoop.importjob.configuration.ParquetTestConfiguration;
|
||||
import org.apache.sqoop.testcategories.thirdpartytest.OracleTest;
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.OracleDatabaseAdapter;
|
||||
import org.apache.sqoop.util.BlockJUnit4ClassRunnerWithParametersFactory;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Category(OracleTest.class)
|
||||
@RunWith(Parameterized.class)
|
||||
@Parameterized.UseParametersRunnerFactory(BlockJUnit4ClassRunnerWithParametersFactory.class)
|
||||
public class OracleNumericTypesImportTest<T extends AvroTestConfiguration & ParquetTestConfiguration> extends NumericTypesImportTestBase<T> {
|
||||
|
||||
@Override
|
||||
public DatabaseAdapter createAdapter() {
|
||||
return new OracleDatabaseAdapter();
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name = "Config: {0}| failWithoutExtraArgs: {1}| failWithPadding: {2}")
|
||||
public static Iterable<? extends Object> testConfigurations() {
|
||||
return Arrays.asList(
|
||||
new Object[]{new OracleImportJobTestConfigurationForNumber(), FAIL_WITHOUT_EXTRA_ARGS, FAIL_WITH_PADDING_ONLY},
|
||||
new Object[]{new OracleImportJobTestConfiguration(), FAIL_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY}
|
||||
);
|
||||
}
|
||||
|
||||
public OracleNumericTypesImportTest(T configuration, boolean failWithoutExtraArgs, boolean failWithPaddingOnly) {
|
||||
super(configuration, failWithoutExtraArgs, failWithPaddingOnly);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob.numerictypes;
|
||||
|
||||
import org.apache.sqoop.importjob.configuration.AvroTestConfiguration;
|
||||
import org.apache.sqoop.importjob.configuration.ParquetTestConfiguration;
|
||||
import org.apache.sqoop.importjob.configuration.PostgresqlImportJobTestConfigurationForNumeric;
|
||||
import org.apache.sqoop.importjob.configuration.PostgresqlImportJobTestConfigurationPaddingShouldSucceed;
|
||||
import org.apache.sqoop.testcategories.thirdpartytest.PostgresqlTest;
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.PostgresDatabaseAdapter;
|
||||
import org.apache.sqoop.util.BlockJUnit4ClassRunnerWithParametersFactory;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Category(PostgresqlTest.class)
|
||||
@RunWith(Parameterized.class)
|
||||
@Parameterized.UseParametersRunnerFactory(BlockJUnit4ClassRunnerWithParametersFactory.class)
|
||||
public class PostgresNumericTypesImportTest<T extends AvroTestConfiguration & ParquetTestConfiguration> extends NumericTypesImportTestBase<T> {
|
||||
|
||||
@Override
|
||||
public DatabaseAdapter createAdapter() {
|
||||
return new PostgresDatabaseAdapter();
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name = "Config: {0}| failWithoutExtraArgs: {1}| failWithPadding: {2}")
|
||||
public static Iterable<? extends Object> testConfigurations() {
|
||||
return Arrays.asList(
|
||||
new Object[]{new PostgresqlImportJobTestConfigurationForNumeric(), FAIL_WITHOUT_EXTRA_ARGS, FAIL_WITH_PADDING_ONLY},
|
||||
new Object[]{new PostgresqlImportJobTestConfigurationPaddingShouldSucceed(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY}
|
||||
);
|
||||
}
|
||||
|
||||
public PostgresNumericTypesImportTest(T configuration, boolean failWithoutExtraArgs, boolean failWithPaddingOnly) {
|
||||
super(configuration, failWithoutExtraArgs, failWithPaddingOnly);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob.numerictypes;
|
||||
|
||||
import org.apache.sqoop.importjob.configuration.SqlServerImportJobTestConfiguration;
|
||||
import org.apache.sqoop.testcategories.thirdpartytest.SqlServerTest;
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.SqlServerDatabaseAdapter;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category(SqlServerTest.class)
|
||||
public class SqlServerNumericTypesImportTest extends NumericTypesImportTestBase {
|
||||
|
||||
@Override
|
||||
public DatabaseAdapter createAdapter() {
|
||||
return new SqlServerDatabaseAdapter();
|
||||
}
|
||||
|
||||
public SqlServerNumericTypesImportTest() {
|
||||
super(new SqlServerImportJobTestConfiguration(), SUCCEED_WITHOUT_EXTRA_ARGS, SUCCEED_WITH_PADDING_ONLY);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob.splitby;
|
||||
|
||||
import org.apache.sqoop.testcategories.thirdpartytest.MysqlTest;
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.MysqlDatabaseAdapter;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category(MysqlTest.class)
|
||||
public class MysqlSplitByImportTest extends SplitByImportTestBase {
|
||||
|
||||
@Override
|
||||
public DatabaseAdapter createAdapter() {
|
||||
return new MysqlDatabaseAdapter();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob.splitby;
|
||||
|
||||
import org.apache.sqoop.testcategories.thirdpartytest.OracleTest;
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.OracleDatabaseAdapter;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category(OracleTest.class)
|
||||
public class OracleSplitByImportTest extends SplitByImportTestBase {
|
||||
|
||||
@Override
|
||||
public DatabaseAdapter createAdapter() {
|
||||
return new OracleDatabaseAdapter();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob.splitby;
|
||||
|
||||
import org.apache.sqoop.testcategories.thirdpartytest.PostgresqlTest;
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.PostgresDatabaseAdapter;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category(PostgresqlTest.class)
|
||||
public class PostgresSplitByImportTest extends SplitByImportTestBase {
|
||||
|
||||
@Override
|
||||
public DatabaseAdapter createAdapter() {
|
||||
return new PostgresDatabaseAdapter();
|
||||
}
|
||||
}
|
@ -16,35 +16,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob;
|
||||
package org.apache.sqoop.importjob.splitby;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.sqoop.SqoopOptions;
|
||||
import org.apache.sqoop.importjob.DatabaseAdapterFactory;
|
||||
import org.apache.sqoop.importjob.configuration.GenericImportJobSplitByTestConfiguration;
|
||||
import org.apache.sqoop.testcategories.thirdpartytest.ThirdPartyTest;
|
||||
import org.apache.sqoop.importjob.configuration.ImportJobTestConfiguration;
|
||||
import org.apache.sqoop.importjob.configuration.ParquetTestConfiguration;
|
||||
import org.apache.sqoop.testutil.ArgumentArrayBuilder;
|
||||
import org.apache.sqoop.testutil.ImportJobTestCase;
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.MSSQLServerDatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.MySqlDatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.OracleDatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.PostgresDatabaseAdapter;
|
||||
import org.apache.sqoop.util.BlockJUnit4ClassRunnerWithParametersFactory;
|
||||
import org.apache.sqoop.util.ParquetReader;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
@ -53,32 +43,18 @@
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
@Category(ThirdPartyTest.class)
|
||||
@Parameterized.UseParametersRunnerFactory(BlockJUnit4ClassRunnerWithParametersFactory.class)
|
||||
public class SplitByImportTest extends ImportJobTestCase {
|
||||
public abstract class SplitByImportTestBase extends ImportJobTestCase implements DatabaseAdapterFactory {
|
||||
|
||||
public static final Log LOG = LogFactory.getLog(SplitByImportTest.class.getName());
|
||||
public static final Log LOG = LogFactory.getLog(SplitByImportTestBase.class.getName());
|
||||
|
||||
private Configuration conf = new Configuration();
|
||||
|
||||
private final ParquetTestConfiguration configuration;
|
||||
private final DatabaseAdapter adapter;
|
||||
|
||||
@Parameters(name = "Adapter: {0}| Config: {1}")
|
||||
public static Iterable<? extends Object> testConfigurations() {
|
||||
GenericImportJobSplitByTestConfiguration testConfiguration = new GenericImportJobSplitByTestConfiguration();
|
||||
return asList(
|
||||
new Object[] {new OracleDatabaseAdapter(), testConfiguration},
|
||||
new Object[] {new PostgresDatabaseAdapter(), testConfiguration},
|
||||
new Object[] {new MSSQLServerDatabaseAdapter(), testConfiguration},
|
||||
new Object[] {new MySqlDatabaseAdapter(), testConfiguration}
|
||||
);
|
||||
}
|
||||
|
||||
public SplitByImportTest(DatabaseAdapter adapter, ParquetTestConfiguration configuration) {
|
||||
this.adapter = adapter;
|
||||
this.configuration = configuration;
|
||||
public SplitByImportTestBase() {
|
||||
this.adapter = createAdapter();
|
||||
this.configuration = new GenericImportJobSplitByTestConfiguration();
|
||||
}
|
||||
|
||||
@Rule
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.sqoop.importjob.splitby;
|
||||
|
||||
import org.apache.sqoop.testcategories.thirdpartytest.SqlServerTest;
|
||||
import org.apache.sqoop.testutil.adapter.DatabaseAdapter;
|
||||
import org.apache.sqoop.testutil.adapter.SqlServerDatabaseAdapter;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@Category(SqlServerTest.class)
|
||||
public class SqlServerSplitByImportTest extends SplitByImportTestBase {
|
||||
|
||||
@Override
|
||||
public DatabaseAdapter createAdapter() {
|
||||
return new SqlServerDatabaseAdapter();
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class MySqlDatabaseAdapter implements DatabaseAdapter {
|
||||
public class MysqlDatabaseAdapter implements DatabaseAdapter {
|
||||
private MySQLTestUtils mySQLTestUtils = new MySQLTestUtils();
|
||||
|
||||
public SqoopOptions injectConnectionParameters(SqoopOptions options) {
|
@ -24,7 +24,7 @@
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class MSSQLServerDatabaseAdapter implements DatabaseAdapter {
|
||||
public class SqlServerDatabaseAdapter implements DatabaseAdapter {
|
||||
|
||||
@Override
|
||||
public String getConnectionString() {
|
Loading…
Reference in New Issue
Block a user