XComp commented on a change in pull request #13640:
URL: https://github.com/apache/flink/pull/13640#discussion_r506330671



##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/metrics/util/MetricUtilsTest.java
##########
@@ -119,4 +141,62 @@ public void testHeapMetrics() throws Exception {
                }
                Assert.fail("Heap usage metric never changed it's value.");
        }
+
+       @Test
+       public void testNonHeapMetricUsageNotStatic() throws 
InterruptedException {
+               final InterceptingOperatorMetricGroup nonHeapMetrics = new 
InterceptingOperatorMetricGroup();
+
+               MetricUtils.instantiateNonHeapMemoryMetrics(nonHeapMetrics);
+
+               @SuppressWarnings("unchecked")
+               final Gauge<Long> used = (Gauge<Long>) 
nonHeapMetrics.get(MetricNames.MEMORY_USED);
+
+               final long usedNonHeapInitially = used.getValue();
+
+               // check memory usage difference multiple times since other 
tests may affect memory usage as well
+               for (int x = 0; x < 10; x++) {
+                       final ByteBuffer tmpByteBuffer = 
ByteBuffer.allocateDirect(1024 * 1024 * 8);
+                       final long usedNonHeapAfterAllocation = used.getValue();
+
+                       if (usedNonHeapInitially != usedNonHeapAfterAllocation) 
{
+                               return;
+                       }
+                       Thread.sleep(50);
+               }
+               Assert.fail("Non-Heap usage metric never changed it's value.");
+       }
+
+       @Test
+       public void testMetaspaceMetricUsageNotStatic() throws 
InterruptedException {
+               final InterceptingOperatorMetricGroup metaspaceMetrics = new 
InterceptingOperatorMetricGroup();
+               final InterceptingOperatorMetricGroup parentMetrics = new 
InterceptingOperatorMetricGroup() {
+                       @Override
+                       public MetricGroup addGroup(String name) {
+                               return metaspaceMetrics;

Review comment:
       It was addressed. See [comment 
above](https://github.com/apache/flink/pull/13640#discussion_r506330191).




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

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


Reply via email to