dcapwell commented on code in PR #4684:
URL: https://github.com/apache/cassandra/pull/4684#discussion_r3149401563
##########
test/distributed/org/apache/cassandra/distributed/test/accord/AccordCQLTestBase.java:
##########
@@ -330,6 +338,79 @@ public void testPartitionMultiRowReturn() throws Exception
});
}
+ @Test
+ public void testSinglePartitionKeyBatch() throws Throwable
+ {
+ List<String> ddls = Arrays.asList("DROP KEYSPACE IF EXISTS " +
KEYSPACE + ';',
+ "CREATE KEYSPACE " + KEYSPACE + "
WITH REPLICATION={'class':'SimpleStrategy', 'replication_factor': 2}",
+ "CREATE TABLE " +
qualifiedAccordTableName + " (k int PRIMARY KEY, v int) WITH " +
transactionalMode.asCqlParam(),
+ "CREATE TABLE " +
qualifiedRegularTableName + " (k int PRIMARY KEY, v int)");
+
+ test(ddls, cluster -> {
+ cluster.coordinator(1).execute("BEGIN BATCH\n" +
+ "INSERT INTO " +
qualifiedAccordTableName + " (k, v) VALUES (1, 2);\n" +
+ "INSERT INTO " +
qualifiedRegularTableName + " (k, v) VALUES (1, 3);\n" +
+ "APPLY BATCH;",
ConsistencyLevel.ONE);
+
+ SimpleQueryResult r1 =
cluster.coordinator(1).executeWithResult("SELECT * FROM " +
qualifiedAccordTableName + " WHERE k = 1", ConsistencyLevel.ONE);
+ SimpleQueryResult r2 =
cluster.coordinator(1).executeWithResult("SELECT * FROM " +
qualifiedRegularTableName + " WHERE k = 1", ConsistencyLevel.ONE);
+
+ assertEquals(1, r1.toObjectArrays().length);
+ assertEquals(1, r2.toObjectArrays().length);
+ });
+ }
+
+ @Test
+ public void testSinglePartitionKeyBatchWrittenToBatchLog() throws Throwable
+ {
+ DatabaseDescriptor.daemonInitialization();
+ List<String> ddls = Arrays.asList("DROP KEYSPACE IF EXISTS " +
KEYSPACE + ';',
+ "CREATE KEYSPACE " + KEYSPACE + "
WITH REPLICATION={'class':'SimpleStrategy', 'replication_factor': 2}",
+ "CREATE TABLE " +
qualifiedAccordTableName + " (k int PRIMARY KEY, v int) WITH " +
transactionalMode.asCqlParam(),
+ "CREATE TABLE " +
qualifiedRegularTableName + " (k int PRIMARY KEY, v int)");
+
+ test(ddls, cluster -> {
+ pauseHints();
+ blockMutationAndPreAccept(cluster);
+ try
+ {
+ cluster.coordinator(1).execute("BEGIN BATCH\n" +
+ "INSERT INTO " +
qualifiedAccordTableName + " (k, v) VALUES (1, 2);\n" +
+ "INSERT INTO " +
qualifiedRegularTableName + " (k, v) VALUES (1, 3);\n" +
+ "APPLY BATCH;",
ConsistencyLevel.ALL);
+ fail("Should have thrown WTE");
+ }
+ catch (Throwable t)
+ {
+ assertEquals(t.getClass().getName(),
WriteTimeoutException.class.getName());
+ }
+
+ if (transactionalMode.nonSerialWritesThroughAccord)
+ cluster.get(1).runOnInstance(() -> {
+ String query = String.format("SELECT id, mutations,
version FROM %s.%s",
+
SchemaConstants.SYSTEM_KEYSPACE_NAME,
+ SystemKeyspace.BATCHES);
+
+ Iterator<UntypedResultSet.Row> r =
QueryProcessor.executeInternal(query).iterator();
+ assert (r.hasNext());
+ UntypedResultSet.Row row = r.next();
+
+ int version = row.getInt("version");
+ List<ByteBuffer> serializedMutations =
row.getList("mutations", BytesType.instance);
+ assertEquals(1, serializedMutations.size());
+
+ try (DataInputBuffer in = new
DataInputBuffer(serializedMutations.get(0), true))
+ {
+ assertEquals(2,
org.apache.cassandra.db.Mutation.serializer.deserialize(in,
version).getPartitionUpdates().size());
+ }
+ catch (Exception e)
+ {
+ logger.info("Deserialization failed");
Review Comment:
you should fail the test; if this is happening the test passes but we have a
bug?
--
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]