yandex-tank/yandextank/plugins/RCAssert.py

39 lines
1.2 KiB
Python
Raw Normal View History

2013-03-28 09:14:40 +00:00
''' Tank exit code check plugin '''
2015-02-02 17:24:32 +00:00
from yandextank.core import AbstractPlugin
2013-03-28 09:14:40 +00:00
class RCAssertPlugin(AbstractPlugin):
''' Apache Benchmark plugin '''
SECTION = 'rcassert'
2015-02-02 17:24:32 +00:00
2013-03-28 09:14:40 +00:00
def __init__(self, core):
AbstractPlugin.__init__(self, core)
self.ok_codes = []
self.fail_code = 10
@staticmethod
def get_key():
return __file__
2015-02-02 17:24:32 +00:00
2013-03-28 09:14:40 +00:00
def get_available_options(self):
return ["pass", "fail_code"]
2015-02-02 17:24:32 +00:00
2013-03-28 09:14:40 +00:00
def configure(self):
2013-09-06 15:58:52 +00:00
codes = self.get_option("pass", '').split(' ')
2013-03-28 09:14:40 +00:00
for code in codes:
if code:
self.ok_codes.append(int(code))
self.fail_code = int(self.get_option("fail_code", self.fail_code))
def post_process(self, retcode):
if not self.ok_codes:
return retcode
2015-02-02 17:24:32 +00:00
2013-03-28 09:14:40 +00:00
for code in self.ok_codes:
self.log.debug("Comparing %s with %s codes", code, retcode)
if code == int(retcode):
self.log.info("Exit code %s was changed to 0 by RCAssert plugin", code)
return 0
2015-02-02 17:24:32 +00:00
2013-03-28 09:14:40 +00:00
self.log.info("Changing exit code to %s because RCAssert pass list was unsatisfied", self.fail_code)
return self.fail_code