accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwa...@apache.org
Subject [accumulo] branch master updated: Simplify CreateInitialSplitsIT (#983)
Date Sat, 23 Feb 2019 18:23:47 GMT
This is an automated email from the ASF dual-hosted git repository.

mwalch 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 d57a444  Simplify CreateInitialSplitsIT (#983)
d57a444 is described below

commit d57a444da6def25d64f5bc90ea80e65b8fc82b1e
Author: Mike Walch <mwalch@apache.org>
AuthorDate: Sat Feb 23 13:23:43 2019 -0500

    Simplify CreateInitialSplitsIT (#983)
    
    * Reduce duplicate code
---
 .../test/functional/CreateInitialSplitsIT.java     | 52 +++++++---------------
 1 file changed, 16 insertions(+), 36 deletions(-)

diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CreateInitialSplitsIT.java
b/test/src/main/java/org/apache/accumulo/test/functional/CreateInitialSplitsIT.java
index 6ea1b44..3522151 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CreateInitialSplitsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CreateInitialSplitsIT.java
@@ -86,6 +86,16 @@ public class CreateInitialSplitsIT extends AccumuloClusterHarness {
     assertTrue(client.tableOperations().exists(tableName));
   }
 
+  private void runTest(SortedSet<Text> expectedSplits) throws AccumuloSecurityException,
+      TableNotFoundException, AccumuloException, TableExistsException {
+    NewTableConfiguration ntc = new NewTableConfiguration().withSplits(expectedSplits);
+    assertFalse(client.tableOperations().exists(tableName));
+    client.tableOperations().create(tableName, ntc);
+    assertTrue(client.tableOperations().exists(tableName));
+    Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
+    assertEquals(expectedSplits, new TreeSet<>(createdSplits));
+  }
+
   /**
    * Create initial splits by providing splits from a Java Collection.
    */
@@ -93,26 +103,14 @@ public class CreateInitialSplitsIT extends AccumuloClusterHarness {
   public void testCreateInitialSplits() throws TableExistsException, AccumuloSecurityException,
       AccumuloException, TableNotFoundException {
     tableName = getUniqueNames(1)[0];
-    SortedSet<Text> expectedSplits = generateNonBinarySplits(3000, 32);
-    NewTableConfiguration ntc = new NewTableConfiguration().withSplits(expectedSplits);
-    assertFalse(client.tableOperations().exists(tableName));
-    client.tableOperations().create(tableName, ntc);
-    assertTrue(client.tableOperations().exists(tableName));
-    Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
-    assertEquals(expectedSplits, new TreeSet<>(createdSplits));
+    runTest(generateNonBinarySplits(3000, 32));
   }
 
   @Test
   public void testCreateInitialSplitsWithEncodedSplits() throws TableExistsException,
       AccumuloSecurityException, AccumuloException, TableNotFoundException {
     tableName = getUniqueNames(1)[0];
-    SortedSet<Text> expectedSplits = generateNonBinarySplits(3000, 32, true);
-    NewTableConfiguration ntc = new NewTableConfiguration().withSplits(expectedSplits);
-    assertFalse(client.tableOperations().exists(tableName));
-    client.tableOperations().create(tableName, ntc);
-    assertTrue(client.tableOperations().exists(tableName));
-    Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
-    assertEquals(expectedSplits, new TreeSet<>(createdSplits));
+    runTest(generateNonBinarySplits(3000, 32, true));
   }
 
   /**
@@ -122,26 +120,14 @@ public class CreateInitialSplitsIT extends AccumuloClusterHarness {
   public void testCreateInitialBinarySplits() throws TableExistsException,
       AccumuloSecurityException, AccumuloException, TableNotFoundException {
     tableName = getUniqueNames(1)[0];
-    SortedSet<Text> expectedSplits = generateBinarySplits(1000, 16);
-    NewTableConfiguration ntc = new NewTableConfiguration().withSplits(expectedSplits);
-    assertFalse(client.tableOperations().exists(tableName));
-    client.tableOperations().create(tableName, ntc);
-    assertTrue(client.tableOperations().exists(tableName));
-    Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
-    assertEquals(expectedSplits, new TreeSet<>(createdSplits));
+    runTest(generateBinarySplits(1000, 16));
   }
 
   @Test
   public void testCreateInitialBinarySplitsWithEncodedSplits() throws TableExistsException,
       AccumuloSecurityException, AccumuloException, TableNotFoundException {
     tableName = getUniqueNames(1)[0];
-    SortedSet<Text> expectedSplits = generateBinarySplits(1000, 16, true);
-    NewTableConfiguration ntc = new NewTableConfiguration().withSplits(expectedSplits);
-    assertFalse(client.tableOperations().exists(tableName));
-    client.tableOperations().create(tableName, ntc);
-    assertTrue(client.tableOperations().exists(tableName));
-    Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
-    assertEquals(expectedSplits, new TreeSet<>(createdSplits));
+    runTest(generateBinarySplits(1000, 16, true));
   }
 
   /**
@@ -184,18 +170,12 @@ public class CreateInitialSplitsIT extends AccumuloClusterHarness {
     // Write data to mulitple tablets
     tableName = getUniqueNames(1)[0];
     SortedSet<Text> expectedSplits = generateNonBinarySplits(1000, 32);
-    NewTableConfiguration ntc = new NewTableConfiguration().withSplits(expectedSplits);
-    assertFalse(client.tableOperations().exists(tableName));
-    client.tableOperations().create(tableName, ntc);
-    assertTrue(client.tableOperations().exists(tableName));
-    // verify data
-    Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
-    assertEquals(expectedSplits, new TreeSet<>(createdSplits));
+    runTest(expectedSplits);
     client.tableOperations().flush(tableName);
     // compact data
     client.tableOperations().compact(tableName, null, null, true, true);
     // verify data
-    createdSplits = client.tableOperations().listSplits(tableName);
+    Collection<Text> createdSplits = client.tableOperations().listSplits(tableName);
     assertEquals(expectedSplits, new TreeSet<>(createdSplits));
     // delete table
     client.tableOperations().delete(tableName);


Mime
View raw message