mirror of
https://github.com/apache/sqoop.git
synced 2025-05-03 19:21:37 +08:00
SQOOP-3380: parquet-configurator-implementation is not recognized as an option
(Szabolcs Vasas)
This commit is contained in:
parent
c814e58348
commit
b37e0c6053
@ -547,6 +547,11 @@ protected RelatedOptions getCommonOptions() {
|
|||||||
.hasArg()
|
.hasArg()
|
||||||
.withArgName("boolean")
|
.withArgName("boolean")
|
||||||
.create());
|
.create());
|
||||||
|
commonOpts.addOption(OptionBuilder
|
||||||
|
.hasArg()
|
||||||
|
.withDescription("The implementation used during Parquet reading/writing")
|
||||||
|
.withLongOpt(PARQUET_CONFIGURATOR_IMPLEMENTATION)
|
||||||
|
.create());
|
||||||
|
|
||||||
return commonOpts;
|
return commonOpts;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
package org.apache.sqoop.tool;
|
package org.apache.sqoop.tool;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
|
import org.apache.commons.cli.Option;
|
||||||
import org.apache.sqoop.SqoopOptions;
|
import org.apache.sqoop.SqoopOptions;
|
||||||
|
import org.apache.sqoop.cli.RelatedOptions;
|
||||||
import org.apache.sqoop.mapreduce.parquet.ParquetJobConfiguratorImplementation;
|
import org.apache.sqoop.mapreduce.parquet.ParquetJobConfiguratorImplementation;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@ -30,11 +32,14 @@
|
|||||||
import static org.apache.sqoop.mapreduce.parquet.ParquetJobConfiguratorImplementation.HADOOP;
|
import static org.apache.sqoop.mapreduce.parquet.ParquetJobConfiguratorImplementation.HADOOP;
|
||||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class TestBaseSqoopTool {
|
public class TestBaseSqoopTool {
|
||||||
|
|
||||||
|
private static final String PARQUET_CONFIGURATOR_IMPLEMENTATION = "parquet-configurator-implementation";
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException exception = ExpectedException.none();
|
public ExpectedException exception = ExpectedException.none();
|
||||||
|
|
||||||
@ -80,7 +85,7 @@ public void testRethrowIfRequiredWithRethrowPropertySetAndException() {
|
|||||||
public void testApplyCommonOptionsSetsParquetJobConfigurationImplementationFromCommandLine() throws Exception {
|
public void testApplyCommonOptionsSetsParquetJobConfigurationImplementationFromCommandLine() throws Exception {
|
||||||
ParquetJobConfiguratorImplementation expectedValue = HADOOP;
|
ParquetJobConfiguratorImplementation expectedValue = HADOOP;
|
||||||
|
|
||||||
when(mockCommandLine.getOptionValue("parquet-configurator-implementation")).thenReturn(expectedValue.toString());
|
when(mockCommandLine.getOptionValue(PARQUET_CONFIGURATOR_IMPLEMENTATION)).thenReturn(expectedValue.toString());
|
||||||
|
|
||||||
testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
|
testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
|
||||||
|
|
||||||
@ -91,7 +96,7 @@ public void testApplyCommonOptionsSetsParquetJobConfigurationImplementationFromC
|
|||||||
public void testApplyCommonOptionsSetsParquetJobConfigurationImplementationFromCommandLineCaseInsensitively() throws Exception {
|
public void testApplyCommonOptionsSetsParquetJobConfigurationImplementationFromCommandLineCaseInsensitively() throws Exception {
|
||||||
String hadoopImplementationLowercase = "haDooP";
|
String hadoopImplementationLowercase = "haDooP";
|
||||||
|
|
||||||
when(mockCommandLine.getOptionValue("parquet-configurator-implementation")).thenReturn(hadoopImplementationLowercase);
|
when(mockCommandLine.getOptionValue(PARQUET_CONFIGURATOR_IMPLEMENTATION)).thenReturn(hadoopImplementationLowercase);
|
||||||
|
|
||||||
testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
|
testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
|
||||||
|
|
||||||
@ -112,7 +117,7 @@ public void testApplyCommonOptionsSetsParquetJobConfigurationImplementationFromC
|
|||||||
public void testApplyCommonOptionsPrefersParquetJobConfigurationImplementationFromCommandLine() throws Exception {
|
public void testApplyCommonOptionsPrefersParquetJobConfigurationImplementationFromCommandLine() throws Exception {
|
||||||
ParquetJobConfiguratorImplementation expectedValue = HADOOP;
|
ParquetJobConfiguratorImplementation expectedValue = HADOOP;
|
||||||
testSqoopOptions.getConf().set("parquetjob.configurator.implementation", "kite");
|
testSqoopOptions.getConf().set("parquetjob.configurator.implementation", "kite");
|
||||||
when(mockCommandLine.getOptionValue("parquet-configurator-implementation")).thenReturn(expectedValue.toString());
|
when(mockCommandLine.getOptionValue(PARQUET_CONFIGURATOR_IMPLEMENTATION)).thenReturn(expectedValue.toString());
|
||||||
|
|
||||||
testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
|
testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
|
||||||
|
|
||||||
@ -121,7 +126,7 @@ public void testApplyCommonOptionsPrefersParquetJobConfigurationImplementationFr
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyCommonOptionsThrowsWhenInvalidParquetJobConfigurationImplementationIsSet() throws Exception {
|
public void testApplyCommonOptionsThrowsWhenInvalidParquetJobConfigurationImplementationIsSet() throws Exception {
|
||||||
when(mockCommandLine.getOptionValue("parquet-configurator-implementation")).thenReturn("this_is_definitely_not_valid");
|
when(mockCommandLine.getOptionValue(PARQUET_CONFIGURATOR_IMPLEMENTATION)).thenReturn("this_is_definitely_not_valid");
|
||||||
|
|
||||||
exception.expectMessage("Invalid Parquet job configurator implementation is set: this_is_definitely_not_valid. Supported values are: [HADOOP]");
|
exception.expectMessage("Invalid Parquet job configurator implementation is set: this_is_definitely_not_valid. Supported values are: [HADOOP]");
|
||||||
testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
|
testBaseSqoopTool.applyCommonOptions(mockCommandLine, testSqoopOptions);
|
||||||
@ -133,4 +138,19 @@ public void testApplyCommonOptionsDoesNotChangeDefaultParquetJobConfigurationImp
|
|||||||
|
|
||||||
assertEquals(HADOOP, testSqoopOptions.getParquetConfiguratorImplementation());
|
assertEquals(HADOOP, testSqoopOptions.getParquetConfiguratorImplementation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetCommonOptionsAddsParquetJobConfigurationImplementation() {
|
||||||
|
RelatedOptions commonOptions = testBaseSqoopTool.getCommonOptions();
|
||||||
|
|
||||||
|
assertTrue(commonOptions.hasOption(PARQUET_CONFIGURATOR_IMPLEMENTATION));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParquetJobConfigurationImplementationOptionHasAnArg() {
|
||||||
|
RelatedOptions commonOptions = testBaseSqoopTool.getCommonOptions();
|
||||||
|
|
||||||
|
Option implementationOption = commonOptions.getOption(PARQUET_CONFIGURATOR_IMPLEMENTATION);
|
||||||
|
assertTrue(implementationOption.hasArg());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user