You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/01/11 16:06:49 UTC

[GitHub] [cassandra] adelapena commented on a change in pull request #821: CASSANDRA-16181 - 4.0 Quality: Replication Test Audit

adelapena commented on a change in pull request #821:
URL: https://github.com/apache/cassandra/pull/821#discussion_r555160694



##########
File path: test/distributed/org/apache/cassandra/distributed/upgrade/MixedModeBatchTestBase.java
##########
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.distributed.upgrade;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cassandra.distributed.api.ConsistencyLevel;
+import org.apache.cassandra.distributed.shared.Versions;
+import org.apache.cassandra.exceptions.WriteFailureException;
+
+import static org.apache.cassandra.distributed.shared.AssertUtils.assertRows;
+import static org.apache.cassandra.distributed.shared.AssertUtils.row;
+
+public class MixedModeBatchTestBase extends MixedModeReplicationTestBase
+{
+    private static final int KEYS_PER_BATCH = 10;
+
+    protected void testSimpleStrategy(Versions.Major from, Versions.Major to, boolean isLogged) throws Throwable
+    {
+        String insert = "INSERT INTO test_simple.names (key, name) VALUES (%d, '%s')";
+        String select = "SELECT * FROM test_simple.names WHERE key = ?";
+
+        new TestCase()
+        .nodes(3)
+        .nodesToUpgrade(1, 2)
+        .upgrade(from, to)
+        .setup(cluster -> {
+            cluster.schemaChange("CREATE KEYSPACE test_simple WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2};");
+            cluster.schemaChange("CREATE TABLE test_simple.names (key int PRIMARY KEY, name text)");
+        })
+        .runAfterNodeUpgrade((cluster, upgraded) -> {
+            List<Long> initialTokens = new ArrayList<>(cluster.size() + 1);
+            initialTokens.add(null); // The first valid token is at 1 to avoid offset math below.
+
+            for (int i = 1; i <= cluster.size(); i++)
+                initialTokens.add(Long.valueOf(cluster.get(i).config().get("initial_token").toString()));
+
+            List<Long> validTokens = initialTokens.subList(1, cluster.size() + 1);
+
+            // Exercise all the coordinators...
+            for (int i = 1; i <= cluster.size(); i++)
+            {
+                StringBuilder batchBuilder = new StringBuilder("BEGIN " + (isLogged ? "" : "UNLOGGED ") + "BATCH\n");

Review comment:
       > I've been looking for some tests somewhere that actually verify atomicity (without isolation, of course) in the case where a mutation in the batch fails, but I don't see any.
   
   That seems an important omission in dtests, being the kind of thing we want to detect and fix in this ticket. We might want to test batch atomicity in a regular not-upgrade dtest too.
   > It might be possible to parameterize the existing tests to optionally activate a ByteBuddy rule or network filter that fails batchlog writes. WDYT?
   
   A parameter to activate/deactivate a ByteBuddy rule seems to make sense, although I'm not sure whether the same rule will be compatible with all the previous versions, so the network filter might be more flexible. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org