wujimin commented on a change in pull request #987: [SCB-1017]add os cpu net
info in the metrics with linux os
URL:
https://github.com/apache/servicecomb-java-chassis/pull/987#discussion_r233341233
##########
File path:
foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestNetUtils.java
##########
@@ -108,6 +108,48 @@ public void testCanTcpListenYes() throws IOException {
Assert.assertTrue(NetUtils.canTcpListen(address, port));
}
+ @Test
+ public void humanReadableBytes() throws IOException {
+ Assert.assertEquals("0 B", NetUtils.humanReadableBytes(0L));
+ Assert.assertEquals("1 B", NetUtils.humanReadableBytes(1L));
+ Assert.assertEquals("1023 B", NetUtils.humanReadableBytes(1023L));
+
+ Assert.assertEquals("1.000 KB", NetUtils.humanReadableBytes(1024L));
+ Assert.assertEquals("1.001 KB", NetUtils.humanReadableBytes(1025L));
+ Assert.assertEquals("1023.999 KB", NetUtils.humanReadableBytes(1024L *
1024 - 1));
+
+ Assert.assertEquals("1.000 MB", NetUtils.humanReadableBytes(1024L * 1024));
+ Assert.assertEquals("1.000 MB", NetUtils.humanReadableBytes(1024L * 1024 +
1));
+ Assert.assertEquals("1.001 MB", NetUtils.humanReadableBytes(1024L * 1024 +
1024));
+ Assert.assertEquals("1023.999 MB", NetUtils.humanReadableBytes(1024L *
1024 * 1024 - 1024));
+ Assert.assertEquals("1024.000 MB", NetUtils.humanReadableBytes(1024L *
1024 * 1024 - 1));
+
+ Assert.assertEquals("1.000 GB", NetUtils.humanReadableBytes(1024L * 1024 *
1024));
+ Assert.assertEquals("1.000 GB", NetUtils.humanReadableBytes(1024L * 1024 *
1024 + 1));
+ Assert.assertEquals("1.000 GB", NetUtils.humanReadableBytes(1024L * 1024 *
1024 + 1024));
+ Assert.assertEquals("1023.999 GB", NetUtils.humanReadableBytes(1024L *
1024 * 1024 * 1024 - 1024 * 1024));
+ Assert.assertEquals("1024.000 GB", NetUtils.humanReadableBytes(1024L *
1024 * 1024 * 1024 - 1024));
+ Assert.assertEquals("1.000 TB", NetUtils.humanReadableBytes(1024L * 1024 *
1024 * 1024));
+ Assert.assertEquals("1.001 TB", NetUtils.humanReadableBytes(1024L * 1024 *
1024 * 1024 + 1024 * 1024 * 1024));
+ Assert.assertEquals("1023.999 TB",
+ NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 - 1024L
* 1024 * 1024));
+
+ Assert.assertEquals("1.000 PB", NetUtils.humanReadableBytes(1024L * 1024 *
1024 * 1024 * 1024));
+ Assert.assertEquals("1.001 PB",
+ NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 + 1024L
* 1024 * 1024 * 1024));
+ Assert.assertEquals("1023.999 PB",
+ NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 * 1024 -
1024L * 1024 * 1024 * 1024));
+
+ Assert.assertEquals("1.000 EB", NetUtils.humanReadableBytes(1024L * 1024 *
1024 * 1024 * 1024 * 1024));
+ Assert.assertEquals("1.001 EB",
+ NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 * 1024 +
1024L * 1024 * 1024 * 1024 * 1024));
+ Assert.assertEquals("8.000 EB",
NetUtils.humanReadableBytes(Long.MAX_VALUE));
+ }
+
+ public static void main(String[] args) {
Review comment:
remove main function
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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