accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject git commit: ACCUMULO-1833 Account for race condition in test where mutations are flushed immediately.
Date Mon, 18 Nov 2013 23:09:52 GMT
Updated Branches:
  refs/heads/1.5.1-SNAPSHOT 60dd8bd73 -> 404e955ec


ACCUMULO-1833 Account for race condition in test where mutations are flushed immediately.


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

Branch: refs/heads/1.5.1-SNAPSHOT
Commit: 404e955ece6b85bd77e3afc5c641b8eb823d547b
Parents: 60dd8bd
Author: Josh Elser <elserj@apache.org>
Authored: Mon Nov 18 17:42:18 2013 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Mon Nov 18 17:44:32 2013 -0500

----------------------------------------------------------------------
 .../test/MultiTableBatchWriterTest.java         | 50 ++++++++++++++++----
 1 file changed, 40 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/404e955e/test/src/test/java/org/apache/accumulo/test/MultiTableBatchWriterTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/MultiTableBatchWriterTest.java b/test/src/test/java/org/apache/accumulo/test/MultiTableBatchWriterTest.java
index c5290e4..9ee1e6e 100644
--- a/test/src/test/java/org/apache/accumulo/test/MultiTableBatchWriterTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/MultiTableBatchWriterTest.java
@@ -340,7 +340,8 @@ public class MultiTableBatchWriterTest {
 
     TCredentials creds = CredentialHelper.create("root", password, instance.getInstanceID());
     MultiTableBatchWriter mtbw = new MultiTableBatchWriterImpl(instance, creds, config, 60,
TimeUnit.SECONDS);
-
+    boolean mutationsRejected = false;
+    
     try {
       final String table1 = "testTableDelete_table1", table2 = "testTableDelete_table2";
 
@@ -364,19 +365,27 @@ public class MultiTableBatchWriterTest {
       m2.put("col1", "", "val1");
       m2.put("col2", "", "val2");
 
-      bw1.addMutation(m2);
-      bw2.addMutation(m2);
+      try {
+        bw1.addMutation(m2);
+        bw2.addMutation(m2);
+      } catch (MutationsRejectedException e) {
+        // Pass - Mutations might flush immediately
+        mutationsRejected = true;
+      }
 
     } finally {
       if (null != mtbw) {
         try {
+          // Mutations might have flushed before the table offline occurred
           mtbw.close();
-          Assert.fail("Should not be able to close batch writers");
         } catch (MutationsRejectedException e) {
           // Pass
+          mutationsRejected = true;
         }
       }
     }
+    
+    Assert.assertTrue("Expected mutations to be rejected.", mutationsRejected);
   }
 
   @Test
@@ -389,6 +398,7 @@ public class MultiTableBatchWriterTest {
 
     TCredentials creds = CredentialHelper.create("root", password, instance.getInstanceID());
     MultiTableBatchWriter mtbw = new MultiTableBatchWriterImpl(instance, creds, config, 60,
TimeUnit.SECONDS);
+    boolean mutationsRejected = false;
 
     try {
       final String table1 = "testOfflineTable_table1", table2 = "testOfflineTable_table2";
@@ -413,19 +423,26 @@ public class MultiTableBatchWriterTest {
       m2.put("col1", "", "val1");
       m2.put("col2", "", "val2");
 
-      bw1.addMutation(m2);
-      bw2.addMutation(m2);
+      try {
+        bw1.addMutation(m2);
+        bw2.addMutation(m2);
+      } catch (MutationsRejectedException e) {
+        // Pass -- Mutations might flush immediately and fail because of offline table
+        mutationsRejected = true;
+      }
     } finally {
       if (null != mtbw) {
         try {
+          // Mutations might have flushed before the table offline occurred
           mtbw.close();
-          Assert.fail("Should not be able to close batch writers");
         } catch (MutationsRejectedException e) {
           // Pass
+          mutationsRejected = true;
         }
       }
-
     }
+    
+    Assert.assertTrue("Expected mutations to be rejected.", mutationsRejected);
   }
 
   @Test
@@ -438,6 +455,7 @@ public class MultiTableBatchWriterTest {
     
     TCredentials creds = CredentialHelper.create("root", password, instance.getInstanceID());
     MultiTableBatchWriter mtbw = new MultiTableBatchWriterImpl(instance, creds, config, 60,
TimeUnit.SECONDS);
+    boolean mutationsRejected = false;
 
     try {
       final String table1 = "testOfflineTableWithCache_table1", table2 = "testOfflineTableWithCache_table2";
@@ -461,6 +479,7 @@ public class MultiTableBatchWriterTest {
         bw1 = mtbw.getBatchWriter(table1);
       } catch (TableOfflineException e) {
         // pass
+        mutationsRejected = true;
       }
 
       tops.offline(table2);
@@ -469,17 +488,21 @@ public class MultiTableBatchWriterTest {
         bw2 = mtbw.getBatchWriter(table2);
       } catch (TableOfflineException e) {
         // pass
+        mutationsRejected = true;
       }
     } finally {
       if (null != mtbw) {
         try {
+          // Mutations might have flushed before the table offline occurred
           mtbw.close();
-          Assert.fail("Expecting close on MTBW to fail due to offline tables");
         } catch (MutationsRejectedException e) {
           // Pass
+          mutationsRejected = true;
         }
       }
     }
+
+    Assert.assertTrue("Expected mutations to be rejected.", mutationsRejected);
   }
 
   @Test
@@ -492,6 +515,7 @@ public class MultiTableBatchWriterTest {
 
     TCredentials creds = CredentialHelper.create("root", password, instance.getInstanceID());
     MultiTableBatchWriter mtbw = new MultiTableBatchWriterImpl(instance, creds, config, 0,
TimeUnit.SECONDS);
+    boolean mutationsRejected = false;
 
     try {
       final String table1 = "testOfflineTableWithoutCache_table1", table2 = "testOfflineTableWithoutCache_table2";
@@ -509,6 +533,7 @@ public class MultiTableBatchWriterTest {
       bw1.addMutation(m1);
       bw2.addMutation(m1);
 
+      // Mutations might or might not flush before tables goes offline
       tops.offline(table1);
       tops.offline(table2);
 
@@ -517,6 +542,7 @@ public class MultiTableBatchWriterTest {
         Assert.fail(table1 + " should be offline");
       } catch (TableOfflineException e) {
         // pass
+        mutationsRejected = true;
       }
 
       try {
@@ -524,16 +550,20 @@ public class MultiTableBatchWriterTest {
         Assert.fail(table1 + " should be offline");
       } catch (TableOfflineException e) {
         // pass
+        mutationsRejected = true;
       }
     } finally {
       if (null != mtbw) {
         try {
+          // Mutations might have flushed before the table offline occurred
           mtbw.close();
-          Assert.fail("Expecting close on MTBW to fail due to offline tables");
         } catch (MutationsRejectedException e) {
           // Pass
+          mutationsRejected = true;
         }
       }
     }
+
+    Assert.assertTrue("Expected mutations to be rejected.", mutationsRejected);
   }
 }


Mime
View raw message