Skip to content

Commit

Permalink
Merge pull request #563 from vveliev/develop
Browse files Browse the repository at this point in the history
adding support for relative file path for ammo file
  • Loading branch information
nettorta committed Apr 18, 2018
2 parents 0c3e0f1 + 76bf9ce commit f9cb66d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'psutil>=1.2.1', 'requests>=2.5.1', 'paramiko>=1.16.0',
'pandas>=0.18.0', 'numpy>=1.12.1', 'future>=0.16.0',
'pip>=8.1.2',
'pyyaml>=3.12', 'cerberus>=1.1', 'influxdb>=5.0.0',
'pyyaml>=3.12', 'cerberus==1.1', 'influxdb>=5.0.0',
'netort>=0.0.11'
],
setup_requires=[
Expand Down
15 changes: 8 additions & 7 deletions yandextank/plugins/ShellExec/plugin.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'''
Contains shellexec plugin
'''
from ...common import util
from netort.process import execute
from ...common.interfaces import AbstractPlugin


class Plugin(AbstractPlugin):
'''
"""
ShellExec plugin
allows executing shell scripts before/after test
'''
"""
SECTION = 'shellexec'

def __init__(self, core, cfg, cfg_updater):
Expand Down Expand Up @@ -47,7 +47,7 @@ def start_test(self):
def is_test_finished(self):
if self.poll:
self.log.info("Executing: %s", self.poll)
retcode = util.execute(
retcode = execute(
self.poll,
shell=True,
poll_period=0.1,
Expand All @@ -69,11 +69,12 @@ def post_process(self, retcode):
return retcode

def execute(self, cmd):
'''
"""
Execute and check exit code
'''
"""
self.log.info("Executing: %s", cmd)
retcode = util.execute(
retcode = execute(
cmd, shell=True, poll_period=0.1, catch_out=self.catch_out)[0]
if retcode:
raise RuntimeError("Subprocess returned %s" % retcode)
return retcode
14 changes: 14 additions & 0 deletions yandextank/plugins/ShellExec/tests/test_shellexec_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest
from yandextank.plugins.ShellExec import Plugin


def test_plugin_execute():
plugin = Plugin(None, {}, None)
assert plugin.execute('echo foo') == 0


def test_plugin_execute_raises():
plugin = Plugin(None, {}, None)
with pytest.raises(RuntimeError) as error:
plugin.execute('echo "foo')
assert 'Subprocess returned 2' in error.message
2 changes: 1 addition & 1 deletion yandextank/stepper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def read_config(self):
self.ammo_file = self.get_option(self.OPTION_AMMOFILE)
self.ammo_type = self.get_option('ammo_type')
if self.ammo_file:
self.ammo_file = os.path.expanduser(self.ammo_file)
self.ammo_file = os.path.abspath(os.path.expanduser(self.ammo_file))
self.loop_limit = self.get_option(self.OPTION_LOOP)
self.ammo_limit = self.get_option("ammo_limit")

Expand Down

0 comments on commit f9cb66d

Please sign in to comment.