mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-08 11:13:51 +00:00
start BFG integration with stepper
This commit is contained in:
parent
c0925b2006
commit
69c2a6782e
@ -2,7 +2,9 @@
|
||||
from Tank.Plugins.Aggregator import AggregatorPlugin
|
||||
from Tank.Plugins.ConsoleOnline import ConsoleOnlinePlugin
|
||||
from tankcore import AbstractPlugin
|
||||
import logging
|
||||
import time
|
||||
from Tank.stepper import Stepper
|
||||
|
||||
|
||||
class BFGPlugin(AbstractPlugin):
|
||||
@ -11,23 +13,38 @@ class BFGPlugin(AbstractPlugin):
|
||||
SECTION = 'bfg'
|
||||
|
||||
def __init__(self, core):
|
||||
self.log = logging.getLogger(__name__)
|
||||
AbstractPlugin.__init__(self, core)
|
||||
self.gun_type = None
|
||||
self.start_time = time.time()
|
||||
self.log.info("Initialized BFG")
|
||||
|
||||
@staticmethod
|
||||
def get_key():
|
||||
return __file__
|
||||
|
||||
def get_available_options(self):
|
||||
return ["gun_type", "load", "ammo_limit", "loop_limit", "instances"]
|
||||
return ["gun_type", "rps_schedule", "ammo_limit", "loop_limit", "instances", "ammo_file"]
|
||||
|
||||
def configure(self):
|
||||
self.gun_type = self.get_option("gun_type")
|
||||
self.load = self.get_option("load")
|
||||
self.ammo_limit = self.get_option("ammo_limit")
|
||||
self.loop_limit = self.get_option("loop_limit")
|
||||
self.instances = self.get_option("instances")
|
||||
# TODO: move this elsewhere
|
||||
def make_steps(schedule):
|
||||
steps = []
|
||||
for step in " ".join(schedule.split("\n")).split(')'):
|
||||
if step.strip():
|
||||
steps.append(step.strip() + ')')
|
||||
return steps
|
||||
self.conf = {
|
||||
'gun_type': self.get_option("gun_type"),
|
||||
'rps_schedule': make_steps(self.get_option("rps_schedule")),
|
||||
'ammo_limit': self.get_option("ammo_limit", '-1'),
|
||||
'loop_limit': self.get_option("loop_limit", '-1'),
|
||||
'instances': self.get_option("instances", '15'),
|
||||
'ammo_file': self.get_option("ammo_file", 'ammo'),
|
||||
}
|
||||
self.bfg = BFG(**self.conf)
|
||||
self.log.info("Configured BFG")
|
||||
|
||||
|
||||
def prepare_test(self):
|
||||
aggregator = None
|
||||
@ -54,24 +71,54 @@ class BFGPlugin(AbstractPlugin):
|
||||
# if aggregator:
|
||||
# aggregator.add_result_listener(widget)
|
||||
pass
|
||||
self.log.info("Prepared BFG")
|
||||
|
||||
def start_test(self):
|
||||
self.log.info("Starting BFG")
|
||||
# TODO: start BFG here
|
||||
self.start_time = time.time()
|
||||
# self.bfg = ...
|
||||
self.bfg.start()
|
||||
|
||||
def is_test_finished(self):
|
||||
retcode = -1 # check if test is finished
|
||||
if retcode != None:
|
||||
if self.bfg.running:
|
||||
return -1
|
||||
else:
|
||||
retcode = self.bfg.retcode
|
||||
self.log.info(
|
||||
"BFG finished with exit code: %s", retcode)
|
||||
return retcode
|
||||
else:
|
||||
return -1
|
||||
|
||||
def end_test(self, retcode):
|
||||
if self.bfg.running():
|
||||
if self.bfg.running:
|
||||
self.log.info("Terminating BFG")
|
||||
self.bfg.stop()
|
||||
return retcode
|
||||
|
||||
class BFG(object):
|
||||
def __init__(
|
||||
self,
|
||||
gun_type,
|
||||
rps_schedule,
|
||||
ammo_limit,
|
||||
loop_limit,
|
||||
instances,
|
||||
ammo_file,
|
||||
):
|
||||
self.gun_type = gun_type
|
||||
self.instances = int(instances)
|
||||
self.stepper = Stepper(
|
||||
rps_schedule=rps_schedule,
|
||||
ammo_file=ammo_file,
|
||||
loop_limit=loop_limit,
|
||||
ammo_limit=ammo_limit,
|
||||
ammo_type = gun_type,
|
||||
)
|
||||
self.running = False
|
||||
self.retcode = None
|
||||
|
||||
def start(self):
|
||||
self.running = True
|
||||
|
||||
def stop(self):
|
||||
self.running = False
|
||||
self.retcode = 0
|
||||
|
@ -19,6 +19,7 @@ class ComponentFactory():
|
||||
uris=None,
|
||||
headers=None,
|
||||
autocases=None,
|
||||
ammo_type='phantom'
|
||||
):
|
||||
self.rps_schedule = rps_schedule
|
||||
self.http_ver = http_ver
|
||||
|
Loading…
Reference in New Issue
Block a user