def test_widget(self): core = self.get_core() core.artifacts_base_dir = tempfile.mkdtemp() owner = MonitoringPlugin(core) owner.monitoring = 1 widget = MonitoringWidget(owner) screen = Screen(50, FakeConsoleMarkup()) res = widget.render(screen) self.assertEquals("Monitoring is <g>online<rst>:", res) widget.monitoring_data( "start;127.0.0.1;1347631472;Memory_total;Memory_used;Memory_free;Memory_shared;Memory_buff;Memory_cached;Net_recv;Net_send;" ) res = widget.render(screen) widget.monitoring_data( "127.0.0.1;1347631473;1507.65625;576.9609375;8055;1518;0;143360;34.9775784753;16.1434977578;0.0" ) res = widget.render(screen) self.assertNotEquals("Monitoring is <g>online<rst>:", res) widget.monitoring_data( "127.0.0.1;1347631473;1506.65625;574.9609375;8055;1518;0;143360;34.9775784753;16.1434977578;0.0" ) res = widget.render(screen)
def test_widget(self): core = self.get_core() core.artifacts_base_dir = tempfile.mkdtemp() owner = MonitoringPlugin(core) owner.monitoring = 1 widget = MonitoringWidget(owner) screen = Screen(50, FakeConsoleMarkup()) res = widget.render(screen) self.assertEquals("Monitoring is <g>online<rst>:", res) widget.monitoring_data("start;127.0.0.1;1347631472;Memory_total;Memory_used;Memory_free;Memory_shared;Memory_buff;Memory_cached;Net_recv;Net_send;") res = widget.render(screen) widget.monitoring_data("127.0.0.1;1347631473;1507.65625;576.9609375;8055;1518;0;143360;34.9775784753;16.1434977578;0.0") res = widget.render(screen) self.assertNotEquals("Monitoring is <g>online<rst>:", res) widget.monitoring_data("127.0.0.1;1347631473;1506.65625;574.9609375;8055;1518;0;143360;34.9775784753;16.1434977578;0.0") res = widget.render(screen)
def test_plugin_config_with_username(self): core = self.get_core() core.artifacts_base_dir = tempfile.mkdtemp() core.load_configs(['config/monitoring.conf']) core.load_plugins() core.plugins_configure() core.plugins_prepare_test() mon = MonitoringPlugin(core) mon.monitoring.ssh_wrapper_class = SSHEmulator core.set_option(mon.SECTION, 'config', "config/mon-user.conf") mon.configure() mon.prepare_test() mon.start_test() self.assertEquals(-1, mon.is_test_finished()) self.assertNotEquals(None, mon.monitoring) time.sleep(1) self.assertEquals(-1, mon.is_test_finished()) mon.end_test(0) mon.post_process(0)
def test_plugin_disabled(self): core = self.get_core() core.artifacts_base_dir = tempfile.mkdtemp() mon = MonitoringPlugin(core) core.set_option(mon.SECTION, 'config', 'none') mon.configure() mon.prepare_test() mon.start_test() self.assertEquals(-1, mon.is_test_finished()) self.assertEquals(None, mon.monitoring) time.sleep(1) self.assertEquals(-1, mon.is_test_finished()) mon.end_test(0) mon.post_process(0)
def test_plugin_default_failedInstall(self): core = self.get_core() core.artifacts_base_dir = tempfile.mkdtemp() core.load_configs(['config/monitoring.conf']) core.load_plugins() core.plugins_configure() core.plugins_prepare_test() mon = MonitoringPlugin(core) mon.configure() mon.monitoring.ssh_wrapper_class = SSHEmulatorFailer mon.prepare_test() mon.start_test() self.assertEquals(-1, mon.is_test_finished()) self.assertEquals(None, mon.monitoring) time.sleep(1) self.assertEquals(-1, mon.is_test_finished()) mon.end_test(0) mon.post_process(0)
def test_plugin_inline_config(self): core = self.get_core() core.artifacts_base_dir = tempfile.mkdtemp() core.load_configs(['config/monitoring.conf']) core.load_plugins() core.plugins_configure() core.plugins_prepare_test() mon = MonitoringPlugin(core) mon.monitoring.ssh_wrapper_class = SSHEmulator # XXX: not working! core.set_option(mon.SECTION, 'config', "<Monitoring>\n<Host address='[target]'/>\n</Monitoring>") mon.configure() mon.prepare_test() mon.start_test() self.assertEquals(-1, mon.is_test_finished()) self.assertNotEquals(None, mon.monitoring) time.sleep(1) self.assertEquals(-1, mon.is_test_finished()) mon.end_test(0) mon.post_process(0)
def test_plugin_inline_config(self): core = self.get_core() core.artifacts_base_dir = tempfile.mkdtemp() core.load_configs(['config/monitoring.conf']) core.load_plugins() core.plugins_configure() core.plugins_prepare_test() mon = MonitoringPlugin(core) mon.monitoring.ssh_wrapper_class = SSHEmulator # XXX: not working! core.set_option( mon.SECTION, 'config', "<Monitoring>\n<Host address='[target]'/>\n</Monitoring>") mon.configure() mon.prepare_test() mon.start_test() self.assertEquals(-1, mon.is_test_finished()) self.assertNotEquals(None, mon.monitoring) time.sleep(1) self.assertEquals(-1, mon.is_test_finished()) mon.end_test(0) mon.post_process(0)