accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [1/3] git commit: ACCUMULO-3160 Remove duplicate code from ConfigurableMacIT.
Date Fri, 26 Sep 2014 21:12:46 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6.2-SNAPSHOT 43528d5c9 -> 2ad407448
  refs/heads/master fa7e86647 -> 159d1b99d


ACCUMULO-3160 Remove duplicate code from ConfigurableMacIT.

Also changes the test from sharing a MAC to starting a new one
for each test method which better isolates test failures.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/2ad40744
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/2ad40744
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/2ad40744

Branch: refs/heads/1.6.2-SNAPSHOT
Commit: 2ad40744839dace578ebef1ffb4b28418222ab4b
Parents: 43528d5
Author: Josh Elser <elserj@apache.org>
Authored: Fri Sep 26 15:08:31 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Fri Sep 26 15:08:31 2014 -0400

----------------------------------------------------------------------
 .../accumulo/test/functional/ExamplesIT.java    | 124 ++++++++-----------
 1 file changed, 51 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/2ad40744/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java b/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java
index 7864ec8..22025a2 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/ExamplesIT.java
@@ -31,8 +31,6 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.accumulo.core.cli.BatchWriterOpts;
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.BatchScanner;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
@@ -76,50 +74,45 @@ import org.apache.accumulo.examples.simple.shard.Index;
 import org.apache.accumulo.examples.simple.shard.Query;
 import org.apache.accumulo.examples.simple.shard.Reverse;
 import org.apache.accumulo.minicluster.MemoryUnit;
-import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl.LogWriter;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
-import org.apache.accumulo.server.util.Admin;
 import org.apache.accumulo.start.Main;
 import org.apache.accumulo.test.TestIngest;
 import org.apache.accumulo.tracer.TraceServer;
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.apache.log4j.Logger;
+import org.junit.Before;
 import org.junit.Test;
 
