mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-08 03:08:56 +00:00
Allow inline monitoring config
This commit is contained in:
parent
81dedafd04
commit
bb7dc4b3dd
@ -1,7 +1,7 @@
|
||||
'''Module to provide target monitoring'''
|
||||
|
||||
from Tank.MonCollector.collector import MonitoringCollector, \
|
||||
MonitoringDataListener, MonitoringDataDecoder
|
||||
MonitoringDataListener, MonitoringDataDecoder, Config
|
||||
from Tank.Plugins.ConsoleOnline import ConsoleOnlinePlugin, AbstractInfoWidget
|
||||
from Tank.Plugins.Phantom import PhantomPlugin
|
||||
from tankcore import AbstractPlugin
|
||||
@ -11,6 +11,7 @@ import traceback
|
||||
from Tank.Plugins.Autostop import AutostopPlugin, AbstractCriteria
|
||||
import tankcore
|
||||
import fnmatch
|
||||
from lxml import etree
|
||||
|
||||
class MonitoringPlugin(AbstractPlugin):
|
||||
'''
|
||||
@ -35,13 +36,21 @@ class MonitoringPlugin(AbstractPlugin):
|
||||
return __file__
|
||||
|
||||
def configure(self):
|
||||
self.config = self.get_option("config", 'auto')
|
||||
self.config = self.get_option("config", 'auto').strip()
|
||||
self.default_target = self.get_option("default_target", 'localhost')
|
||||
self.monitoring.ssh_timeout=tankcore.expand_to_seconds(self.get_option('ssh_timeout', "5s"))
|
||||
self.monitoring.ssh_timeout = tankcore.expand_to_seconds(self.get_option('ssh_timeout', "5s"))
|
||||
|
||||
if self.config == 'none' or self.config == 'auto':
|
||||
self.die_on_fail = False
|
||||
else:
|
||||
if self.config[0] == '<':
|
||||
xmlfile = self.core.mkstemp(".xml", "monitoring_")
|
||||
self.core.add_artifact_file(xmlfile)
|
||||
xml=open(xmlfile, 'w')
|
||||
xml.write(self.config)
|
||||
xml.close()
|
||||
self.config=xmlfile
|
||||
|
||||
if not os.path.exists(self.config):
|
||||
raise OSError("Monitoring config file not found: %s" % self.config)
|
||||
|
||||
|
@ -74,6 +74,26 @@ class MonitoringCollectorTestCase(TankTestCase):
|
||||
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
|
||||
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_widget(self):
|
||||
core = self.get_core()
|
||||
|
Loading…
Reference in New Issue
Block a user