Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge from develop #795

Merged
merged 8 commits into from Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion yandextank/plugins/Pandora/config/schema.yaml
Expand Up @@ -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
Expand All @@ -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
Expand Down
30 changes: 29 additions & 1 deletion yandextank/plugins/Pandora/plugin.py
Expand Up @@ -2,6 +2,7 @@
import logging
import subprocess
import time
import os
from threading import Event

import yaml
Expand Down Expand Up @@ -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():
Expand All @@ -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
Expand All @@ -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'):
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions yandextank/plugins/Telegraf/client.py
Expand Up @@ -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")
Expand Down