Skip to content

Commit

Permalink
Bound Linearizability Check in CoordinatorTests (elastic#48751) (elas…
Browse files Browse the repository at this point in the history
…tic#48853)

Same as elastic#44444 but for the coordinator tests.
Closes elastic#48742
  • Loading branch information
original-brownbear authored Nov 4, 2019
1 parent c85cf7a commit d83e374
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.disruption.DisruptableMockTransport;
import org.elasticsearch.test.disruption.DisruptableMockTransport.ConnectionStatus;
import org.elasticsearch.threadpool.Scheduler;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportInterceptor;
import org.elasticsearch.transport.TransportService;
Expand All @@ -90,6 +91,9 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
Expand Down Expand Up @@ -561,7 +565,21 @@ void stabilise(long stabilisationDurationMillis) {
leader.improveConfiguration(lastAcceptedState), sameInstance(lastAcceptedState));

logger.info("checking linearizability of history with size {}: {}", history.size(), history);
assertTrue("history not linearizable: " + history, linearizabilityChecker.isLinearizable(spec, history, i -> null));
final AtomicBoolean abort = new AtomicBoolean();
// Large histories can be problematic and have the linearizability checker run OOM
// Bound the time how long the checker can run on such histories (Values empirically determined)
final ScheduledThreadPoolExecutor scheduler = Scheduler.initScheduler(Settings.EMPTY);
try {
if (history.size() > 300) {
scheduler.schedule(() -> abort.set(true), 10, TimeUnit.SECONDS);
}
final boolean linearizable = linearizabilityChecker.isLinearizable(spec, history, i -> null, abort::get);
if (abort.get() == false) {
assertTrue("history not linearizable: " + history, linearizable);
}
} finally {
ThreadPool.terminate(scheduler, 1, TimeUnit.SECONDS);
}
logger.info("linearizability check completed");
}

Expand Down

0 comments on commit d83e374

Please sign in to comment.