Skip to content

Commit 35dc006

Browse files
committed
got in-sync with trunk
1 parent 32aa970 commit 35dc006

13 files changed

+195
-76
lines changed

test/distributed/org/apache/cassandra/distributed/test/JavaDriverUtils.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ private JavaDriverUtils()
3636
{
3737
}
3838

39+
public static com.datastax.driver.core.Cluster create(ICluster<? extends IInstance> dtest, Consumer<com.datastax.driver.core.Cluster.Builder> overrideBuilder)
40+
{
41+
return create(dtest, null, overrideBuilder);
42+
}
43+
3944
public static com.datastax.driver.core.Cluster create(ICluster<? extends IInstance> dtest)
4045
{
4146
return create(dtest, null, null);
@@ -94,8 +99,10 @@ public static ConsistencyLevel toDriverCL(org.apache.cassandra.distributed.api.C
9499
case EACH_QUORUM: return ConsistencyLevel.EACH_QUORUM;
95100
case ANY: return ConsistencyLevel.ANY;
96101
case ALL: return ConsistencyLevel.ALL;
102+
case NODE_LOCAL:
103+
throw new AssertionError("NODE_LOCAL is not supported by driver and should go directly through jvm-dtest api");
97104
default:
98-
throw new UnsupportedOperationException(cl.name());
105+
throw new UnsupportedOperationException("Unknown ConsistencyLevel: " + cl);
99106
}
100107
}
101108
}

test/distributed/org/apache/cassandra/distributed/test/cql3/AccordInteropMultiNodeTableWalkBase.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package org.apache.cassandra.distributed.test.cql3;
2020

21-
import accord.utils.Property;
2221
import accord.utils.RandomSource;
2322
import org.apache.cassandra.distributed.Cluster;
2423
import org.apache.cassandra.distributed.api.ConsistencyLevel;
@@ -32,13 +31,6 @@ public AccordInteropMultiNodeTableWalkBase(TransactionalMode transactionalMode)
3231
super(transactionalMode);
3332
}
3433

35-
@Override
36-
protected void preCheck(Property.StatefulBuilder builder)
37-
{
38-
// if a failing seed is detected, populate here
39-
// Example: builder.withSeed(42L);
40-
}
41-
4234
@Override
4335
protected State createState(RandomSource rs, Cluster cluster)
4436
{

test/distributed/org/apache/cassandra/distributed/test/cql3/AccordInteropSingleNodeTableWalkBase.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.apache.cassandra.distributed.test.cql3;
2020

21+
import accord.utils.Property;
2122
import accord.utils.RandomSource;
2223
import org.apache.cassandra.distributed.Cluster;
2324
import org.apache.cassandra.distributed.api.ConsistencyLevel;
@@ -30,6 +31,15 @@ public AccordInteropSingleNodeTableWalkBase(TransactionalMode transactionalMode)
3031
super(transactionalMode);
3132
}
3233

34+
@Override
35+
protected void preCheck(Cluster cluster, Property.StatefulBuilder builder)
36+
{
37+
// if a failing seed is detected, populate here
38+
// Example: builder.withSeed(42L);
39+
// CQL operations may have opertors such as +, -, and / (example 4 + 4), to "apply" them to get a constant value
40+
// CQL_DEBUG_APPLY_OPERATOR = true;
41+
}
42+
3343
@Override
3444
protected State createState(RandomSource rs, Cluster cluster)
3545
{

test/distributed/org/apache/cassandra/distributed/test/cql3/AccordInteropSingleNodeTokenConflictTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected void preCheck(Property.StatefulBuilder builder)
4242
}
4343

4444
@Override
45-
protected State createState(Cluster cluster, RandomSource rs)
45+
protected State createState(RandomSource rs, Cluster cluster)
4646
{
4747
return new AccordInteropState(rs, cluster);
4848
}

test/distributed/org/apache/cassandra/distributed/test/cql3/FullAccordInteropMultiNodeTableWalkTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.cassandra.distributed.test.cql3;
2020

2121
import accord.utils.Property;
22+
import org.apache.cassandra.distributed.Cluster;
2223
import org.apache.cassandra.service.consensus.TransactionalMode;
2324

2425
public class FullAccordInteropMultiNodeTableWalkTest extends AccordInteropMultiNodeTableWalkBase
@@ -29,9 +30,30 @@ public FullAccordInteropMultiNodeTableWalkTest()
2930
}
3031

