Skip to content

Commit 457f399

Browse files
committed
Add test for fetched tombstones metrics
1 parent 43d930f commit 457f399

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

test/unit/org/apache/cassandra/index/sai/metrics/QueryMetricsTest.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ private void testQueryKindMetrics(boolean perTable, boolean perQuery)
494494
for (int c = 0; c < numRowsPerPartition; c++)
495495
execute("INSERT INTO %s (k, c, n, v) VALUES (?, ?, 1, [1, 1])", k, c);
496496

497+
// add a tombstone
498+
execute("INSERT INTO %s (k, c, n, v) VALUES (?, ?, 1, [1, 1])", numPartitions, numRowsPerPartition);
499+
execute("DELETE FROM %s WHERE k = ?", numPartitions);
500+
497501
// filter query (goes to the general, filter and range query metrics)
498502
UntypedResultSet rows = execute("SELECT k, c FROM %s WHERE n = 1");
499503
assertEquals(numRows, rows.size());
@@ -530,13 +534,13 @@ private void testQueryKindMetrics(boolean perTable, boolean perQuery)
530534

531535
// Verify counters for total keys fetched.
532536
name = "TotalKeysFetched";
533-
waitForEquals(objectName(name, TABLE_QUERY_METRIC_TYPE), numRowsPerPartition + numRows + numRowsPerPartition + numRows + numRowsPerPartition + numRows);
537+
waitForEquals(objectName(name, TABLE_QUERY_METRIC_TYPE), 3L * (numRowsPerPartition + numRows + 1));
534538
waitForEqualsIfExists(perTable, objectName(name, TABLE_SP_FILTER_QUERY_METRIC_TYPE), numRowsPerPartition);
535-
waitForEqualsIfExists(perTable, objectName(name, TABLE_MP_FILTER_QUERY_METRIC_TYPE), numRows);
539+
waitForEqualsIfExists(perTable, objectName(name, TABLE_MP_FILTER_QUERY_METRIC_TYPE), numRows + 1);
536540
waitForEqualsIfExists(perTable, objectName(name, TABLE_SP_TOPK_QUERY_METRIC_TYPE), numRowsPerPartition);
537-
waitForEqualsIfExists(perTable, objectName(name, TABLE_MP_TOPK_QUERY_METRIC_TYPE), numRows);
541+
waitForEqualsIfExists(perTable, objectName(name, TABLE_MP_TOPK_QUERY_METRIC_TYPE), numRows + 1);
538542
waitForEqualsIfExists(perTable, objectName(name, TABLE_SP_HYBRID_QUERY_METRIC_TYPE), numRowsPerPartition);
539-
waitForEqualsIfExists(perTable, objectName(name, TABLE_MP_HYBRID_QUERY_METRIC_TYPE), numRows);
543+
waitForEqualsIfExists(perTable, objectName(name, TABLE_MP_HYBRID_QUERY_METRIC_TYPE), numRows + 1);
540544

541545
// Verify counters for total partitions fetched.
542546
name = "TotalPartitionsFetched";
@@ -578,6 +582,16 @@ private void testQueryKindMetrics(boolean perTable, boolean perQuery)
578582
waitForEqualsIfExists(perTable, objectName(name, TABLE_SP_HYBRID_QUERY_METRIC_TYPE), numRowsPerPartition);
579583
waitForEqualsIfExists(perTable, objectName(name, TABLE_MP_HYBRID_QUERY_METRIC_TYPE), numRows);
580584

585+
// Verify counters for total tombstones fetched.
586+
name = "TotalTombstonesFetched";
587+
waitForEquals(objectName(name, TABLE_QUERY_METRIC_TYPE), 3);
588+
waitForEqualsIfExists(perTable, objectName(name, TABLE_SP_FILTER_QUERY_METRIC_TYPE), 0);
589+
waitForEqualsIfExists(perTable, objectName(name, TABLE_MP_FILTER_QUERY_METRIC_TYPE), 1);
590+
waitForEqualsIfExists(perTable, objectName(name, TABLE_SP_TOPK_QUERY_METRIC_TYPE), 0);
591+
waitForEqualsIfExists(perTable, objectName(name, TABLE_MP_TOPK_QUERY_METRIC_TYPE), 1);
592+
waitForEqualsIfExists(perTable, objectName(name, TABLE_SP_HYBRID_QUERY_METRIC_TYPE), 0);
593+
waitForEqualsIfExists(perTable, objectName(name, TABLE_MP_HYBRID_QUERY_METRIC_TYPE), 1);
594+
581595
// Verify counters for timeouts.
582596
name = "TotalQueryTimeouts";
583597
waitForEquals(objectName(name, TABLE_QUERY_METRIC_TYPE), 0);

0 commit comments

Comments
 (0)