2014-05-01 23:54:54 +00:00
#! /usr/bin/env python2
2013-03-22 14:18:15 +00:00
from Tank . ConsoleWorker import ConsoleTank , CompletionHelperOptionParser
2012-09-12 13:18:58 +00:00
from optparse import OptionParser
import logging
import os
import sys
import traceback
if __name__ == " __main__ " :
sys . path . append ( os . path . dirname ( __file__ ) )
parser = OptionParser ( )
parser . add_option ( ' -c ' , ' --config ' , action = ' append ' , help = " Path to INI file containing run options, multiple options accepted " )
2012-09-17 13:48:02 +00:00
parser . add_option ( ' -f ' , ' --fail-lock ' , action = ' store_true ' , dest = ' lock_fail ' , help = " Don ' t wait for lock to release, fail test instead " )
2014-06-10 14:47:35 +00:00
parser . add_option ( ' -i ' , ' --ignore-lock ' , action = ' store_true ' , dest = ' ignore_lock ' , help = " Ignore lock files from concurrent instances, has precedence before --lock-fail " )
parser . add_option ( ' -k ' , ' --lock-dir ' , action = ' store ' , dest = ' lock_dir ' , type = " string " , help = " Directory for lock file " )
2012-09-12 13:18:58 +00:00
parser . add_option ( ' -l ' , ' --log ' , action = ' store ' , default = " tank.log " , help = " Tank log file location " )
2012-10-01 11:23:59 +00:00
parser . add_option ( ' -m ' , ' --manual-start ' , action = ' store_true ' , dest = ' manual_start ' , help = " Wait for Enter key to start the test " )
2012-09-25 13:59:58 +00:00
parser . add_option ( ' -n ' , ' --no-rc ' , action = ' store_true ' , dest = ' no_rc ' , help = " Don ' t load config files from /etc/yandex-tank and ~/.yandex-tank " )
2012-09-12 13:18:58 +00:00
parser . add_option ( ' -o ' , ' --option ' , action = ' append ' , help = " Set config option, multiple options accepted, example: -o ' shellexec.start=pwd ' " )
parser . add_option ( ' -q ' , ' --quiet ' , action = ' store_true ' , help = " Less console output, only errors and warnings " )
2012-10-01 11:23:59 +00:00
parser . add_option ( ' -s ' , ' --scheduled-start ' , action = ' store ' , dest = ' scheduled_start ' , help = " Start test at specified time, format ' YYYY-MM-DD hh:mm:ss ' , date part is optional " )
2012-09-12 13:18:58 +00:00
parser . add_option ( ' -v ' , ' --verbose ' , action = ' store_true ' , help = " More console output, +debug messages " )
2013-03-22 13:55:13 +00:00
completion_helper = CompletionHelperOptionParser ( )
completion_helper . handle_request ( parser )
2014-06-10 14:47:35 +00:00
2012-09-12 13:18:58 +00:00
options , ammofile = parser . parse_args ( )
2012-09-12 15:55:59 +00:00
worker = ConsoleTank ( options , ammofile )
2012-09-12 13:18:58 +00:00
worker . init_logging ( )
2014-06-10 14:47:35 +00:00
try :
2012-09-12 13:18:58 +00:00
worker . configure ( )
2012-09-12 15:55:59 +00:00
rc = worker . perform_test ( )
2012-09-12 13:18:58 +00:00
exit ( rc )
except Exception , ex :
logging . error ( " Exception: %s " , ex )
logging . debug ( " Exception: %s " , traceback . format_exc ( ex ) )
exit ( 1 )
2014-06-10 14:47:35 +00:00