-public class ExamplesIT extends AbstractMacIT {
-  BatchWriterOpts bwOpts = new BatchWriterOpts();
-
-  static Connector c;
-  static String instance;
-  static String keepers;
-  static String user = "root";
-  static String passwd;
-  String visibility = "A|B";
-  static String auths = "A,B";
-  BatchWriterConfig bwc = new BatchWriterConfig();
+public class ExamplesIT extends ConfigurableMacIT {
+  private static final Logger log = Logger.getLogger(ExamplesIT.class);
+  private static final BatchWriterOpts bwOpts = new BatchWriterOpts();
+  private static final BatchWriterConfig bwc = new BatchWriterConfig();
+  private static final String visibility = "A|B";
+  private static final String auths = "A,B";
+
+  Connector c;
+  String instance;
+  String keepers;
+  String user = "root";
+  String passwd;
   BatchWriter bw;
   IteratorSetting is;
-  static String dir;
-  static FileSystem fs;
-  private static MiniAccumuloClusterImpl cluster;
-
-  @BeforeClass
-  public static void before() throws Exception {
-    MiniAccumuloConfigImpl cfg = new MiniAccumuloConfigImpl(createTestDir(ExamplesIT.class.getName()),
AbstractMacIT.ROOT_PASSWORD);
-    cfg.setNativeLibPaths(NativeMapIT.nativeMapLocation().getAbsolutePath());
-    cfg.setDefaultMemory(cfg.getDefaultMemory() * 2, MemoryUnit.BYTE);
+  String dir;
+  FileSystem fs;
 
-    cfg.setProperty(Property.TSERV_NATIVEMAP_ENABLED, Boolean.TRUE.toString());
-    configureForEnvironment(cfg, ExamplesIT.class, createSharedTestDir(ExamplesIT.class.getName()
+ "-ssl"));
-    cluster = new MiniAccumuloClusterImpl(cfg);
-    cluster.start();
+  @Override
+  public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopConf) {
+    cfg.setDefaultMemory(cfg.getDefaultMemory() * 2, MemoryUnit.BYTE);
+  }
 
+  @Before
+  public void getClusterInfo() throws Exception {
+    c = getConnector();
     passwd = AbstractMacIT.ROOT_PASSWORD;
-    c = cluster.getConnector("root", ROOT_PASSWORD);
     fs = FileSystem.get(CachedConfiguration.getInstance());
     instance = c.getInstance().getInstanceName();
     keepers = c.getInstance().getZooKeepers();
@@ -129,18 +122,13 @@ public class ExamplesIT extends AbstractMacIT {
   }
 
   @Override
-  public Connector getConnector() throws AccumuloException, AccumuloSecurityException {
-    return cluster.getConnector("root", ROOT_PASSWORD);
-  }
-
-  @Override
-  public String rootPath() {
-    return cluster.getConfig().getDir().getAbsolutePath();
+  public int defaultTimeoutSeconds() {
+    return 6 * 60;
   }
 
-  @Test(timeout = 45 * 1000)
+  @Test
   public void testTrace() throws Exception {
-    Process trace = exec(TraceServer.class);
+    Process trace = cluster.exec(TraceServer.class);
     while (!c.tableOperations().exists("trace"))
       UtilWaitThread.sleep(500);
     Process p = goodExec(TracingExample.class, "-i", instance, "-z", keepers, "-u", user,
"-p", passwd, "-C", "-D", "-c");
@@ -161,7 +149,7 @@ public class ExamplesIT extends AbstractMacIT {
     trace.destroy();
   }
 
-  @Test(timeout = 20 * 1000)
+  @Test
   public void testClasspath() throws Exception {
     Process p = cluster.exec(Main.class, Collections.singletonList(MapReduceIT.hadoopTmpDirArg),
"classpath");
     assertEquals(0, p.waitFor());
@@ -179,11 +167,7 @@ public class ExamplesIT extends AbstractMacIT {
     assertTrue(level3 < level4);
   }
 
-  private Process exec(Class<TraceServer> class1) throws IOException {
-    return cluster.exec(class1);
-  }
-
-  @Test(timeout = 90 * 1000)
+  @Test
   public void testDirList() throws Exception {
     goodExec(Ingest.class, "-i", instance, "-z", keepers, "-u", user, "-p", passwd, "--dirTable",
"dirTable", "--indexTable", "indexTable", "--dataTable",
         "dataTable", "--vis", visibility, "--chunkSize", 10000 + "", cluster.getConfig().getDir().getAbsolutePath());
@@ -193,11 +177,11 @@ public class ExamplesIT extends AbstractMacIT {
       writer.flush();
     }
     String result = FunctionalTestUtils.readAll(cluster, QueryUtil.class, p);
-    System.out.println("result " + result);
+    log.info("result " + result);
     assertTrue(result.contains("accumulo-site.xml"));
   }
 
-  @Test(timeout = 6 * 1000)
+  @Test
   public void testAgeoffFilter() throws Exception {
     c.tableOperations().create("filtertest");
     is = new IteratorSetting(10, AgeOffFilter.class);
@@ -213,7 +197,7 @@ public class ExamplesIT extends AbstractMacIT {
     assertEquals(0, FunctionalTestUtils.count(c.createScanner("filtertest", Authorizations.EMPTY)));
   }
 
-  @Test(timeout = 60 * 1000)
+  @Test
   public void testStatsCombiner() throws Exception {
     String table = "statscombinertest";
     c.tableOperations().create(table);
@@ -228,18 +212,18 @@ public class ExamplesIT extends AbstractMacIT {
     bw.addMutation(m);
     bw.flush();
 
-    
+
     Iterator<Entry<Key, Value>> iter = c.createScanner(table, Authorizations.EMPTY).iterator();
     assertTrue("Iterator had no results", iter.hasNext());
     Entry<Key, Value> e = iter.next();
     assertEquals("Results ", "1,3,4,2", e.getValue().toString());
     assertFalse("Iterator had additional results", iter.hasNext());
-    
+
     m = new Mutation("foo");
     m.put("a", "b", "0,20,20,2");
     bw.addMutation(m);
     bw.close();
-    
+
     iter = c.createScanner(table, Authorizations.EMPTY).iterator();
     assertTrue("Iterator had no results", iter.hasNext());
     e = iter.next();
@@ -247,7 +231,7 @@ public class ExamplesIT extends AbstractMacIT {
     assertFalse("Iterator had additional results", iter.hasNext());
   }
 
-  @Test(timeout = 50 * 1000)
+  @Test
   public void testBloomFilters() throws Exception {
     c.tableOperations().create("bloom_test");
     c.tableOperations().setProperty("bloom_test", Property.TABLE_BLOOM_ENABLED.getKey(),
"true");
@@ -271,7 +255,7 @@ public class ExamplesIT extends AbstractMacIT {
     assertTrue(diff2 < diff);
   }
 
-  @Test(timeout = 3 * 60 * 1000)
+  @Test
   public void testShardedIndex() throws Exception {
     c.tableOperations().create("shard");
     c.tableOperations().create("doc2term");
@@ -296,7 +280,7 @@ public class ExamplesIT extends AbstractMacIT {
         "5", "--count", "1000");
   }
 
-  @Test(timeout = 10 * 1000)
+  @Test
   public void testMaxMutationConstraint() throws Exception {
     c.tableOperations().create("test_ingest");
     c.tableOperations().addConstraint("test_ingest", MaxMutationSize.class.getName());
@@ -310,7 +294,7 @@ public class ExamplesIT extends AbstractMacIT {
     }
   }
 
-  @Test(timeout = 60 * 1000)
+  @Test
   public void testBulkIngest() throws Exception {
     goodExec(GenerateTestData.class, "--start-row", "0", "--count", "10000", "--output",
dir + "/tmp/input/data");
     goodExec(SetupTable.class, "-i", instance, "-z", keepers, "-u", user, "-p", passwd, "--table",
"bulkTable");
@@ -318,7 +302,7 @@ public class ExamplesIT extends AbstractMacIT {
         "--workDir", dir + "/tmp");
   }
 
-  @Test(timeout = 2 * 60 * 1000)
+  @Test
   public void testTeraSortAndRead() throws Exception {
     String sorted = "sorted";
     goodExec(TeraSortIngest.class, "--count", (1000 * 1000) + "", "-nk", "10", "-xk", "10",
"-nv", "10", "-xv", "10", "-t", sorted, "-i", instance, "-z",
@@ -328,7 +312,7 @@ public class ExamplesIT extends AbstractMacIT {
     goodExec(TableToFile.class, "-i", instance, "-z", keepers, "-u", user, "-p", passwd,
"-t", sorted, "--output", dir + "/tmp/tableFile");
   }
 
-  @Test(timeout = 30 * 1000)
+  @Test
   public void testWordCount() throws Exception {
     c.tableOperations().create("wordCount");
     is = new IteratorSetting(10, SummingCombiner.class);
@@ -339,29 +323,29 @@ public class ExamplesIT extends AbstractMacIT {
     goodExec(WordCount.class, "-i", instance, "-u", user, "-p", passwd, "-z", keepers, "--input",
dir + "/tmp/wc", "-t", "wordCount");
   }
 
-  @Test(timeout = 30 * 1000)
+  @Test
   public void testInsertWithBatchWriterAndReadData() throws Exception {
     String helloBatch = "helloBatch";
     goodExec(InsertWithBatchWriter.class, "-i", instance, "-z", keepers, "-u", user, "-p",
passwd, "-t", helloBatch);
     goodExec(ReadData.class, "-i", instance, "-z", keepers, "-u", user, "-p", passwd, "-t",
helloBatch);
   }
 
-  @Test(timeout = 5 * 60 * 1000)
+  @Test
   public void testIsolatedScansWithInterference() throws Exception {
     goodExec(InterferenceTest.class, "-i", instance, "-z", keepers, "-u", user, "-p", passwd,
"-t", "itest1", "--iterations", "100000", "--isolated");
   }
 
-  @Test(timeout = 6 * 60 * 1000)
+  @Test
   public void testScansWithInterference() throws Exception {
     goodExec(InterferenceTest.class, "-i", instance, "-z", keepers, "-u", user, "-p", passwd,
"-t", "itest2", "--iterations", "100000");
   }
 
-  @Test(timeout = 20 * 1000)
+  @Test
   public void testRowOperations() throws Exception {
     goodExec(RowOperations.class, "-i", instance, "-z", keepers, "-u", user, "-p", passwd);
   }
 
-  @Test(timeout = 15 * 1000)
+  @Test
   public void testBatchWriter() throws Exception {
     c.tableOperations().create("test");
     goodExec(SequentialBatchWriter.class, "-i", instance, "-z", keepers, "-u", user, "-p",
passwd, "-t", "test", "--start", "0", "--num", "100000", "--size",
@@ -369,7 +353,7 @@ public class ExamplesIT extends AbstractMacIT {
 
   }
 
-  @Test(timeout = 135 * 1000)
+  @Test
   public void testReadWriteAndDelete() throws Exception {
     String test2 = "test2";
     goodExec(ReadWriteExample.class, "-i", instance, "-z", keepers, "-u", user, "-p", passwd,
"--auths", auths, "--table", test2, "--createtable", "-c",
@@ -378,7 +362,7 @@ public class ExamplesIT extends AbstractMacIT {
 
   }
 
-  @Test(timeout = 50 * 1000)
+  @Test
   public void testRandomBatchesAndFlush() throws Exception {
     String test3 = "test3";
     c.tableOperations().create(test3);
@@ -389,17 +373,11 @@ public class ExamplesIT extends AbstractMacIT {
     goodExec(Flush.class, "-i", instance, "-z", keepers, "-u", user, "-p", passwd, "--table",
test3);
   }
 
-  @AfterClass
-  public static void stop() throws Exception {
-    goodExec(Admin.class, "stopAll");
-    cleanUp(cluster);
-  }
-
-  private static Process goodExec(Class<?> theClass, String... args) throws InterruptedException,
IOException {
+  private Process goodExec(Class<?> theClass, String... args) throws InterruptedException,
IOException {
     return expectExec(0, theClass, args);
   }
 
-  private static Process expectExec(int exitCode, Class<?> theClass, String... args)
throws InterruptedException, IOException {
+  private Process expectExec(int exitCode, Class<?> theClass, String... args) throws
InterruptedException, IOException {
     Process p = null;
     assertEquals(exitCode, (p = cluster.exec(theClass, Collections.singletonList(MapReduceIT.hadoopTmpDirArg),
args)).waitFor());
     return p;


Mime
View raw message