Skip to content

Commit

Permalink
fixup: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kgiusti committed Nov 18, 2024
1 parent 9f73340 commit f8a158f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
12 changes: 8 additions & 4 deletions tests/system_tests_skmanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
14 changes: 13 additions & 1 deletion tests/system_tests_skstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import os
import re
import sys
import unittest
from subprocess import PIPE
from proton import Url, SSLDomain, SSLUnavailable, SASL
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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'])
Expand Down

0 comments on commit f8a158f

Please sign in to comment.