3132
@Override
32-
protected void preCheck(Property.StatefulBuilder builder)
33+
protected void preCheck(Cluster cluster, Property.StatefulBuilder builder)
3334
{
35+
cluster.setUncaughtExceptionsFilter(t -> {
36+
// There is a known issue with drop table and journal snapshots where the journal can't find the given table...
37+
// To make these tests stable need to ignore this error as it's unrelated to the test and is target to be fixed
38+
// directly.
39+
/*
40+
Suppressed: java.lang.AssertionError: Unknown keyspace ks12
41+
at org.apache.cassandra.db.Keyspace.open(Keyspace.java:149)
42+
at org.apache.cassandra.db.Keyspace.openAndGetStoreIfExists(Keyspace.java:172)
43+
at org.apache.cassandra.service.accord.AccordDataStore.lambda$snapshot$2(AccordDataStore.java:104)
44+
*/
45+
46+
if (t instanceof AssertionError
47+
&& t.getMessage() != null
48+
&& t.getMessage().startsWith("Unknown keyspace ks"))
49+
return true;
50+
return false;
51+
});
3452
// if a failing seed is detected, populate here
3553
// Example: builder.withSeed(42L);
54+
// CQL operations may have opertors such as +, -, and / (example 4 + 4), to "apply" them to get a constant value
55+
// CQL_DEBUG_APPLY_OPERATOR = true;
56+
57+
builder.withExamples(50);
3658
}
3759
}

test/distributed/org/apache/cassandra/distributed/test/cql3/FullAccordInteropSingleNodeTableWalkTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.cassandra.distributed.test.cql3;
2020

2121
import accord.utils.Property;
22+
import org.apache.cassandra.distributed.Cluster;
2223
import org.apache.cassandra.service.consensus.TransactionalMode;
2324

2425
public class FullAccordInteropSingleNodeTableWalkTest extends AccordInteropSingleNodeTableWalkBase
@@ -29,9 +30,11 @@ public FullAccordInteropSingleNodeTableWalkTest()
2930
}
3031

3132
@Override
32-
protected void preCheck(Property.StatefulBuilder builder)
33+
protected void preCheck(Cluster cluster, Property.StatefulBuilder builder)
3334
{
3435
// if a failing seed is detected, populate here
3536
// Example: builder.withSeed(42L);
37+
// CQL operations may have opertors such as +, -, and / (example 4 + 4), to "apply" them to get a constant value
38+
// CQL_DEBUG_APPLY_OPERATOR = true;
3639
}
3740
}

test/distributed/org/apache/cassandra/distributed/test/cql3/MixedReadsAccordInteropMultiNodeTableWalkTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.cassandra.distributed.test.cql3;
2020

2121
import accord.utils.Property;
22+
import org.apache.cassandra.distributed.Cluster;
2223
import org.apache.cassandra.service.consensus.TransactionalMode;
2324

2425
public class MixedReadsAccordInteropMultiNodeTableWalkTest extends AccordInteropMultiNodeTableWalkBase
@@ -29,9 +30,11 @@ public MixedReadsAccordInteropMultiNodeTableWalkTest()
2930
}
3031

3132
@Override
32-
protected void preCheck(Property.StatefulBuilder builder)
33+
protected void preCheck(Cluster cluster, Property.StatefulBuilder builder)
3334
{
3435
// if a failing seed is detected, populate here
3536
// Example: builder.withSeed(42L);
37+
// CQL operations may have opertors such as +, -, and / (example 4 + 4), to "apply" them to get a constant value
38+
// CQL_DEBUG_APPLY_OPERATOR = true;
3639
}
3740
}

test/distributed/org/apache/cassandra/distributed/test/cql3/MixedReadsAccordInteropSingleNodeTableWalkTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.cassandra.distributed.test.cql3;
2020

2121
import accord.utils.Property;
22+
import org.apache.cassandra.distributed.Cluster;
2223
import org.apache.cassandra.service.consensus.TransactionalMode;
2324

2425
public class MixedReadsAccordInteropSingleNodeTableWalkTest extends AccordInteropSingleNodeTableWalkBase
@@ -29,9 +30,11 @@ public MixedReadsAccordInteropSingleNodeTableWalkTest()
2930
}
3031

3132
@Override
32-
protected void preCheck(Property.StatefulBuilder builder)
33+
protected void preCheck(Cluster cluster, Property.StatefulBuilder builder)
3334
{
3435
// if a failing seed is detected, populate here
3536
// Example: builder.withSeed(42L);
37+
// CQL operations may have opertors such as +, -, and / (example 4 + 4), to "apply" them to get a constant value
38+
// CQL_DEBUG_APPLY_OPERATOR = true;
3639
}
3740
}

test/distributed/org/apache/cassandra/distributed/test/cql3/MultiNodeTableWalkTest.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@
2525
import accord.utils.RandomSource;
2626
import org.apache.cassandra.distributed.Cluster;
2727
import org.apache.cassandra.distributed.api.ConsistencyLevel;
28+
import org.apache.cassandra.distributed.api.IInvokableInstance;
2829
import org.apache.cassandra.service.consensus.TransactionalMode;
2930

