diff --git a/setup.py b/setup.py index e02528958..3b1785239 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='yandextank', - version='1.12.5', + version='1.12.5.1', description='a performance measurement tool', longer_description=''' Yandex.Tank is a performance measurement and load testing automatization tool. diff --git a/yandextank/plugins/Pandora/config/schema.yaml b/yandextank/plugins/Pandora/config/schema.yaml index 3a32d0e2c..d9a0012f9 100644 --- a/yandextank/plugins/Pandora/config/schema.yaml +++ b/yandextank/plugins/Pandora/config/schema.yaml @@ -6,7 +6,7 @@ affinity: pandora_cmd: type: string default: pandora - description: Pandora executable path + description: Pandora executable path or link to it buffered_seconds: type: integer default: 2 @@ -21,6 +21,13 @@ config_file: expvar: type: boolean default: false +resources: + default: [] + type: list + description: additional resources you need to download before test +resource: + type: dict + description: dict with attributes for additional resources report_file: type: string nullable: true diff --git a/yandextank/plugins/Pandora/plugin.py b/yandextank/plugins/Pandora/plugin.py index 8abfbe75e..cdf57e15c 100644 --- a/yandextank/plugins/Pandora/plugin.py +++ b/yandextank/plugins/Pandora/plugin.py @@ -2,6 +2,7 @@ import logging import subprocess import time +import os from threading import Event import yaml @@ -43,6 +44,7 @@ def __init__(self, core, cfg, name): self.__schedule = None self.ammofile = None self.process_stderr_file = None + self.resources = [] @staticmethod def get_key(): @@ -56,10 +58,13 @@ def get_available_options(self): return opts def configure(self): - self.pandora_cmd = self.get_option("pandora_cmd") self.report_file = self.get_option("report_file") self.buffered_seconds = self.get_option("buffered_seconds") self.affinity = self.get_option("affinity", "") + self.resources = self.get_option("resources") + + # if we use custom pandora binary, we can download it and make it executable + self.pandora_cmd = self.get_resource(self.get_option("pandora_cmd"), "./pandora", permissions=0755) # get config_contents and patch it: expand resources via resource manager # config_content option has more priority over config_file @@ -75,6 +80,11 @@ def configure(self): raise RuntimeError("Neither pandora.config_content, nor pandora.config_file specified") logger.debug('Config after parsing for patching: %s', self.config_contents) + # download all resources from self.get_options("resources") + if len(self.resources) > 0: + for resource in self.resources: + self.get_resource(resource["src"], resource["dst"]) + # find report filename and add to artifacts self.report_file = self.__find_report_filename() with open(self.report_file, 'w'): @@ -186,6 +196,24 @@ def get_stats_reader(self): self.stats_reader = PandoraStatsReader(self.expvar_enabled, self.expvar_port) return self.stats_reader + def get_resource(self, resource, dst, permissions=0644): + opener = resource_manager.get_opener(resource) + if isinstance(opener, HttpOpener): + tmp_path = opener.download_file(True, try_ungzip=True) + try: + os.rename(tmp_path, dst) + logger.info('Successfully moved resource %s', dst) + except OSError as ex: + logger.debug("Could not move resource %s\n%s", dst, ex) + else: + dst = opener.get_filename + try: + os.chmod(dst, permissions) + logger.info('Permissions on %s have changed %d', dst, permissions) + except OSError as ex: + logger.debug("Could not chane pepermissions on %s\n%s", dst, ex) + return dst + def prepare_test(self): try: console = self.core.get_plugin_of_type(ConsolePlugin) diff --git a/yandextank/plugins/Telegraf/client.py b/yandextank/plugins/Telegraf/client.py index b4ca92502..aa5a0b310 100644 --- a/yandextank/plugins/Telegraf/client.py +++ b/yandextank/plugins/Telegraf/client.py @@ -138,13 +138,16 @@ def read_buffer(self): 'otherwise something really nasty happend', exc_info=True) + def _stop_agent(self): + if self.session: + self.session.terminate() + logger.info('Waiting localhost agent to terminate...') + def uninstall(self): """ Remove agent's files from remote host """ if self.session: - logger.info('Waiting monitoring data...') - self.session.terminate() self.session.wait() self.session = None log_filename = "agent_{host}.log".format(host="localhost")