Example #1
0
 def test_target_hint(self):
     """ test target hint (special address=[target] option) """
     manager = ConfigManager()
     configs = manager.getconfig(
         'yandextank/plugins/Telegraf/tests/target_hint.xml',
         'somehost.yandex.tld')
     assert (configs[0]['host'] == 'somehost.yandex.tld')
 def test_target_hint(self):
     """ test target hint (special address=[target] option) """
     manager = ConfigManager()
     configs = manager.getconfig(
         'yandextank/plugins/Telegraf/tests/target_hint.xml',
         'somehost.yandex.tld')
     assert (configs[0]['host'] == 'somehost.yandex.tld')
Example #3
0
 def test_xml_old_parse(self):
     """ old-style monitoring xml parse """
     manager = ConfigManager()
     configs = manager.getconfig(
         'yandextank/plugins/Telegraf/tests/old_mon.xml', 'sometargethint')
     assert (configs[0]['host'] == 'somehost.yandex.tld'
             and configs[0]['host_config']['CPU']['name'] == '[inputs.cpu]')
Example #4
0
 def test_xml_telegraf_parse(self):
     """ telegraf-style monitoring xml parse """
     manager = ConfigManager()
     configs = manager.getconfig(os.path.join(PATH, 'telegraf_mon.xml'),
                                 'sometargethint')
     assert (configs[0]['host'] == 'somehost.yandex.tld'
             and configs[0]['host_config']['CPU']['name'] == '[inputs.cpu]')
Example #5
0
 def test_target_hint(self):
     """ test target hint (special address=[target] option) """
     manager = ConfigManager()
     configs = manager.getconfig(
         os.path.join(PATH, 'target_hint.xml'),
         'somehost.yandex.tld')
     assert (configs[0]['host'] == 'somehost.yandex.tld')
Example #6
0
 def test_xml_old_parse(self):
     """ old-style monitoring xml parse """
     manager = ConfigManager()
     configs = manager.getconfig(
         'yandextank/plugins/Telegraf/tests/old_mon.xml', 'sometargethint')
     assert (
         configs[0]['host'] == 'somehost.yandex.tld' and
         configs[0]['host_config']['CPU']['name'] == '[inputs.cpu]')
Example #7
0
 def test_create_custom_exec_script(self):
     """ test agent config creates custom_exec config """
     manager = ConfigManager()
     telegraf_configs = manager.getconfig(
         os.path.join(PATH, 'telegraf_mon.xml'), 'sometargethint')
     agent_config = AgentConfig(telegraf_configs[0], False)
     custom_exec_config = agent_config.create_custom_exec_script()
     with open(custom_exec_config, 'r') as custom_fname:
         data = custom_fname.read()
     assert (data.find("-0) curl -s 'http://localhost:6100/stat'") != -1)
Example #8
0
 def test_create_startup_configs(self):
     """ test agent config creates startup config """
     manager = ConfigManager()
     telegraf_configs = manager.getconfig(
         os.path.join(PATH, 'telegraf_mon.xml'), 'sometargethint')
     agent_config = AgentConfig(telegraf_configs[0], False)
     startup = agent_config.create_startup_config()
     cfg_parser = RawConfigParser(strict=False)
     cfg_parser.read(startup)
     assert cfg_parser.has_section('startup')
 def test_create_startup_configs(self):
     """ test agent config creates startup config """
     manager = ConfigManager()
     telegraf_configs = manager.getconfig(
         'yandextank/plugins/Telegraf/tests/telegraf_mon.xml',
         'sometargethint')
     agent_config = AgentConfig(telegraf_configs[0], False)
     startup = agent_config.create_startup_config()
     cfg_parser = ConfigParser()
     cfg_parser.read(startup)
     assert cfg_parser.has_section('startup')
Example #10
0
 def test_create_custom_exec_script(self):
     """ test agent config creates custom_exec config """
     manager = ConfigManager()
     telegraf_configs = manager.getconfig(
         'yandextank/plugins/Telegraf/tests/telegraf_mon.xml',
         'sometargethint')
     agent_config = AgentConfig(telegraf_configs[0], False)
     custom_exec_config = agent_config.create_custom_exec_script()
     with open(custom_exec_config, 'r') as custom_fname:
         data = custom_fname.read()
     assert (data.find("-0) curl -s 'http://localhost:6100/stat'") != -1)
Example #11
0
 def test_create_startup_configs(self):
     """ test agent config creates startup config """
     manager = ConfigManager()
     telegraf_configs = manager.getconfig(
         'yandextank/plugins/Telegraf/tests/telegraf_mon.xml',
         'sometargethint')
     agent_config = AgentConfig(telegraf_configs[0], False)
     startup = agent_config.create_startup_config()
     cfg_parser = ConfigParser()
     cfg_parser.read(startup)
     assert cfg_parser.has_section('startup')
 def test_rawxml_parse(self):
     """ raw xml read from string """
     manager = ConfigManager()
     config = """
     <Monitoring>
         <Host>
             <CPU feature="passed"/>
         </Host>
     </Monitoring>
     """
     etree = manager.parse_xml(config)
     host = etree.findall('Host')[0]
     assert (host[0].tag == 'CPU')
Example #13
0
 def test_rawxml_parse(self):
     """ raw xml read from string """
     manager = ConfigManager()
     config = """
     <Monitoring>
         <Host>
             <CPU feature="passed"/>
         </Host>
     </Monitoring>
     """
     etree = manager.parse_xml(config)
     host = etree.findall('Host')[0]
     assert (host[0].tag == 'CPU')
Example #14
0
 def test_create_collector_configs(self):
     """ test agent config creates collector config """
     manager = ConfigManager()
     telegraf_configs = manager.getconfig(
         os.path.join(PATH, 'telegraf_mon.xml'), 'sometargethint')
     agent_config = AgentConfig(telegraf_configs[0], False)
     remote_workdir = '/path/to/workdir/temp'
     collector_config = agent_config.create_collector_config(remote_workdir)
     cfg_parser = RawConfigParser(strict=False)
     cfg_parser.read(collector_config)
     assert (cfg_parser.has_section('agent')
             and cfg_parser.get('agent', 'interval') == "'1s'"
             and cfg_parser.has_section('[outputs.file')
             and cfg_parser.get('[outputs.file', 'files')
             == "['{rmt}/monitoring.rawdata']".format(rmt=remote_workdir))
Example #15
0
 def test_create_collector_configs(self):
     """ test agent config creates collector config """
     manager = ConfigManager()
     telegraf_configs = manager.getconfig(
         'yandextank/plugins/Telegraf/tests/telegraf_mon.xml',
         'sometargethint')
     agent_config = AgentConfig(telegraf_configs[0], False)
     remote_workdir = '/path/to/workdir/temp'
     collector_config = agent_config.create_collector_config(remote_workdir)
     cfg_parser = ConfigParser()
     cfg_parser.read(collector_config)
     assert (
         cfg_parser.has_section('agent') and
         cfg_parser.get('agent', 'interval') == "'1s'" and
         cfg_parser.has_section('[outputs.file') and
         cfg_parser.get('[outputs.file', 'files') ==
         "['{rmt}/monitoring.rawdata']".format(rmt=remote_workdir))