zentol commented on issue #7850: [FLINK-11183][metrics] Properly measure current memory usage URL: https://github.com/apache/flink/pull/7850#issuecomment-470067647 I don't think tests are worth it in this case. You have to do some funky things to test these metrics, and even then you can't even cover all of them. `Max` can't be tested since usually is either undefined (-1) or fixed from startup. In any case we can't influence this value. For heap metrics we can indeed allocate an array to test `Used`, however to test `Committed` we have to exceed the current committed space. If the JVM is configured to commit little memory on the start everything is fine, but it's not unthinkable that people set this to some really large value (say multiple GB) In the worst-case `committed == max` so you have to guard against this edge-case. This gets even worse for non-heap metrics since you can't influence it as easily. You'd have to load a _ton_ of classes to affect `Committed`. At the end of the day the test would be significantly more complex than the code that it tests, so I'm against adding it.
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
