mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
add tests
This commit is contained in:
1
tests/fixtures/generic/vmstat-extra-wide-streaming.json
vendored
Normal file
1
tests/fixtures/generic/vmstat-extra-wide-streaming.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"runnable_procs":0,"uninterruptible_sleeping_procs":0,"virtual_mem_used":0,"free_mem":2430264,"buffer_mem":1011084,"cache_mem":22658240,"inactive_mem":null,"active_mem":null,"swap_in":0,"swap_out":0,"blocks_in":4,"blocks_out":6,"interrupts":3,"context_switches":5,"user_time":3,"system_time":1,"idle_time":96,"io_wait_time":0,"stolen_time":0,"timestamp":null,"timezone":null}]
|
1
tests/fixtures/generic/vmstat-extra-wide.json
vendored
Normal file
1
tests/fixtures/generic/vmstat-extra-wide.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"runnable_procs":0,"uninterruptible_sleeping_procs":0,"virtual_mem_used":0,"free_mem":2430264,"buffer_mem":1011084,"cache_mem":22658240,"inactive_mem":null,"active_mem":null,"swap_in":0,"swap_out":0,"blocks_in":4,"blocks_out":6,"interrupts":3,"context_switches":5,"user_time":3,"system_time":1,"idle_time":96,"io_wait_time":0,"stolen_time":0,"timestamp":null,"timezone":null}]
|
4
tests/fixtures/generic/vmstat-extra-wide.out
vendored
Normal file
4
tests/fixtures/generic/vmstat-extra-wide.out
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
--procs-- -----------------------memory---------------------- ---swap-- -----io---- -system-- --------cpu--------
|
||||
r b swpd free buff cache si so bi bo in cs us sy id wa st
|
||||
0 0 0 2430264 1011084 22658240 0 0 4 6 3 5 3 1 96 0 0
|
||||
|
@ -40,6 +40,9 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/vmstat-1-long.out'), 'r', encoding='utf-8') as f:
|
||||
ubuntu_18_04_vmstat_1_long = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/vmstat-extra-wide.out'), 'r', encoding='utf-8') as f:
|
||||
generic_vmstat_extra_wide = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/vmstat.json'), 'r', encoding='utf-8') as f:
|
||||
centos_7_7_vmstat_json = json.loads(f.read())
|
||||
@ -65,6 +68,9 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/vmstat-1-long.json'), 'r', encoding='utf-8') as f:
|
||||
ubuntu_18_04_vmstat_1_long_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/vmstat-extra-wide.json'), 'r', encoding='utf-8') as f:
|
||||
generic_vmstat_extra_wide_json = json.loads(f.read())
|
||||
|
||||
|
||||
def test_vmstat_nodata(self):
|
||||
"""
|
||||
@ -120,6 +126,12 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.vmstat.parse(self.ubuntu_18_04_vmstat_1_long, quiet=True), self.ubuntu_18_04_vmstat_1_long_json)
|
||||
|
||||
def test_vmstat_extra_wide(self):
|
||||
"""
|
||||
Test 'vmstat -w' with wider output
|
||||
"""
|
||||
self.assertEqual(jc.parsers.vmstat.parse(self.generic_vmstat_extra_wide, quiet=True), self.generic_vmstat_extra_wide_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -45,6 +45,9 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/vmstat-1-long.out'), 'r', encoding='utf-8') as f:
|
||||
ubuntu_18_04_vmstat_1_long = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/vmstat-extra-wide.out'), 'r', encoding='utf-8') as f:
|
||||
generic_vmstat_extra_wide = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/vmstat-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
centos_7_7_vmstat_streaming_json = json.loads(f.read())
|
||||
@ -70,6 +73,9 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/vmstat-1-long-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
ubuntu_18_04_vmstat_1_long_streaming_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/vmstat-extra-wide-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
generic_vmstat_extra_wide_streaming_json = json.loads(f.read())
|
||||
|
||||
|
||||
def test_vmstat_s_nodata(self):
|
||||
"""
|
||||
@ -131,6 +137,12 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.vmstat_s.parse(self.ubuntu_18_04_vmstat_1_long.splitlines(), quiet=True)), self.ubuntu_18_04_vmstat_1_long_streaming_json)
|
||||
|
||||
def test_vmstat_extra_wide(self):
|
||||
"""
|
||||
Test 'vmstat -w' with extra wide output
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.vmstat_s.parse(self.generic_vmstat_extra_wide.splitlines(), quiet=True)), self.generic_vmstat_extra_wide_streaming_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user