This is an automated email from the ASF dual-hosted git repository.
dcapwell pushed a commit to branch cep-15-accord
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cep-15-accord by this push:
new 92d90a8a24 Topology mixup tests should do repairs for host replacement
and other required topology changes
92d90a8a24 is described below
commit 92d90a8a24870e63d660951922cb66f847476a87
Author: David Capwell <[email protected]>
AuthorDate: Mon Mar 10 15:57:18 2025 -0700
Topology mixup tests should do repairs for host replacement and other
required topology changes
patch by David Capwell; reviewed by Benedict Elliott Smith for
CASSANDRA-20426
---
.../fuzz/topology/TopologyMixupTestBase.java | 33 +++++++++++++---------
.../cassandra/index/accord/RouteIndexTest.java | 5 +++-
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git
a/test/distributed/org/apache/cassandra/fuzz/topology/TopologyMixupTestBase.java
b/test/distributed/org/apache/cassandra/fuzz/topology/TopologyMixupTestBase.java
index fe1bbabed3..5e821770d2 100644
---
a/test/distributed/org/apache/cassandra/fuzz/topology/TopologyMixupTestBase.java
+++
b/test/distributed/org/apache/cassandra/fuzz/topology/TopologyMixupTestBase.java
@@ -140,8 +140,9 @@ public abstract class TopologyMixupTestBase<S extends
TopologyMixupTestBase.Sche
state ->
state.cluster.get(toCoordinate).nodetoolResult("repair",
state.schema.keyspace(), state.schema.table(), "--force").asserts().success());
}
- private static <S extends Schema> Command<State<S>, Void, ?>
repairCommand(int toCoordinate, String ks, String... tables) {
- return new SimpleCommand<>(state -> "nodetool repair " + ks +
(tables.length == 0 ? "" : " " + Arrays.asList(tables)) + " from node" +
toCoordinate + state.commandNamePostfix(),
+ private static <S extends Schema> Command<State<S>, Void, ?>
repairCommand(@Nullable String reason, int toCoordinate, String ks, String...
tables)
+ {
+ return new SimpleCommand<>(state -> "nodetool repair " + ks +
(tables.length == 0 ? "" : " " + Arrays.asList(tables)) + (reason == null ? ""
: " for " + reason) + " from node" + toCoordinate + state.commandNamePostfix(),
state -> {
if (tables.length == 0) {
state.cluster.get(toCoordinate).nodetoolResult("repair", ks,
"--force").asserts().success();
@@ -156,6 +157,19 @@ public abstract class TopologyMixupTestBase<S extends
TopologyMixupTestBase.Sche
});
}
+ protected static <S extends Schema> Command<State<S>, Void, ?>
repairFor(State<S> state, String reason)
+ {
+ List<Command<State<S>, Void, ?>> commands = new ArrayList<>();
+ //TODO (efficiency): rather than run on every instance, run on 1 per
section of the ring?
+ for (int inst : state.topologyHistory.up())
+ {
+ commands.add(repairCommand(reason, inst, "system_auth"));
+ commands.add(repairCommand(reason, inst, "system_traces"));
+ commands.add(repairCommand(reason, inst, state.schema.keyspace(),
state.schema.table()));
+ }
+ return multistep(commands);
+ }
+
private Command<State<S>, Void, ?> waitForCMSToQuiesce()
{
return new Property.StateOnlyCommand<>()
@@ -436,13 +450,13 @@ public abstract class TopologyMixupTestBase<S extends
TopologyMixupTestBase.Sche
switch (task)
{
case AddNode:
- possible.put(ignore -> multistep(addNode(),
awaitClusterStable()), 1);
+ possible.put(ignore -> multistep(repairFor(state, "add
node"), addNode(), awaitClusterStable()), 1);
break;
case RemoveNode:
possible.put(rs ->
multistep(removeNodeRandomizedDispatch(rs, state), awaitClusterStable()), 1);
break;
case HostReplace:
- possible.put(rs -> multistep(hostReplace(rs, state),
awaitClusterStable()), 1);
+ possible.put(rs -> multistep(repairFor(state, "host
replace"), hostReplace(rs, state), awaitClusterStable()), 1);
break;
case StartNode:
possible.put(rs -> startInstance(rs, state), 1);
@@ -632,19 +646,10 @@ public abstract class TopologyMixupTestBase<S extends
TopologyMixupTestBase.Sche
if (next.checkPreconditions(state) ==
Property.PreCheckResult.Ignore)
return next;
commandsTransformers.remove(self);
- int[] up = state.topologyHistory.up();
List<Command<State<S>, Void, ?>> commands = new
ArrayList<>();
commands.add(fixDistributedSchemas);
- for (String ks : Arrays.asList("system_auth",
"system_traces"))
- {
- int coordinator = rs.pickInt(up);
- commands.add(repairCommand(coordinator, ks));
- }
commands.add(fixTestKeyspace);
- {
- int coordinator = rs.pickInt(up);
- commands.add(repairCommand(coordinator, KEYSPACE));
- }
+ commands.add(repairFor(state, "set RF=" + TARGET_RF));
commands.add(reconfig);
commands.add(next);
return multistep(commands);
diff --git a/test/unit/org/apache/cassandra/index/accord/RouteIndexTest.java
b/test/unit/org/apache/cassandra/index/accord/RouteIndexTest.java
index 02db16b993..7528cd6d5f 100644
--- a/test/unit/org/apache/cassandra/index/accord/RouteIndexTest.java
+++ b/test/unit/org/apache/cassandra/index/accord/RouteIndexTest.java
@@ -101,6 +101,7 @@ import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.LazyToString;
import org.apache.cassandra.utils.RTree;
import org.apache.cassandra.utils.RangeTree;
+import org.apache.cassandra.utils.concurrent.CountDownLatch;
import org.assertj.core.api.Assertions;
import org.mockito.Mockito;
@@ -589,7 +590,9 @@ public class RouteIndexTest extends CQLTester.InMemory
Txn txn = toTxn(txnId, participants);
AccordGenerators.CommandBuilder builder = new
AccordGenerators.CommandBuilder(txnId, txn, txnId,
txn.slice(participants.owns().toRanges(), true), PartialDeps.NONE, Ballot.ZERO,
Ballot.ZERO, accord.local.Command.WaitingOn.none(txnId.domain(), Deps.NONE));
var cmd = builder.build(saveStatus);
- journal.get().saveCommand(storeId, new Journal.CommandUpdate(null,
cmd), () -> {});
+ CountDownLatch latch = CountDownLatch.newCountDownLatch(1);
+ journal.get().saveCommand(storeId, new Journal.CommandUpdate(null,
cmd), () -> latch.decrement());
+ latch.awaitThrowUncheckedOnInterrupt();
}
private static Txn toTxn(TxnId txnId, StoreParticipants participants)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]