3031
public class MultiNodeTableWalkTest extends SingleNodeTableWalkTest
3132
{
33+
/**
34+
* This field lets the test run as if it was multiple nodes, but actually runs against a single node.
35+
* This behavior is desirable when this test fails to see if the issue can be reproduced on single node as well.
36+
*/
37+
private boolean mockMultiNode = true;
3238

3339
public MultiNodeTableWalkTest()
3440
{
@@ -40,16 +46,21 @@ protected MultiNodeTableWalkTest(@Nullable TransactionalMode transactionalMode)
4046
}
4147

4248
@Override
43-
protected void preCheck(Property.StatefulBuilder builder)
49+
protected void preCheck(Cluster cluster, Property.StatefulBuilder builder)
4450
{
4551
// if a failing seed is detected, populate here
4652
// Example: builder.withSeed(42L);
53+
// CQL operations may have opertors such as +, -, and / (example 4 + 4), to "apply" them to get a constant value
54+
// CQL_DEBUG_APPLY_OPERATOR = true;
55+
// Sometimes It's useful to validate that the error is localized to mutliple nodes rather than single node,
56+
// so uncomment the below to allow running the test as a single node
57+
// mockMultiNode = true;
4758
}
4859

4960
@Override
5061
protected Cluster createCluster() throws IOException
5162
{
52-
return createCluster(3, c -> {
63+
return createCluster(mockMultiNode ? 1 : 3, c -> {
5364
c.set("range_request_timeout", "180s")
5465
.set("read_request_timeout", "180s")
5566
.set("transaction_timeout", "180s")
@@ -72,6 +83,25 @@ public MultiNodeState(RandomSource rs, Cluster cluster)
7283
super(rs, cluster);
7384
}
7485

86+
@Override
87+
protected boolean isMultiNode()
88+
{
89+
// When a seed fails its useful to rerun the test as a single node to see if the issue persists... but doing so corrupts the random history!
90+
// To avoid that, this method hard codes that the test is multi node...
91+
return true;
92+
}
93+
94+
@Override
95+
protected IInvokableInstance selectInstance(RandomSource rs)
96+
{
97+
if (mockMultiNode)
98+
{
99+
rs.nextInt(0, 3); // needed to avoid breaking random history
100+
return cluster.get(1);
101+
}
102+
return super.selectInstance(rs);
103+
}
104+
75105
@Override
76106
protected ConsistencyLevel selectCl()
77107
{

test/distributed/org/apache/cassandra/distributed/test/cql3/SingleNodeTableWalkTest.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected SingleNodeTableWalkTest(@Nullable TransactionalMode transactionalMode)
9191
this.transactionalMode = transactionalMode;
9292
}
9393

94-
protected void preCheck(Property.StatefulBuilder builder)
94+
protected void preCheck(Cluster cluster, Property.StatefulBuilder builder)
9595
{
9696
// if a failing seed is detected, populate here
9797
// Example: builder.withSeed(42L);
@@ -111,13 +111,6 @@ protected List<CreateIndexDDL.Indexer> supportedIndexers()
111111
return Collections.singletonList(CreateIndexDDL.SAI);
112112
}
113113

114-
public Property.Command<State, Void, ?> insert(RandomSource rs, State state)
115-
{
116-
//TODO (maintaince): can this become reusable? its the same as token conflict test...
117-
Mutation mutation = state.mutationGen.next(rs);
118-
return state.command(rs, mutation);
119-
}
120-
121114
public Property.Command<State, Void, ?> selectExisting(RandomSource rs, State state)
122115
{
123116
NavigableSet<BytesPartitionState.Ref> keys = state.model.partitionKeys();
@@ -227,9 +220,9 @@ public void test() throws IOException
227220
try (Cluster cluster = createCluster())
228221
{
229222
Property.StatefulBuilder statefulBuilder = stateful().withExamples(10).withSteps(400);
230-
preCheck(statefulBuilder);
223+
preCheck(cluster, statefulBuilder);
231224
statefulBuilder.check(commands(() -> rs -> createState(rs, cluster))
232-
.add(this::insert)
225+
.add(StatefulASTBase::insert)
233226
.addIf(State::hasPartitions, this::selectExisting)
234227
.addAllIf(State::supportTokens, b -> b.add(this::selectToken)
235228
.add(this::selectTokenRange))
@@ -280,7 +273,7 @@ private static FunctionCall token(State state, BytesPartitionState.Ref ref)
280273
return FunctionCall.tokenByValue(values);
281274
}
282275

283-
public class State extends BaseState
276+
public class State extends CommonState
284277
{
285278
protected final LinkedHashMap<Symbol, IndexedColumn> indexes;
286279
private final Gen<Mutation> mutationGen;
@@ -316,6 +309,12 @@ public State(RandomSource rs, Cluster cluster)
316309
.build());
317310
}
318311

312+
@Override
313+
protected Gen<Mutation> mutationGen()
314+
{
315+
return mutationGen;
316+
}
317+
319318
private LinkedHashMap<Symbol, IndexedColumn> createIndexes(RandomSource rs, TableMetadata metadata)
320319
{
321320
LinkedHashMap<Symbol, IndexedColumn> indexed = new LinkedHashMap<>();

0 commit comments

Comments
 (0)