dcapwell commented on code in PR #4684:
URL: https://github.com/apache/cassandra/pull/4684#discussion_r3149398103


##########
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());

Review Comment:
   nit: use junit assert.  `-ea` should be set by java, but its always best to 
be explicit; you don't want to actually have a conditionally run assert here, 
you want to run 100% of the time?



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

Reply via email to