smiklosovic commented on code in PR #1791:
URL: https://github.com/apache/cassandra/pull/1791#discussion_r947197740


##########
test/unit/org/apache/cassandra/tools/nodetool/CompactionStatsTest.java:
##########
@@ -251,20 +334,31 @@ public boolean isGlobal()
         };
 
         CompactionManager.instance.active.beginCompaction(compactionHolder);
-        ToolRunner.ToolResult tool = 
ToolRunner.invokeNodetool("compactionstats", "--vtable", "--human-readable");
-        tool.assertOnCleanExit();
-        String stdout = tool.getStdout();
-        assertThat(stdout).contains("pending tasks: 1");
+
+        String stdout = waitForNumberOfPendingTasks(1,"compactionstats", 
"--vtable", "--human-readable");
+
         
Assertions.assertThat(stdout).containsPattern("keyspace\\s+table\\s+task 
id\\s+completion ratio\\s+kind\\s+progress\\s+sstables\\s+total\\s+unit");
         String expectedStatsPattern = 
String.format("%s\\s+%s\\s+%s\\s+%.2f%%\\s+%s\\s+%s\\s+%s\\s+%s\\s+%s",
             CQLTester.KEYSPACE, currentTable(), compactionId, (double) 
bytesCompacted / bytesTotal * 100,
             OperationType.COMPACTION, "123 bytes", sstables.size(), "120.56 
KiB", CompactionInfo.Unit.BYTES);
         Assertions.assertThat(stdout).containsPattern(expectedStatsPattern);
 
         CompactionManager.instance.active.finishCompaction(compactionHolder);
-        tool = ToolRunner.invokeNodetool("compactionstats", "--vtable", 
"--human-readable");
-        tool.assertOnCleanExit();
-        stdout = tool.getStdout();
-        assertThat(stdout).contains("pending tasks: 0");
+
+        waitForNumberOfPendingTasks(0,"compactionstats", "--vtable", 
"--human-readable");
+    }
+
+    private String waitForNumberOfPendingTasks(int pendingTasksToWaitFor, 
String... args)

Review Comment:
   helper for asserting / waiting on the number of pending tasks. The tests 
were flaky for me when executed on repeat.



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