aweisberg commented on code in PR #2049:
URL: https://github.com/apache/cassandra/pull/2049#discussion_r1063845177


##########
test/distributed/org/apache/cassandra/distributed/test/accord/AccordCQLTest.java:
##########
@@ -2305,4 +2312,30 @@ public void testReferenceArithmeticInUpdate() throws 
Exception
              assertEmptyWithPreemptedRetry(cluster, cql);
         });
     }
+
+    @Test
+    public void testCASAndSerialRead() throws Exception
+    {
+        test("CREATE TABLE " + currentTable + " (id int, c int, v int, s int 
static, PRIMARY KEY ((id), c));",
+            cluster -> {
+                ICoordinator coordinator = cluster.coordinator(1);
+                int startingAccordCoordinateCount = getAccordCoordinateCount();
+                coordinator.execute("INSERT INTO " + currentTable + " (id, c, 
v, s) VALUES (1, 2, 3, 5);", ConsistencyLevel.ALL);
+                assertRowSerial(cluster, "SELECT id, c, v, s FROM " + 
currentTable + " WHERE id = 1 AND c = 2", 1, 2, 3, 5);
+                assertRowEqualsWithPreemptedRetry(cluster, new Object[]{true}, 
"UPDATE " + currentTable + " SET v = 4 WHERE id = 1 AND c = 2 IF v = 3");
+                assertRowSerial(cluster, "SELECT id, c, v, s FROM " + 
currentTable + " WHERE id = 1 AND c = 2", 1, 2, 4, 5);
+                assertRowEqualsWithPreemptedRetry(cluster, new Object[]{ 
false, 4 }, "UPDATE " + currentTable + " SET v = 4 WHERE id = 1 AND c = 2 IF v 
= 3");
+                assertRowSerial(cluster, "SELECT id, c, v, s FROM " + 
currentTable + " WHERE id = 1 AND c = 2", 1, 2, 4, 5);
+
+                // Test working with a static column
+                assertRowEqualsWithPreemptedRetry(cluster, new Object[]{ 
false, 5 }, "UPDATE " + currentTable + " SET v = 5 WHERE id = 1 AND c = 2 IF s 
= 4");
+                assertRowSerial(cluster, "SELECT id, c, v, s FROM " + 
currentTable + " WHERE id = 1 AND c = 2", 1, 2, 4, 5);
+                assertRowEqualsWithPreemptedRetry(cluster, new Object[]{true}, 
"UPDATE " + currentTable + " SET v = 5 WHERE id = 1 AND c = 2 IF s = 5");
+                assertRowSerial(cluster, "SELECT id, c, v, s FROM " + 
currentTable + " WHERE id = 1 AND c = 2", 1, 2, 5, 5);
+                assertRowEqualsWithPreemptedRetry(cluster, new Object[]{true}, 
"UPDATE " + currentTable + " SET s = 6 WHERE id = 1 IF s = 5");
+                assertRowSerial(cluster, "SELECT id, c, v, s FROM " + 
currentTable + " WHERE id = 1 AND c = 2", 1, 2, 5, 6);
+                // Make sure all the consensus using queries actually were run 
on Accord
+                assertEquals( 11, getAccordCoordinateCount() - 
startingAccordCoordinateCount);
+        });
+    }

Review Comment:
   I was leaning on ColumnConditionTest to check that we could actually 
roundtrip the already tested implementation of CAS and CQL semantics and then 
end to end test with AccordCQLTest we could actually read/write data running 
through Accord.
   
   CASTestBase requires functionality I don't think we have yet in accord like 
adding and removing nodes. CASWriteTest has tests that are pretty specifically 
testing the Paxos implementation.
   
   I think running with simulator is more interesting, but it was not quite 
working when I went to run it although I do have a branch with it 
https://github.com/aweisberg/cassandra/tree/cassandra-18100-simulator
   
   There are kind of two things to test in my mind. Does any CQL 
syntax/semantics break with CAS on Accord, and does actually running requests 
on Accord work. I think the latter is pretty well covered and simulator is the 
real proof, but also if Accord can pass simulator for other transaction types 
it should apply to CAS transactions.
   
   The former is kind of unit tested by ColumnConditionTest in that if 
ColumnCondition correctly implements the CQL and we can roundtrip it then it 
should also work for CAS. A lot of the code is existing code.
   
   The hole there is I am not sure we test CAS syntax methodically anywhere?



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