bereng commented on code in PR #2896:
URL: https://github.com/apache/cassandra/pull/2896#discussion_r1448529904
##########
test/distributed/org/apache/cassandra/distributed/test/CasWriteTest.java:
##########
@@ -253,32 +263,42 @@ public void testWriteUnknownResult()
cluster.filters().reset();
int pk = pkGen.getAndIncrement();
CountDownLatch ready = new CountDownLatch(1);
- cluster.filters().verbs(Verb.PAXOS_PROPOSE_REQ.id).from(1).to(2,
3).messagesMatching((from, to, msg) -> {
+ final IMessageFilters.Matcher matcher = (from, to, msg) -> {
if (to == 2)
{
// Inject a single CAS request in-between prepare and propose
phases
cluster.coordinator(2).execute(mkCasInsertQuery((a) -> pk, 1,
2),
ConsistencyLevel.QUORUM);
ready.countDown();
- } else {
+ }
+ else
+ {
Uninterruptibles.awaitUninterruptibly(ready);
}
return false;
- }).drop();
+ };
+ cluster.filters().verbs(Verb.PAXOS_PROPOSE_REQ.id).from(1).to(2,
3).messagesMatching(matcher).drop();
+ cluster.filters().verbs(Verb.PAXOS2_PROPOSE_REQ.id).from(1).to(2,
3).messagesMatching(matcher).drop();
try
{
cluster.coordinator(1).execute(mkCasInsertQuery((a) -> pk, 1, 1),
ConsistencyLevel.QUORUM);
}
catch (Throwable t)
{
- Assert.assertEquals("Expecting cause to be
CasWriteUnknownResultException",
-
CasWriteUnknownResultException.class.getCanonicalName(),
t.getClass().getCanonicalName());
+ final Class<?> exceptionClass = isPaxosVariant2() ?
CasWriteTimeoutException.class : CasWriteUnknownResultException.class;
+ Assert.assertEquals("Expecting cause to be " +
exceptionClass.getSimpleName(),
+ exceptionClass.getCanonicalName(),
t.getClass().getCanonicalName());
return;
}
Assert.fail("Expecting test to throw a
CasWriteUnknownResultException");
}
+ private static boolean isPaxosVariant2()
+ {
+ return
"v2".equals(cluster.coordinator(1).instance().config().getString("paxos_variant"));
Review Comment:
Could have used `PaxosVariant.v2` enum instead of a harcoded value?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]