jacek-lewandowski commented on code in PR #2900:
URL: https://github.com/apache/cassandra/pull/2900#discussion_r1394356622


##########
test/unit/org/apache/cassandra/io/DiskSpaceMetricsTest.java:
##########
@@ -109,15 +112,13 @@ public void testFlushSize() throws Throwable
         for (int i = 0; i < 3; i++)
             insertN(KEYSPACE_PER_TEST, cfs, 1000, 55);
 
-        cfs.forceBlockingFlush(ColumnFamilyStore.FlushReason.UNIT_TESTS);
-        int totalSize = 0;
-        final Set<SSTableReader> liveSSTables = cfs.getLiveSSTables();
+        final List<SSTableReader> liveSSTables = cfs.getLiveSSTables().stream()
+                                                    
.sorted(SSTableReader.idComparator)
+                                                    
.collect(Collectors.toList());
+        MovingAverage expectedMetrics = ExpMovingAverage.decayBy1000();
         for (SSTableReader rdr : liveSSTables)
-        {
-            totalSize += rdr.onDiskLength();
-        }
-        final int avgSize = totalSize / liveSSTables.size();
-        assertEquals(avgSize, cfs.metric.flushSizeOnDisk.get(), 0.05 * 
avgSize);
+            expectedMetrics.update(rdr.onDiskLength());
+        
assertThat(cfs.metric.flushSizeOnDisk.get()).isEqualTo(expectedMetrics.get());

Review Comment:
   we could do that, though, I've run 500 iterations of this test without that 
delta and it passed each 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