tolbertam commented on code in PR #3917:
URL: https://github.com/apache/cassandra/pull/3917#discussion_r2040858768


##########
test/unit/org/apache/cassandra/cql3/PstmtPersistenceTest.java:
##########
@@ -142,19 +148,103 @@ public void testPstmtInvalidation() throws Throwable
 
         createTable("CREATE TABLE %s (key int primary key, val int)");
 
+        long initialEvicted = numberOfEvictedStatements();
+
         for (int cnt = 1; cnt < 10000; cnt++)
         {
             prepareStatement("INSERT INTO %s (key, val) VALUES (?, ?) USING 
TIMESTAMP " + cnt, clientState);
 
-            if (numberOfEvictedStatements() > 0)
+            if (numberOfEvictedStatements() - initialEvicted > 0)
             {
+                assertEquals("Number of statements in table and in cache don't 
match", numberOfStatementsInMemory(), numberOfStatementsOnDisk());
+
+                // prepare a more statements to trigger more evictions
+                for (int cnt2 = cnt + 1; cnt2 < cnt + 10; cnt2++)
+                    prepareStatement("INSERT INTO %s (key, val) VALUES (?, ?) 
USING TIMESTAMP " + cnt2, clientState);
+
+                // each new prepared statement should have caused an eviction
+                assertEquals("eviction count didn't increase by the expected 
number", 10, numberOfEvictedStatements() - initialEvicted);
+                assertEquals("Number of statements in memory (expected) and 
table (actual) don't match", numberOfStatementsInMemory(), 
numberOfStatementsOnDisk());
+
                 return;
             }
         }
 
         fail("Prepared statement eviction does not work");
     }
 
+
+
+    @Test
+    public void testAsyncPstmtInvalidation() throws Throwable

Review Comment:
   Thanks for the byteman instrumentation suggestion.  I added something for 
that which enables the test to ensure that all load timestamps precede delete 
timestamps and it seems to work quite well.
   
   While it looks like the test is doing quite a bit, it's not actually doing 
much more than `testPstmtInvalidation` other than preparing statements 
asynchronously with a concurrency of 10 in an executor and with some additional 
validation.  The test takes on the order of ~1200ms where testPstmtInvalidation 
takes ~500ms.
   
   I think there is still some value in it as it is more representative of how 
prepared statements can be prepared in practice (multiple threads preparing 
statements concurrently), but I'm also ok with just merging the validation i 
added here into `testPstmtInvalidation`, let me know what you think :+1:



-- 
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: pr-unsubscr...@cassandra.apache.org

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


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

Reply via email to