Repository: nifi
Updated Branches:
  refs/heads/0.x 0a681977a -> f8e655548


NIFI-1872: Allow for adequate time for embedded zookeeper server to startup for 
unit tests


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

Branch: refs/heads/0.x
Commit: f8e65554863b8009bb097a630678af0461276104
Parents: 0a68197
Author: Mark Payne <[email protected]>
Authored: Fri May 13 14:03:50 2016 -0400
Committer: Mark Payne <[email protected]>
Committed: Fri May 13 14:03:50 2016 -0400

----------------------------------------------------------------------
 .../zookeeper/TestZooKeeperStateProvider.java   | 27 +++++++++++++-------
 1 file changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/f8e65554/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/zookeeper/TestZooKeeperStateProvider.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/zookeeper/TestZooKeeperStateProvider.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/zookeeper/TestZooKeeperStateProvider.java
index 060302c..3542a09 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/zookeeper/TestZooKeeperStateProvider.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/zookeeper/TestZooKeeperStateProvider.java
@@ -205,8 +205,7 @@ public class TestZooKeeperStateProvider extends 
AbstractTestStateProvider {
     }
 
     @Test
-    @Ignore("Needs to be fixed as it intermittently fails.")
-    public void testStateTooLargeExceptionThrown() {
+    public void testStateTooLargeExceptionThrown() throws InterruptedException 
{
         final Map<String, String> state = new HashMap<>();
         final StringBuilder sb = new StringBuilder();
 
@@ -220,13 +219,23 @@ public class TestZooKeeperStateProvider extends 
AbstractTestStateProvider {
             state.put("numbers." + i, sb.toString());
         }
 
-        try {
-            getProvider().setState(state, componentId);
-            Assert.fail("Expected StateTooLargeException");
-        } catch (final StateTooLargeException stle) {
-            // expected behavior.
-        } catch (final Exception e) {
-            Assert.fail("Expected StateTooLargeException but " + e.getClass() 
+ " was thrown", e);
+        while (true) {
+            try {
+                getProvider().setState(state, componentId);
+                Assert.fail("Expected StateTooLargeException");
+            } catch (final StateTooLargeException stle) {
+                // expected behavior.
+                break;
+            } catch (final IOException ioe) {
+                // If we attempt to interact with the server too quickly, we 
will get a
+                // ZooKeeper ConnectionLoss Exception, which the provider 
wraps in an IOException.
+                // We will wait 1 second in this case and try again. The test 
will timeout if this
+                // does not succeeed within 20 seconds.
+                Thread.sleep(1000L);
+            } catch (final Exception e) {
+                e.printStackTrace();
+                Assert.fail("Expected StateTooLargeException but " + 
e.getClass() + " was thrown", e);
+            }
         }
 
         try {

Reply via email to