Mei Liu has uploaded a new change for review. Change subject: Add test for loading policy when mom start ups with require keyword in policy ......................................................................
Add test for loading policy when mom start ups with require keyword in policy This test targets the scenario that policy which contains require key is set in config and loaded at mom starts up. Test checks if the required collectors are in place. Change-Id: I5003ccd33c7382b6f283999f822e4e60199dce1c Signed-off-by: MeiLiu <[email protected]> --- M tests/GeneralTests.py 1 file changed, 43 insertions(+), 16 deletions(-) git pull ssh://gerrit.ovirt.org:29418/mom refs/changes/76/15476/1 diff --git a/tests/GeneralTests.py b/tests/GeneralTests.py index f17c499..6b0e333 100644 --- a/tests/GeneralTests.py +++ b/tests/GeneralTests.py @@ -128,8 +128,8 @@ config = get_base_config() config.set('main', 'host-monitor-interval', '1') config.set('host', 'collectors', 'HostMemory') - mom_instance = start_mom(config) - stats = mom_instance.getStatistics() + self.mom_instance = start_mom(config) + stats = self.mom_instance.getStatistics() self.assertTrue('mem_available' in stats['host']) self.assertFalse('ksm_run' in stats['host']) @@ -146,16 +146,16 @@ time.sleep(1) self.assertTrue(monitor.collectors is None) - def testReloadStress(self): - def wait_for_stats(): - for i in xrange(0, 5): - stats = mom_instance.getStatistics() - if stats['host'] is None: - time.sleep(1) - else: - return stats - self.fail("Timeout when waiting for stats") + def _wait_for_stats(self): + for i in xrange(0, 5): + stats = self.mom_instance.getStatistics() + if stats['host'] is None: + time.sleep(1) + else: + return stats + self.fail("Timeout when waiting for stats") + def testReloadStress(self): config = get_base_config() config.set('main', 'host-monitor-interval', '1') config.set('host', 'collectors', '') @@ -170,17 +170,44 @@ (require "Controller" "KSM" ()) """ - mom_instance = start_mom(config) + self.mom_instance = start_mom(config) for i in xrange(0, 10): - self.assertTrue(mom_instance.setPolicy(pol1)) - stats = wait_for_stats() + self.assertTrue(self.mom_instance.setPolicy(pol1)) + stats = self._wait_for_stats() print stats['host'] self.assertTrue('mem_available' in stats['host']) self.assertFalse('ksm_run' in stats['host']) - self.assertTrue(mom_instance.setPolicy(pol2)) - stats = wait_for_stats() + self.assertTrue(self.mom_instance.setPolicy(pol2)) + stats = self._wait_for_stats() print stats['host'] self.assertFalse('mem_available' in stats['host']) self.assertTrue('ksm_run' in stats['host']) + + def testLoadPolicy(self): + pol = """ + (require "Collector" "HostMemory" ()) + (require "Collector" "HostKSM" ()) + (require "Controller" "KSM" ()) + """ + + config = get_base_config() + config.set('main', 'host-monitor-interval', '1') + config.set('host', 'collectors', '') + config.set('main', 'controllers', '') + + fd, path = tempfile.mkstemp() + f = os.fdopen(fd, "w") + f.write(pol) + f.flush() + f.close() + config.set('main', 'policy', path) + + self.mom_instance = start_mom(config) + try: + stats = self._wait_for_stats() + self.assertTrue('mem_available' in stats['host']) + self.assertTrue('ksm_run' in stats['host']) + finally: + os.remove(path) -- To view, visit http://gerrit.ovirt.org/15476 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5003ccd33c7382b6f283999f822e4e60199dce1c Gerrit-PatchSet: 1 Gerrit-Project: mom Gerrit-Branch: master Gerrit-Owner: Mei Liu <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
