Add enum_ammo parameter

This commit is contained in:
Alexey Lavrenuke 2015-02-11 17:19:44 +03:00
parent 8447eb3d40
commit 47431ddd93
4 changed files with 22 additions and 5 deletions

View File

@ -33,6 +33,7 @@ class PhantomConfig:
self.phantom_modules_path = None self.phantom_modules_path = None
self.threads = None self.threads = None
self.additional_libs = None self.additional_libs = None
self.enum_ammo = False
def get_option(self, opt_name, default=None): def get_option(self, opt_name, default=None):
""" get option wrapper """ """ get option wrapper """
@ -41,7 +42,7 @@ class PhantomConfig:
@staticmethod @staticmethod
def get_available_options(): def get_available_options():
opts = ["threads", "phantom_modules_path", opts = ["threads", "phantom_modules_path",
"additional_libs", "writelog", ] "additional_libs", "writelog", "enum_ammo", ]
opts += StreamConfig.get_available_options() opts += StreamConfig.get_available_options()
return opts return opts

View File

@ -7,6 +7,7 @@ import subprocess
import sys import sys
import time import time
import datetime import datetime
import string
from yandextank.plugins import ConsoleScreen from yandextank.plugins import ConsoleScreen
from yandextank.plugins.Aggregator import \ from yandextank.plugins.Aggregator import \
@ -44,6 +45,8 @@ class PhantomPlugin(AbstractPlugin, AggregateResultListener):
self.cached_info = None self.cached_info = None
self.phantom_stderr = None self.phantom_stderr = None
self.enum_ammo = False
@staticmethod @staticmethod
def get_key(): def get_key():
return __file__ return __file__
@ -60,6 +63,7 @@ class PhantomPlugin(AbstractPlugin, AggregateResultListener):
self.eta_file = self.get_option("eta_file", '') self.eta_file = self.get_option("eta_file", '')
self.core.add_artifact_file(self.eta_file) self.core.add_artifact_file(self.eta_file)
self.phantom_path = self.get_option("phantom_path", 'phantom') self.phantom_path = self.get_option("phantom_path", 'phantom')
self.enum_ammo = self.get_option("enum_ammo", False)
self.buffered_seconds = int( self.buffered_seconds = int(
self.get_option("buffered_seconds", self.buffered_seconds)) self.get_option("buffered_seconds", self.buffered_seconds))
@ -383,6 +387,7 @@ class PhantomReader(AbstractReader):
self.last_sample_time = 0 self.last_sample_time = 0
self.read_lines_count = 0 self.read_lines_count = 0
self.buffered_seconds = 3 self.buffered_seconds = 3
self.enum_ammo = self.phantom.enum_ammo
def check_open_files(self): def check_open_files(self):
info = self.phantom.get_info() info = self.phantom.get_info()
@ -493,7 +498,10 @@ class PhantomReader(AbstractReader):
# bytes: sent received # bytes: sent received
# connect send latency receive # connect send latency receive
# accuracy # accuracy
data_item = (data[1], active, rt_real / 1000, data[11], data[10], marker = data[1]
if self.enum_ammo:
marker = string.rsplit(marker, "#", 1)[0]
data_item = (marker, active, rt_real / 1000, data[11], data[10],
int(data[8]), int(data[9]), int(data[8]), int(data[9]),
int(data[3]) / 1000, int(data[4]) / 1000, int(data[3]) / 1000, int(data[4]) / 1000,
int(data[5]) / 1000, int(data[6]) / 1000, int(data[5]) / 1000, int(data[6]) / 1000,

View File

@ -22,6 +22,7 @@ class ComponentFactory():
uris=None, uris=None,
headers=None, headers=None,
autocases=None, autocases=None,
enum_ammo=False,
ammo_type='phantom', ammo_type='phantom',
chosen_cases=[], chosen_cases=[],
): ):
@ -47,7 +48,7 @@ class ComponentFactory():
if self.uris and loop_limit: if self.uris and loop_limit:
info.status.ammo_limit = len(self.uris) * loop_limit info.status.ammo_limit = len(self.uris) * loop_limit
self.headers = headers self.headers = headers
self.marker = get_marker(autocases) self.marker = get_marker(autocases, enum_ammo)
self.chosen_cases = chosen_cases self.chosen_cases = chosen_cases
def get_load_plan(self): def get_load_plan(self):

View File

@ -100,6 +100,7 @@ class StepperWrapper(object):
self.uris = [] self.uris = []
self.headers = [] self.headers = []
self.autocases = 0 self.autocases = 0
self.enum_ammo = False
self.use_caching = True self.use_caching = True
self.force_stepping = None self.force_stepping = None
self.ammo_type = 'phantom' self.ammo_type = 'phantom'
@ -126,8 +127,12 @@ class StepperWrapper(object):
opts = [StepperWrapper.OPTION_AMMOFILE, StepperWrapper.OPTION_LOOP, opts = [StepperWrapper.OPTION_AMMOFILE, StepperWrapper.OPTION_LOOP,
StepperWrapper.OPTION_SCHEDULE, StepperWrapper.OPTION_STPD] StepperWrapper.OPTION_SCHEDULE, StepperWrapper.OPTION_STPD]
opts += ["instances_schedule", "uris", opts += ["instances_schedule", "uris",
"headers", "header_http", "autocases", "ammo_type", "ammo_limit"] "headers", "header_http",
opts += ["use_caching", "cache_dir", "force_stepping", "file_cache", "chosen_cases"] "autocases", "enum_ammo",
"ammo_type", "ammo_limit"]
opts += ["use_caching", "cache_dir",
"force_stepping", "file_cache",
"chosen_cases"]
return opts return opts
def read_config(self): def read_config(self):
@ -159,6 +164,7 @@ class StepperWrapper(object):
self.headers = rx.findall(self.get_option("headers", '')) self.headers = rx.findall(self.get_option("headers", ''))
self.http_ver = self.get_option("header_http", self.http_ver) self.http_ver = self.get_option("header_http", self.http_ver)
self.autocases = self.get_option("autocases", '0') self.autocases = self.get_option("autocases", '0')
self.enum_ammo = self.get_option("enum_ammo", False)
self.use_caching = int(self.get_option("use_caching", '1')) self.use_caching = int(self.get_option("use_caching", '1'))
self.file_cache = int(self.get_option('file_cache', '8192')) self.file_cache = int(self.get_option('file_cache', '8192'))
@ -285,6 +291,7 @@ class StepperWrapper(object):
uris=self.uris, uris=self.uris,
headers=[header.strip('[]') for header in self.headers], headers=[header.strip('[]') for header in self.headers],
autocases=self.autocases, autocases=self.autocases,
enum_ammo=self.enum_ammo,
ammo_type=self.ammo_type, ammo_type=self.ammo_type,
chosen_cases=self.chosen_cases, chosen_cases=self.chosen_cases,
) )