SOLR-10602: Fix usage of delta in NodeAddTriggerTest.testRestoreState to avoid spurious failures

This commit is contained in:
Shalin Shekhar Mangar 2017-06-26 09:01:02 +05:30
parent 1dd09fc40d
commit 82d927f699
1 changed files with 1 additions and 6 deletions

View File

@ -232,8 +232,6 @@ public class NodeAddedTriggerTest extends SolrCloudTestCase {
// add a new node but update the trigger before the waitFor period expires
// and assert that the new trigger still fires
NodeAddedTrigger trigger = new NodeAddedTrigger("node_added_trigger", props, container);
final long waitTime = 2;
props.put("waitFor", waitTime);
trigger.setListener(noFirstRunListener);
trigger.run();
@ -258,13 +256,10 @@ public class NodeAddedTriggerTest extends SolrCloudTestCase {
eventRef.set(event);
long currentTimeNanos = timeSource.getTime();
long eventTimeNanos = event.getEventTime();
long waitForNanos = TimeUnit.NANOSECONDS.convert(waitTime, TimeUnit.SECONDS) + WAIT_FOR_DELTA_NANOS;
long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS) - WAIT_FOR_DELTA_NANOS;
if (currentTimeNanos - eventTimeNanos <= waitForNanos) {
fail("NodeAddedListener was fired before the configured waitFor period: currentTimeNanos=" + currentTimeNanos + ", eventTimeNanos=" + eventTimeNanos + ",waitForNanos=" + waitForNanos);
}
if (timeSource.getTime() - event.getEventTime() <= TimeUnit.NANOSECONDS.convert(waitTime, TimeUnit.SECONDS)) {
fail("NodeAddedListener was fired before the configured waitFor period");
}
} else {
fail("NodeAddedTrigger was fired more than once!");
}