Skip to content

Commit

Permalink
Merge pull request #679 from yandex/hotfix_1.11.0
Browse files Browse the repository at this point in the history
Hotfix 1.11.0
  • Loading branch information
fomars committed Nov 16, 2018
2 parents 86a566c + a8d0c81 commit 480af83
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='yandextank',
version='1.11.0',
version='1.11.0.1',
description='a performance measurement tool',
longer_description='''
Yandex.Tank is a performance measurement and load testing automatization tool.
Expand Down
2 changes: 1 addition & 1 deletion yandextank/common/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_key():
def __init__(self, core, cfg):
"""
@type core: TankCore
:type core: TankCore
"""
super(AbstractPlugin, self).__init__()
self._cleanup_actions = []
Expand Down
21 changes: 6 additions & 15 deletions yandextank/core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def main():

ammofile = ammofiles[0] if len(ammofiles) > 0 else None

log_handlers = init_logging(options.error_log, options.verbose, options.quiet)
init_logging(options.error_log, options.verbose, options.quiet)

cli_kwargs = {'core': {'lock_dir': options.lock_dir}} if options.lock_dir else {}
if options.ignore_lock:
Expand All @@ -127,7 +127,7 @@ def main():
[cli_kwargs],
options.no_rc,
ammo_file=ammofile if ammofile else None,
log_handlers=log_handlers)
)
except ValidationError as e:
logging.error('Config validation error:\n{}'.format(e.errors))
return
Expand All @@ -137,21 +137,12 @@ def main():
except KeyboardInterrupt:
worker.stop()
worker.join()
# try:
# worker.configure()
# rc = worker.perform_test()
# sys.exit(rc)
# except Exception as ex:
# worker.core._collect_artifacts()
# logging.error("Exception: %s", ex)
# logging.debug("Exception: %s", traceback.format_exc(ex))
# sys.exit(1)


def init_logging(events_log_fname, verbose, quiet):
""" Set up logging, as it is very important for console tool """
# logger = logging.getLogger('')
# logger.setLevel(logging.DEBUG)
logger = logging.getLogger('')
logger.setLevel(logging.DEBUG)

# create file handler which logs error messages

Expand Down Expand Up @@ -184,13 +175,13 @@ def init_logging(events_log_fname, verbose, quiet):
console_handler.addFilter(f_err)
console_handler.addFilter(f_warn)
console_handler.addFilter(f_crit)
# logger.addHandler(console_handler)
logger.addHandler(console_handler)

f_info = SingleLevelFilter(logging.INFO, True)
f_debug = SingleLevelFilter(logging.DEBUG, True)
stderr_hdl.addFilter(f_info)
stderr_hdl.addFilter(f_debug)
# logger.addHandler(stderr_hdl)
logger.addHandler(stderr_hdl)

if events_log_fname:
err_file_handler = logging.FileHandler(events_log_fname)
Expand Down
38 changes: 20 additions & 18 deletions yandextank/core/consoleworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ..config_converter.converter import convert_ini, convert_single_option

DEFAULT_CONFIG = 'load.yaml'
logger = logging.getLogger('yandextank')


class RealConsoleMarkup(object):
Expand Down Expand Up @@ -159,7 +160,7 @@ def get_default_configs():
baseconfigs_location + os.sep + filename)
]
except OSError:
logging.info(
logger.info(
baseconfigs_location + ' is not accessible to get configs list')

configs += [os.path.expanduser('~/.yandex-tank')]
Expand Down Expand Up @@ -264,15 +265,15 @@ def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type:
msg = 'Exception occurred:\n{}: {}\n{}'.format(exc_type, exc_val, '\n'.join(traceback.format_tb(exc_tb)))
msgs.append(msg)
logging.error(msg)
logging.info('Trying to clean up')
logger.error(msg)
logger.info('Trying to clean up')
for name, action in reversed(self._actions):
try:
action()
except Exception:
msg = 'Exception occurred during cleanup action {}'.format(name)
msgs.append(msg)
logging.error(msg, exc_info=True)
logger.error(msg, exc_info=True)
self.tankworker.save_status('\n'.join(msgs))
self.tankworker.core._collect_artifacts()
return False # re-raise exception
Expand All @@ -292,7 +293,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
self.worker.status = Status.TEST_FINISHING
retcode = 0
if exc_type:
logging.error('Test interrupted:\n{}: {}\n{}'.format(exc_type, exc_val, exc_tb))
logger.error('Test interrupted:\n{}: {}\n{}'.format(exc_type, exc_val, exc_tb))
retcode = 1
retcode = self.worker.core.plugins_end_test(retcode)
self.worker.retcode = retcode
Expand All @@ -314,8 +315,9 @@ class TankWorker(Thread):
FINISH_FILENAME = 'finish_status.yaml'

def __init__(self, configs, cli_options=None, cfg_patches=None, cli_args=None, no_local=False,
log_handlers=None, wait_lock=True, files=None, ammo_file=None):
log_handlers=None, wait_lock=True, files=None, ammo_file=None, api_start=False):
super(TankWorker, self).__init__()
self.api_start = api_start
self.wait_lock = wait_lock
self.log_handlers = log_handlers if log_handlers is not None else []
self.files = [] if files is None else files
Expand Down Expand Up @@ -354,19 +356,20 @@ def _combine_configs(run_cfgs, cli_options=None, cfg_patches=None, cli_args=None

def init_folder(self):
self.folder = self.core.artifacts_dir
for f in self.files:
shutil.move(f, self.folder)
if self.ammo_file:
shutil.move(self.ammo_file, self.folder)
# os.chdir(self.folder)
if self.api_start > 0:
for f in self.files:
shutil.move(f, self.folder)
if self.ammo_file:
shutil.move(self.ammo_file, self.folder)
os.chdir(self.folder)

def run(self):
with Cleanup(self) as add_cleanup:
lock = self.get_lock()
add_cleanup('release lock', lock.release)
self.status = Status.TEST_PREPARING
self.init_logging(debug=True)
logging.info('Created a folder for the test. %s' % self.folder)
logger.info('Created a folder for the test. %s' % self.folder)

self.core.plugins_configure()
add_cleanup('plugins cleanup', self.core.plugins_cleanup)
Expand Down Expand Up @@ -400,14 +403,14 @@ def get_lunapark_jobno(self):
try:
return str(self.core.status['uploader']['job_no'])
except KeyError:
logging.warning('Job number is not available yet')
logger.warning('Job number is not available yet')
return None

def get_lunapark_link(self):
try:
return str(self.core.status['uploader']['web_link'])
except KeyError:
logging.warning('Job number is not available yet')
logger.warning('Job number is not available yet')
return None

def init_logging(self, debug=False):
Expand All @@ -417,7 +420,6 @@ def init_logging(self, debug=False):
current_file_mode = os.stat(filename).st_mode
os.chmod(filename, current_file_mode | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)

logger = logging.getLogger()
logger.handlers = []
logger.setLevel(logging.DEBUG if debug else logging.INFO)

Expand All @@ -426,11 +428,11 @@ def init_logging(self, debug=False):
self.file_handler.setFormatter(logging.Formatter(
"%(asctime)s [%(levelname)s] %(name)s %(filename)s:%(lineno)d\t%(message)s"))
logger.addHandler(self.file_handler)
logging.info("Log file created")
logger.info("Log file created")

for handler in self.log_handlers:
logger.addHandler(handler)
logging.info("Logging handler {} added".format(handler))
logger.info("Logging handler {} added".format(handler))

def get_lock(self):
while True:
Expand All @@ -442,7 +444,7 @@ def get_lock(self):
self.set_msg(e.message)
if not self.wait_lock:
raise RuntimeError("Lock file present, cannot continue")
logging.warning(
logger.warning(
"Couldn't get lock. Will retry in 5 seconds...")
time.sleep(5)
return lock
Expand Down

0 comments on commit 480af83

Please sign in to comment.