Tests: Remove unnecessary Callable variant of assertBusy
The assertBusy method currently has both a Runnable and Callable version. This has caused confusion with type inference and lambdas sometimes, in particular with java 9. This change removes the callable version as nothing was actually using it.
This commit is contained in:
parent
ef435d0099
commit
c7b45b2cc7
|
@ -137,7 +137,7 @@ public class CancelTests extends ReindexTestCase {
|
|||
ALLOWED_OPERATIONS.release(BLOCKING_OPERATIONS);
|
||||
|
||||
// Checks that no more operations are executed
|
||||
assertBusy(() -> ALLOWED_OPERATIONS.availablePermits() == 0 && ALLOWED_OPERATIONS.getQueueLength() == 0);
|
||||
assertBusy(() -> assertTrue(ALLOWED_OPERATIONS.availablePermits() == 0 && ALLOWED_OPERATIONS.getQueueLength() == 0));
|
||||
|
||||
// And check the status of the response
|
||||
BulkIndexByScrollResponse response = future.get();
|
||||
|
|
|
@ -443,24 +443,13 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
* Runs the code block for 10 seconds waiting for no assertion to trip.
|
||||
*/
|
||||
public static void assertBusy(Runnable codeBlock) throws Exception {
|
||||
assertBusy(Executors.callable(codeBlock), 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public static void assertBusy(Runnable codeBlock, long maxWaitTime, TimeUnit unit) throws Exception {
|
||||
assertBusy(Executors.callable(codeBlock), maxWaitTime, unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the code block for 10 seconds waiting for no assertion to trip.
|
||||
*/
|
||||
public static <V> V assertBusy(Callable<V> codeBlock) throws Exception {
|
||||
return assertBusy(codeBlock, 10, TimeUnit.SECONDS);
|
||||
assertBusy(codeBlock, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the code block for the provided interval, waiting for no assertions to trip.
|
||||
*/
|
||||
public static <V> V assertBusy(Callable<V> codeBlock, long maxWaitTime, TimeUnit unit) throws Exception {
|
||||
public static void assertBusy(Runnable codeBlock, long maxWaitTime, TimeUnit unit) throws Exception {
|
||||
long maxTimeInMillis = TimeUnit.MILLISECONDS.convert(maxWaitTime, unit);
|
||||
long iterations = Math.max(Math.round(Math.log10(maxTimeInMillis) / Math.log10(2)), 1);
|
||||
long timeInMillis = 1;
|
||||
|
@ -468,7 +457,8 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
List<AssertionError> failures = new ArrayList<>();
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
try {
|
||||
return codeBlock.call();
|
||||
codeBlock.run();
|
||||
return;
|
||||
} catch (AssertionError e) {
|
||||
failures.add(e);
|
||||
}
|
||||
|
@ -479,7 +469,7 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
timeInMillis = maxTimeInMillis - sum;
|
||||
Thread.sleep(Math.max(timeInMillis, 0));
|
||||
try {
|
||||
return codeBlock.call();
|
||||
codeBlock.run();
|
||||
} catch (AssertionError e) {
|
||||
for (AssertionError failure : failures) {
|
||||
e.addSuppressed(failure);
|
||||
|
|
Loading…
Reference in New Issue