mirror of https://github.com/apache/cassandra
Fix flakey test org.apache.cassandra.simulator.test.ShortPaxosSimulationTest#casOnAccordSimulationTest
patch by David Capwell; reviewed by Ariel Weisberg for CASSANDRA-20322
This commit is contained in:
parent
b81d13f994
commit
3fb23e0247
|
|
@ -19,11 +19,9 @@
|
|||
package org.apache.cassandra.simulator.paxos;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.LongSupplier;
|
||||
|
|
@ -35,8 +33,6 @@ import javax.annotation.Nullable;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import accord.coordinate.CoordinationFailed;
|
||||
import accord.coordinate.Invalidated;
|
||||
import com.carrotsearch.hppc.IntArrayList;
|
||||
import com.carrotsearch.hppc.IntHashSet;
|
||||
import com.carrotsearch.hppc.cursors.IntCursor;
|
||||
|
|
@ -52,7 +48,6 @@ import org.apache.cassandra.distributed.api.IInvokableInstance;
|
|||
import org.apache.cassandra.distributed.api.QueryResults;
|
||||
import org.apache.cassandra.distributed.api.SimpleQueryResult;
|
||||
import org.apache.cassandra.distributed.impl.Query;
|
||||
import org.apache.cassandra.exceptions.RequestExecutionException;
|
||||
import org.apache.cassandra.schema.ColumnMetadata;
|
||||
import org.apache.cassandra.schema.TableMetadata;
|
||||
import org.apache.cassandra.service.consensus.TransactionalMode;
|
||||
|
|
@ -62,7 +57,6 @@ import org.apache.cassandra.simulator.RunnableActionScheduler;
|
|||
import org.apache.cassandra.simulator.cluster.ClusterActions;
|
||||
import org.apache.cassandra.simulator.systems.SimulatedSystems;
|
||||
import org.apache.cassandra.simulator.utils.IntRange;
|
||||
import org.apache.cassandra.streaming.StreamReceivedOutOfTokenRangeException;
|
||||
|
||||
import static org.apache.cassandra.simulator.paxos.HistoryChecker.fail;
|
||||
|
||||
|
|
@ -159,13 +153,7 @@ public class PairOfSequencesAccordSimulation extends AbstractPairOfSequencesPaxo
|
|||
@Override
|
||||
protected Class<? extends Throwable>[] expectedExceptions()
|
||||
{
|
||||
return (Class<? extends Throwable>[]) new Class<?>[] { CancellationException.class,
|
||||
CoordinationFailed.class,
|
||||
ClosedChannelException.class,
|
||||
Invalidated.class,
|
||||
RequestExecutionException.class,
|
||||
StreamReceivedOutOfTokenRangeException.class // should always come in combination with closed channel exception
|
||||
};
|
||||
return expectedExceptionsAccord();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -280,6 +280,20 @@ public class PairOfSequencesPaxosSimulation extends AbstractPairOfSequencesPaxos
|
|||
return new ModifyingOperation(operationId, instance, ANY, serialConsistency, primaryKey, historyChecker);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends Throwable>[] expectedExceptions()
|
||||
{
|
||||
return maybeAccord() ? expectedExceptionsAccord() : expectedExceptionsPaxos();
|
||||
}
|
||||
|
||||
private boolean maybeAccord()
|
||||
{
|
||||
// at startup are we accord?
|
||||
if (transactionalMode != null && transactionalMode.accordIsEnabled) return true;
|
||||
// do we migrate to accord?
|
||||
return clusterOptions.consensusChangeLimit > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
void log(@Nullable Integer primaryKey)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.cassandra.simulator.paxos;
|
||||
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
|
@ -37,7 +38,7 @@ import com.google.common.base.Throwables;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import accord.coordinate.Invalidated;
|
||||
import accord.coordinate.CoordinationFailed;
|
||||
import org.apache.cassandra.concurrent.ExecutorFactory;
|
||||
import org.apache.cassandra.concurrent.ScheduledExecutorPlus;
|
||||
import org.apache.cassandra.distributed.Cluster;
|
||||
|
|
@ -55,6 +56,7 @@ import org.apache.cassandra.simulator.cluster.ClusterActionListener;
|
|||
import org.apache.cassandra.simulator.systems.InterceptorOfGlobalMethods;
|
||||
import org.apache.cassandra.simulator.systems.SimulatedActionCallable;
|
||||
import org.apache.cassandra.simulator.systems.SimulatedSystems;
|
||||
import org.apache.cassandra.streaming.StreamReceivedOutOfTokenRangeException;
|
||||
import org.apache.cassandra.utils.AssertionUtils;
|
||||
import org.apache.cassandra.utils.CloseableIterator;
|
||||
import org.apache.cassandra.utils.concurrent.Threads;
|
||||
|
|
@ -74,17 +76,29 @@ public abstract class PaxosSimulation implements Simulation, ClusterActionListen
|
|||
|
||||
private static String createDescription(int[] primaryKeys, int id, String idString)
|
||||
{
|
||||
return (primaryKeys.length == 1 ? Integer.toString(primaryKeys[0]) : Arrays.toString(primaryKeys)) + "/" + id + ": " + idString;
|
||||
return (primaryKeys.length == 1 ? Integer.toString(primaryKeys[0]) : Arrays.toString(primaryKeys)) + '/' + id + ": " + idString;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Class<? extends Throwable>[] expectedExceptions()
|
||||
protected Class<? extends Throwable>[] expectedExceptionsPaxos()
|
||||
{
|
||||
return (Class<? extends Throwable>[]) new Class<?>[] { RequestExecutionException.class,
|
||||
Invalidated.class,
|
||||
CancellationException.class };
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Class<? extends Throwable>[] expectedExceptionsAccord()
|
||||
{
|
||||
return (Class<? extends Throwable>[]) new Class<?>[] { RequestExecutionException.class,
|
||||
CancellationException.class,
|
||||
CoordinationFailed.class,
|
||||
ClosedChannelException.class,
|
||||
StreamReceivedOutOfTokenRangeException.class // should always come in combination with closed channel exception
|
||||
};
|
||||
}
|
||||
|
||||
protected abstract Class<? extends Throwable>[] expectedExceptions();
|
||||
|
||||
abstract class Operation extends SimulatedActionCallable<SimpleQueryResult> implements BiConsumer<SimpleQueryResult, Throwable>
|
||||
{
|
||||
final int[] primaryKeys;
|
||||
|
|
|
|||
Loading…
Reference in New Issue