diff --git a/tests/fixtures/generic/vmstat-extra-wide-streaming.json b/tests/fixtures/generic/vmstat-extra-wide-streaming.json new file mode 100644 index 000000000..df97eae4e --- /dev/null +++ b/tests/fixtures/generic/vmstat-extra-wide-streaming.json @@ -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}] diff --git a/tests/fixtures/generic/vmstat-extra-wide.json b/tests/fixtures/generic/vmstat-extra-wide.json new file mode 100644 index 000000000..df97eae4e --- /dev/null +++ b/tests/fixtures/generic/vmstat-extra-wide.json @@ -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}] diff --git a/tests/fixtures/generic/vmstat-extra-wide.out b/tests/fixtures/generic/vmstat-extra-wide.out new file mode 100644 index 000000000..50cd622bd --- /dev/null +++ b/tests/fixtures/generic/vmstat-extra-wide.out @@ -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 + diff --git a/tests/test_vmstat.py b/tests/test_vmstat.py index 689adb10b..c82f288c8 100644 --- a/tests/test_vmstat.py +++ b/tests/test_vmstat.py @@ -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 @@ def test_vmstat_1_long(self): """ 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() diff --git a/tests/test_vmstat_s.py b/tests/test_vmstat_s.py index 01ed7a569..9f50d7a9f 100644 --- a/tests/test_vmstat_s.py +++ b/tests/test_vmstat_s.py @@ -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 @@ def test_vmstat_s_1_long_ubuntu_18_04(self): """ 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()