Commit f0be8d52 authored by Jérome Perrin's avatar Jérome Perrin

tests: update monitor tests for python3

timing seems to be slightly different (I did not investigate much)
parent d4abf3ff
......@@ -68,11 +68,14 @@ class TestMonitorMemory(unittest.TestCase):
def testMonitorWithLittleMemoryLimit(self):
"""Test the monitor with limit of 10Mb. In This case the openoffice will be
stopped"""
stopped after some time"""
try:
self.monitor = MonitorMemory(openoffice, 2, 10)
self.monitor = MonitorMemory(openoffice, 1, 10)
self.monitor.start()
sleep(self.interval)
for _ in range(30):
sleep(1)
if not openoffice.status():
break
self.assertEqual(openoffice.status(), False)
finally:
self.monitor.terminate()
......@@ -99,11 +102,9 @@ class TestMonitorMemory(unittest.TestCase):
"""Test memory usage"""
self.monitor = MonitorMemory(openoffice, 2, 400)
openoffice.stop()
memory_usage_int = self.monitor.get_memory_usage()
self.assertEqual(memory_usage_int, 0)
memory_usage = self.monitor.get_memory_usage()
self.assertEqual(memory_usage, 0)
if not openoffice.status():
openoffice.start()
memory_usage_int = self.monitor.get_memory_usage()
self.assertIsInstance(memory_usage_int, int)
memory_usage = self.monitor.get_memory_usage()
self.assertIsInstance(memory_usage, int)
......@@ -61,13 +61,15 @@ class TestMonitorTimeout(unittest.TestCase):
try:
monitor_timeout = self._createMonitor(1)
monitor_timeout.start()
sleep(2)
sleep(5)
self.assertEqual(openoffice.status(), False)
openoffice.restart()
self.assertTrue(openoffice.status())
finally:
monitor_timeout.terminate()
openoffice.release()
try:
monitor_timeout.terminate()
finally:
openoffice.release()
def testStopOpenOfficeTwice(self):
"""Test the cases that is necessary start the monitors twice"""
......@@ -75,20 +77,22 @@ class TestMonitorTimeout(unittest.TestCase):
try:
monitor_timeout = self._createMonitor(1)
monitor_timeout.start()
sleep(2)
sleep(5)
self.assertEqual(openoffice.status(), False)
monitor_timeout.terminate()
openoffice.restart()
self.assertTrue(openoffice.status())
monitor_timeout = self._createMonitor(1)
monitor_timeout.start()
sleep(2)
sleep(5)
self.assertEqual(openoffice.status(), False)
monitor_timeout.terminate()
sleep(1)
self.assertEqual(monitor_timeout.is_alive(), False)
finally:
monitor_timeout.terminate()
openoffice.release()
try:
monitor_timeout.terminate()
finally:
openoffice.release()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment