From 18356de83738d64e619898016d873993ec474d17 Mon Sep 17 00:00:00 2001 From: markrmiller Date: Sun, 9 Dec 2018 22:42:40 -0600 Subject: [PATCH] SOLR-12923: Harden TestSimTriggerIntegration. --- .../autoscaling/sim/SimDistribStateManager.java | 11 +++++++---- .../autoscaling/sim/TestSimTriggerIntegration.java | 12 ++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimDistribStateManager.java b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimDistribStateManager.java index 2b8940a7b78..7b730389038 100644 --- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimDistribStateManager.java +++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimDistribStateManager.java @@ -476,23 +476,26 @@ public class SimDistribStateManager implements DistribStateManager { @Override public void removeData(String path, int version) throws NoSuchElementException, NotEmptyException, BadVersionException, IOException { multiLock.lock(); + Node parent; + Node n; try { - Node n = traverse(path, false, CreateMode.PERSISTENT); + n = traverse(path, false, CreateMode.PERSISTENT); if (n == null) { throw new NoSuchElementException(path); } - Node parent = n.parent; + parent = n.parent; if (parent == null) { throw new IOException("Cannot remove root node"); } if (!n.children.isEmpty()) { throw new NotEmptyException(path); } - parent.removeChild(n.name, version); } finally { multiLock.unlock(); } - + + // outside the lock to avoid deadlock with update lock + parent.removeChild(n.name, version); } @Override diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimTriggerIntegration.java b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimTriggerIntegration.java index 8f37ddb391e..c4ec12227e8 100644 --- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimTriggerIntegration.java +++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimTriggerIntegration.java @@ -210,7 +210,7 @@ public class TestSimTriggerIntegration extends SimSolrCloudTestCase { String newNode = cluster.simAddNode(); - if (!triggerFiredLatch.await(45000 / SPEED, TimeUnit.MILLISECONDS)) { + if (!triggerFiredLatch.await(220000 / SPEED, TimeUnit.MILLISECONDS)) { fail("Both triggers should have fired by now"); } @@ -350,7 +350,7 @@ public class TestSimTriggerIntegration extends SimSolrCloudTestCase { fail("Two TriggerAction instances should have been created by now"); } - boolean await = triggerFiredLatch.await(45000 / SPEED, TimeUnit.MILLISECONDS); + boolean await = triggerFiredLatch.await(90000 / SPEED, TimeUnit.MILLISECONDS); assertTrue("The trigger did not fire at all", await); assertTrue(triggerFired.get()); NodeLostTrigger.NodeLostEvent nodeLostEvent = (NodeLostTrigger.NodeLostEvent) events.iterator().next(); @@ -408,7 +408,7 @@ public class TestSimTriggerIntegration extends SimSolrCloudTestCase { fail("Two TriggerAction instances should have been created by now"); } - boolean await = triggerFiredLatch.await(20000 / SPEED, TimeUnit.MILLISECONDS); + boolean await = triggerFiredLatch.await(60000 / SPEED, TimeUnit.MILLISECONDS); assertTrue("The trigger did not fire at all", await); assertTrue(triggerFired.get()); TriggerEvent nodeAddedEvent = events.iterator().next(); @@ -438,7 +438,7 @@ public class TestSimTriggerIntegration extends SimSolrCloudTestCase { } String newNode = cluster.simAddNode(); - boolean await = triggerFiredLatch.await(45000 / SPEED, TimeUnit.MILLISECONDS); + boolean await = triggerFiredLatch.await(60000 / SPEED, TimeUnit.MILLISECONDS); assertTrue("The trigger did not fire at all", await); assertTrue(triggerFired.get()); TriggerEvent nodeAddedEvent = events.iterator().next(); @@ -726,7 +726,7 @@ public class TestSimTriggerIntegration extends SimSolrCloudTestCase { events.clear(); String newNode = cluster.simAddNode(); - boolean await = triggerFiredLatch.await(60000 / SPEED, TimeUnit.MILLISECONDS); + boolean await = triggerFiredLatch.await(90000 / SPEED, TimeUnit.MILLISECONDS); assertTrue("The trigger did not fire at all", await); assertTrue(triggerFired.get()); // reset @@ -924,7 +924,7 @@ public class TestSimTriggerIntegration extends SimSolrCloudTestCase { } - if (!triggerFiredLatch.await(30000 / SPEED, TimeUnit.MILLISECONDS)) { + if (!triggerFiredLatch.await(60000 / SPEED, TimeUnit.MILLISECONDS)) { fail("Trigger should have fired by now"); } assertEquals(1, events.size());