sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject sqoop git commit: SQOOP-3347: Make verify() more generic in AvroTestUtils
Date Fri, 20 Jul 2018 14:57:50 GMT
Repository: sqoop
Updated Branches:
  refs/heads/trunk b3e941be0 -> 6c6963abe


SQOOP-3347: Make verify() more generic in AvroTestUtils

(Boglarka Egyed via Szabolcs Vasas)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/6c6963ab
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/6c6963ab
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/6c6963ab

Branch: refs/heads/trunk
Commit: 6c6963abe8f0513a19bf61a8c9055563ff245b1c
Parents: b3e941b
Author: Szabolcs Vasas <vasas@apache.org>
Authored: Fri Jul 20 16:56:47 2018 +0200
Committer: Szabolcs Vasas <vasas@apache.org>
Committed: Fri Jul 20 16:56:47 2018 +0200

----------------------------------------------------------------------
 .../avro/AvroImportForNumericTypesTest.java         |  1 +
 .../sqoop/manager/hsqldb/TestHsqldbAvroPadding.java |  1 +
 .../org/apache/sqoop/testutil/AvroTestUtils.java    | 16 ++++++++++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/6c6963ab/src/test/org/apache/sqoop/importjob/avro/AvroImportForNumericTypesTest.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/importjob/avro/AvroImportForNumericTypesTest.java b/src/test/org/apache/sqoop/importjob/avro/AvroImportForNumericTypesTest.java
index e04caf7..ff13dc3 100644
--- a/src/test/org/apache/sqoop/importjob/avro/AvroImportForNumericTypesTest.java
+++ b/src/test/org/apache/sqoop/importjob/avro/AvroImportForNumericTypesTest.java
@@ -204,6 +204,7 @@ public class AvroImportForNumericTypesTest extends ImportJobTestCase {
   }
 
   private void verify() {
+    AvroTestUtils.registerDecimalConversionUsageForVerification();
     AvroTestUtils.verify(configuration.getExpectedResults(), getConf(), getTablePath());
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6c6963ab/src/test/org/apache/sqoop/manager/hsqldb/TestHsqldbAvroPadding.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/manager/hsqldb/TestHsqldbAvroPadding.java b/src/test/org/apache/sqoop/manager/hsqldb/TestHsqldbAvroPadding.java
index 7e42bf1..bb7cae4 100644
--- a/src/test/org/apache/sqoop/manager/hsqldb/TestHsqldbAvroPadding.java
+++ b/src/test/org/apache/sqoop/manager/hsqldb/TestHsqldbAvroPadding.java
@@ -76,6 +76,7 @@ public class TestHsqldbAvroPadding extends ImportJobTestCase {
     builder.withProperty("sqoop.avro.decimal_padding.enable", "true");
     String[] args = builder.build();
     runImport(args);
+    AvroTestUtils.registerDecimalConversionUsageForVerification();
     AvroTestUtils.verify(AvroTestUtils.getExpectedResults(), getConf(), getTablePath());
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6c6963ab/src/test/org/apache/sqoop/testutil/AvroTestUtils.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/testutil/AvroTestUtils.java b/src/test/org/apache/sqoop/testutil/AvroTestUtils.java
index 75940bf..04a8494 100644
--- a/src/test/org/apache/sqoop/testutil/AvroTestUtils.java
+++ b/src/test/org/apache/sqoop/testutil/AvroTestUtils.java
@@ -25,6 +25,8 @@ import org.apache.avro.generic.GenericDatumReader;
 import org.apache.avro.generic.GenericRecord;
 import org.apache.avro.io.DatumReader;
 import org.apache.avro.mapred.FsInput;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 
@@ -37,6 +39,11 @@ import static org.junit.Assert.assertEquals;
 
 public class AvroTestUtils {
 
+  private static final String OUTPUT_FILE_NAME = "part-m-00000.avro";
+
+  public static final Log LOG = LogFactory.getLog(
+          AvroTestUtils.class.getName());
+
   public static List<String[]> getInputData() {
     List<String[]> data = new ArrayList<>();
     data.add(new String[]{"1", "'Aaron'", "1000000.05", "'engineering'"});
@@ -63,9 +70,13 @@ public class AvroTestUtils {
         .withOption("table", testCase.getTableName());
   }
 
-  public static void verify(String[] expectedResults, Configuration conf, Path tablePath)
{
-    Path outputFile = new Path(tablePath, "part-m-00000.avro");
+  public static void registerDecimalConversionUsageForVerification() {
     GenericData.get().addLogicalTypeConversion(new Conversions.DecimalConversion());
+  }
+
+  public static void verify(String[] expectedResults, Configuration conf, Path tablePath)
{
+    Path outputFile = new Path(tablePath, OUTPUT_FILE_NAME);
+
     try (DataFileReader<GenericRecord> reader = read(outputFile, conf)) {
       GenericRecord record;
       if (!reader.hasNext() && expectedResults != null && expectedResults.length
> 0) {
@@ -78,6 +89,7 @@ public class AvroTestUtils {
       }
     }
     catch (IOException ioe) {
+      LOG.error("Issue with verifying the output", ioe);
       throw new RuntimeException(ioe);
     }
   }


Mime
View raw message