accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmil...@apache.org
Subject [accumulo] branch master updated: Added a couple Tests to AccumuloOutputFormat (#1132)
Date Thu, 02 May 2019 15:05:37 GMT
This is an automated email from the ASF dual-hosted git repository.

mmiller pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e6e364  Added a couple Tests to AccumuloOutputFormat  (#1132)
5e6e364 is described below

commit 5e6e36446744d2d43c82ca2fc1b76ddff6f0e76c
Author: Jeffrey Manno <jeffreymanno15@gmail.com>
AuthorDate: Thu May 2 11:05:32 2019 -0400

    Added a couple Tests to AccumuloOutputFormat  (#1132)
---
 .../hadoop/mapred/AccumuloOutputFormatTest.java    | 41 +++++++++++++++++++++
 .../hadoop/mapreduce/AccumuloOutputFormatTest.java | 43 ++++++++++++++++++++++
 2 files changed, 84 insertions(+)

diff --git a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloOutputFormatTest.java
b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloOutputFormatTest.java
index 0ba7ef9..26a7a67 100644
--- a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloOutputFormatTest.java
+++ b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapred/AccumuloOutputFormatTest.java
@@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.fail;
 
+import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
@@ -91,4 +93,43 @@ public class AccumuloOutputFormatTest {
     } catch (IllegalStateException e) {}
   }
 
+  @Test
+  public void testCreateTables() {
+    JobConf job = new JobConf();
+    String tableName = "test_create_tables";
+
+    Properties cp = Accumulo.newClientProperties().to("test", "zk").as("blah", "blah").build();
+
+    AccumuloOutputFormat.configure().clientProperties(cp).defaultTable(tableName).createTables(true)
+        .store(job);
+
+    assertEquals("Should have been able to create table", true,
+        OutputConfigurator.canCreateTables(AccumuloOutputFormat.class, job));
+  }
+
+  @Test
+  public void testClientPropertiesPath() throws Exception {
+    JobConf job = new JobConf();
+    Properties cp = Accumulo.newClientProperties().to("test", "zk").as("blah", "blah").build();
+
+    try {
+      File file = File.createTempFile("accumulo-client", ".properties", null);
+      file.deleteOnExit();
+
+      FileWriter writer = new FileWriter(file);
+      writer.write("auth.type=password\n");
+      writer.write("instance.zookeepers=zk\n");
+      writer.write("instance.name=test\n");
+      writer.write("auth.principal=blah\n");
+      writer.write("auth.token=blah");
+      writer.close();
+
+      AccumuloOutputFormat.configure().clientPropertiesPath(file.getAbsolutePath()).store(job);
+
+      assertEquals("Properties from path does not match the expected values ", cp,
+          OutputConfigurator.getClientProperties(AccumuloOutputFormat.class, job));
+    } catch (IOException e) {
+      throw new IllegalStateException(e);
+    }
+  }
 }
diff --git a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloOutputFormatTest.java
b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloOutputFormatTest.java
index d16ee68..ecbb77b 100644
--- a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloOutputFormatTest.java
+++ b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/mapreduce/AccumuloOutputFormatTest.java
@@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.fail;
 
+import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
@@ -93,4 +95,45 @@ public class AccumuloOutputFormatTest {
     } catch (IllegalStateException e) {}
   }
 
+  @Test
+  public void testCreateTables() throws Exception {
+    Job job = Job.getInstance();
+    String tableName = "test_create_tables";
+
+    Properties cp = Accumulo.newClientProperties().to("test", "zk").as("blah", "blah").build();
+
+    AccumuloOutputFormat.configure().clientProperties(cp).defaultTable(tableName).createTables(true)
+        .store(job);
+
+    assertEquals("Should have been able to create table", true,
+        OutputConfigurator.canCreateTables(AccumuloOutputFormat.class, job.getConfiguration()));
+  }
+
+  @Test
+  public void testClientPropertiesPath() throws Exception {
+    Job job = Job.getInstance();
+    Properties cp = Accumulo.newClientProperties().to("test", "zk").as("blah", "blah").build();
+
+    try {
+      File file = File.createTempFile("accumulo-client", ".properties", null);
+      file.deleteOnExit();
+
+      FileWriter writer = new FileWriter(file);
+      writer.write("auth.type=password\n");
+      writer.write("instance.zookeepers=zk\n");
+      writer.write("instance.name=test\n");
+      writer.write("auth.principal=blah\n");
+      writer.write("auth.token=blah");
+      writer.close();
+
+      AccumuloOutputFormat.configure().clientPropertiesPath(file.getAbsolutePath()).store(job);
+
+      assertEquals("Properties from path does not match the expected values ", cp,
+          OutputConfigurator.getClientProperties(AccumuloOutputFormat.class,
+              job.getConfiguration()));
+    } catch (IOException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+
 }


Mime
View raw message