diff --git a/tests/system_tests_skmanage.py b/tests/system_tests_skmanage.py index 4da148e7a..c6f542fab 100644 --- a/tests/system_tests_skmanage.py +++ b/tests/system_tests_skmanage.py @@ -625,16 +625,20 @@ def test_check_memory_usage(self): query_command = f'QUERY --type={ROUTER_METRICS_TYPE}' output = json.loads(self.run_skmanage(query_command)) self.assertEqual(len(output), 1) - mem = output[0].get('memoryUsage') + vmsize = output[0].get('memoryUsage') + rss = output[0].get('residentMemoryUsage') if sys.platform.lower().startswith('linux'): # @TODO(kgiusti) - linux only for now - self.assertIsNotNone(mem) - self.assertGreaterEqual(mem, 0) + self.assertIsNotNone(vmsize) + self.assertIsNotNone(rss) + self.assertGreaterEqual(vmsize, 0) + self.assertGreaterEqual(rss, 0) else: # @TODO(kgiusti) - update test to handle other platforms as support # is added - self.assertIsNone(mem) + self.assertIsNone(vmsize) + self.assertIsNone(rss) def test_ssl_connection(self): """Verify skmanage can securely connect via SSL""" diff --git a/tests/system_tests_skstat.py b/tests/system_tests_skstat.py index e8b00d86e..9c7894d0c 100644 --- a/tests/system_tests_skstat.py +++ b/tests/system_tests_skstat.py @@ -19,6 +19,7 @@ import os import re +import sys import unittest from subprocess import PIPE from proton import Url, SSLDomain, SSLUnavailable, SASL @@ -86,6 +87,12 @@ def test_general(self): out, flags=re.DOTALL) is not None, out) self.assertTrue(re.match(r"(.*)\bMode\b[ \t]+\bstandalone\b(.*)", out, flags=re.DOTALL) is not None, out) + if sys.platform.lower().startswith('linux'): + # process memory metrics currently only supported on linux + self.assertTrue(re.match(r"(.*)\bVmSize\b[ \t]+\b[0-9]+\b(.*)", + out, flags=re.DOTALL) is not None, out) + self.assertTrue(re.match(r"(.*)\bRSS\b[ \t]+\b[0-9]+\b(.*)", + out, flags=re.DOTALL) is not None, out) self.assertEqual(out.count("QDR.A"), 2) @@ -248,7 +255,12 @@ def test_memory(self): self.assertIn("QDR.A", out) self.assertIn("UTC", out) regexp = r'qdr_address_t\s+[0-9]+' - assert re.search(regexp, out, re.I), "Can't find '%s' in '%s'" % (regexp, out) + self.assertIsNotNone(re.search(regexp, out, re.I), + "Can't find '%s' in '%s'" % (regexp, out)) + if sys.platform.lower().startswith('linux'): + # process memory metrics currently only supported on linux + m_regexp = r"(.*)\bVmSize\b[ \t]+\bRSS\b[ \t]+\bPooled\b(.*)" + self.assertIsNotNone(re.match(m_regexp, out, flags=re.DOTALL), out) def test_memory_csv(self): out = self.run_skstat(['--memory', '--csv']) diff --git a/tools/skstat.in b/tools/skstat.in index 777e7b5ff..182e12e12 100755 --- a/tools/skstat.in +++ b/tools/skstat.in @@ -367,13 +367,13 @@ class BusManager: pass try: - if router.memoryUsage is not None: + if router_metrics.memoryUsage is not None: rows.append(('VmSize', NumKMG(router_metrics.memoryUsage, base=1024))) except Exception: pass try: - if router.residentMemoryUsage is not None: + if router_metrics.residentMemoryUsage is not None: rows.append(('RSS', NumKMG(router_metrics.residentMemoryUsage, base=1024))) except Exception: @@ -744,13 +744,14 @@ class BusManager: # attempt to get the qdrouterd process memory usage # this may not be present on all platforms - router = self.query('io.skupper.router.router')[0] + router_metrics = self.query('io.skupper.router.routerMetrics')[0] + try: - vm_size = router.memoryUsage + vm_size = router_metrics.memoryUsage except AttributeError: vm_size = None try: - rss_size = router.residentMemoryUsage + rss_size = router_metrics.residentMemoryUsage except AttributeError: rss_size = None