mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-06 10:25:17 +00:00
Read active instances info from new phantom stat
This commit is contained in:
parent
0032955547
commit
6aad093a18
@ -1,4 +1,13 @@
|
||||
""" Contains Phantom Plugin, Console widgets, result reader classes """
|
||||
# FIXME: 3 there is no graceful way to interrupt the process of phout import
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import datetime
|
||||
|
||||
from Tank.Plugins import ConsoleScreen
|
||||
from Tank.Plugins.Aggregator import AggregatorPlugin, AggregateResultListener, \
|
||||
AbstractReader
|
||||
@ -6,20 +15,10 @@ from Tank.Plugins.Autostop import AutostopPlugin, AbstractCriteria
|
||||
from Tank.Plugins.ConsoleOnline import ConsoleOnlinePlugin, AbstractInfoWidget
|
||||
from Tank.Plugins.PhantomUtils import PhantomConfig
|
||||
from tankcore import AbstractPlugin
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import tankcore
|
||||
import time
|
||||
import datetime
|
||||
|
||||
# FIXME: 3 there is no graceful way to interrupt the process in phout
|
||||
# import mode
|
||||
|
||||
|
||||
class PhantomPlugin(AbstractPlugin, AggregateResultListener):
|
||||
|
||||
""" Plugin for running phantom tool """
|
||||
|
||||
OPTION_CONFIG = "config"
|
||||
@ -201,7 +200,6 @@ class PhantomPlugin(AbstractPlugin, AggregateResultListener):
|
||||
|
||||
|
||||
class PhantomProgressBarWidget(AbstractInfoWidget, AggregateResultListener):
|
||||
|
||||
"""
|
||||
Widget that displays progressbar
|
||||
"""
|
||||
@ -266,10 +264,8 @@ class PhantomProgressBarWidget(AbstractInfoWidget, AggregateResultListener):
|
||||
progress_chars = '=' * (int(pb_width * progress) - 1)
|
||||
progress_chars += self.krutilka.next()
|
||||
|
||||
res += color_bg + progress_chars + screen.markup.RESET + color_fg + \
|
||||
'~' * \
|
||||
(pb_width - int(pb_width * progress)) + \
|
||||
screen.markup.RESET + ' '
|
||||
res += color_bg + progress_chars + screen.markup.RESET + color_fg
|
||||
res += '~' * (pb_width - int(pb_width * progress)) + screen.markup.RESET + ' '
|
||||
res += str_perc + "\n"
|
||||
|
||||
eta = 'ETA: %s' % eta_time
|
||||
@ -284,7 +280,6 @@ class PhantomProgressBarWidget(AbstractInfoWidget, AggregateResultListener):
|
||||
|
||||
|
||||
class PhantomInfoWidget(AbstractInfoWidget, AggregateResultListener):
|
||||
|
||||
"""
|
||||
Widget with information about current run state
|
||||
"""
|
||||
@ -323,11 +318,9 @@ class PhantomInfoWidget(AbstractInfoWidget, AggregateResultListener):
|
||||
|
||||
res += "Active instances: "
|
||||
if float(self.instances) / self.instances_limit > 0.8:
|
||||
res += screen.markup.RED + \
|
||||
str(self.instances) + screen.markup.RESET
|
||||
res += screen.markup.RED + str(self.instances) + screen.markup.RESET
|
||||
elif float(self.instances) / self.instances_limit > 0.5:
|
||||
res += screen.markup.YELLOW + \
|
||||
str(self.instances) + screen.markup.RESET
|
||||
res += screen.markup.YELLOW + str(self.instances) + screen.markup.RESET
|
||||
else:
|
||||
res += str(self.instances)
|
||||
|
||||
@ -340,24 +333,18 @@ class PhantomInfoWidget(AbstractInfoWidget, AggregateResultListener):
|
||||
|
||||
res += "\n Accuracy: "
|
||||
if self.selfload < 80:
|
||||
res += screen.markup.RED + \
|
||||
('%.2f' % self.selfload) + screen.markup.RESET
|
||||
res += screen.markup.RED + ('%.2f' % self.selfload) + screen.markup.RESET
|
||||
elif self.selfload < 95:
|
||||
res += screen.markup.YELLOW + \
|
||||
('%.2f' % self.selfload) + screen.markup.RESET
|
||||
res += screen.markup.YELLOW + ('%.2f' % self.selfload) + screen.markup.RESET
|
||||
else:
|
||||
res += ('%.2f' % self.selfload)
|
||||
|
||||
res += "%\n Time lag: "
|
||||
if self.time_lag > self.owner.buffered_seconds * 5:
|
||||
self.log.debug("Time lag: %s", self.time_lag)
|
||||
res += screen.markup.RED + \
|
||||
str(datetime.timedelta(seconds=self.time_lag)) + \
|
||||
screen.markup.RESET
|
||||
res += screen.markup.RED + str(datetime.timedelta(seconds=self.time_lag)) + screen.markup.RESET
|
||||
elif self.time_lag > self.owner.buffered_seconds:
|
||||
res += screen.markup.YELLOW + \
|
||||
str(datetime.timedelta(seconds=self.time_lag)) + \
|
||||
screen.markup.RESET
|
||||
res += screen.markup.YELLOW + str(datetime.timedelta(seconds=self.time_lag)) + screen.markup.RESET
|
||||
else:
|
||||
res += str(datetime.timedelta(seconds=self.time_lag))
|
||||
|
||||
@ -378,10 +365,7 @@ class PhantomInfoWidget(AbstractInfoWidget, AggregateResultListener):
|
||||
|
||||
|
||||
class PhantomReader(AbstractReader):
|
||||
|
||||
"""
|
||||
Adapter to read phout files
|
||||
"""
|
||||
""" Adapter to read phout files """
|
||||
|
||||
def __init__(self, owner, phantom):
|
||||
AbstractReader.__init__(self, owner)
|
||||
@ -390,10 +374,10 @@ class PhantomReader(AbstractReader):
|
||||
self.phout = None
|
||||
self.stat = None
|
||||
self.stat_data = {}
|
||||
self.pending_datetime = None
|
||||
self.steps = []
|
||||
self.first_request_time = sys.maxint
|
||||
self.partial_buffer = ''
|
||||
self.stat_read_buffer = ''
|
||||
self.pending_second_data_queue = []
|
||||
self.last_sample_time = 0
|
||||
self.read_lines_count = 0
|
||||
@ -412,6 +396,7 @@ class PhantomReader(AbstractReader):
|
||||
"Opening stat file: %s", self.phantom.phantom.stat_log)
|
||||
self.stat = open(self.phantom.phantom.stat_log, 'r')
|
||||
|
||||
|
||||
def close_files(self):
|
||||
if self.stat:
|
||||
self.stat.close()
|
||||
@ -419,33 +404,40 @@ class PhantomReader(AbstractReader):
|
||||
if self.phout:
|
||||
self.phout.close()
|
||||
|
||||
|
||||
def get_next_sample(self, force):
|
||||
if self.stat and len(self.data_queue) < self.buffered_seconds * 2:
|
||||
self.__read_stat_data()
|
||||
return self.__read_phout_data(force)
|
||||
|
||||
|
||||
def __read_stat_data(self):
|
||||
""" Read active instances info """
|
||||
stat = self.stat.readlines()
|
||||
for line in stat:
|
||||
if line.startswith('time\t'):
|
||||
date_str = line[len('time:\t') - 1:].strip()[:-5].strip()
|
||||
date_obj = datetime.datetime.strptime(
|
||||
date_str, '%Y-%m-%d %H:%M:%S')
|
||||
self.pending_datetime = int(time.mktime(date_obj.timetuple()))
|
||||
self.stat_data[self.pending_datetime] = 0
|
||||
if line.startswith('tasks\t'):
|
||||
if not self.pending_datetime:
|
||||
raise RuntimeError(
|
||||
"Can't have tasks info without timestamp")
|
||||
end_marker = "\n},"
|
||||
self.stat_read_buffer += self.stat.read()
|
||||
while end_marker in self.stat_read_buffer:
|
||||
chunk_str = self.stat_read_buffer[:self.stat_read_buffer.find(end_marker) + len(end_marker) - 1]
|
||||
self.stat_read_buffer = self.stat_read_buffer[self.stat_read_buffer.find(end_marker) + len(end_marker) + 1:]
|
||||
chunk = json.loads("{%s}" % chunk_str)
|
||||
self.log.debug("Stat chunk (left %s bytes): %s", len(self.stat_read_buffer), chunk)
|
||||
|
||||
self.stat_data[self.pending_datetime] += int(
|
||||
line[len('tasks\t'):])
|
||||
self.log.debug(
|
||||
"Active instances: %s=>%s", self.pending_datetime, self.stat_data[self.pending_datetime])
|
||||
for date_str in chunk.keys():
|
||||
statistics = chunk[date_str]
|
||||
|
||||
date_obj = datetime.datetime.strptime(date_str.split(".")[0], '%Y-%m-%d %H:%M:%S')
|
||||
pending_datetime = int(time.mktime(date_obj.timetuple()))
|
||||
self.stat_data[pending_datetime] = 0
|
||||
|
||||
for benchmark_name in statistics.keys():
|
||||
if not benchmark_name.startswith("benchmark_io"):
|
||||
continue
|
||||
benchmark = statistics[benchmark_name]
|
||||
self.stat_data[pending_datetime] += benchmark["stream_method"]["mmtasks"][2]
|
||||
self.log.debug("Active instances: %s=>%s", pending_datetime, self.stat_data[pending_datetime])
|
||||
|
||||
self.log.debug("Instances info buffer size: %s", len(self.stat_data))
|
||||
|
||||
|
||||
def __read_phout_data(self, force):
|
||||
""" Read phantom results """
|
||||
if self.phout and len(self.data_queue) < self.buffered_seconds * 2:
|
||||
@ -499,16 +491,15 @@ class PhantomReader(AbstractReader):
|
||||
# accuracy
|
||||
data_item = (data[1], active, rt_real / 1000, data[11], data[10],
|
||||
int(data[8]), int(data[9]),
|
||||
int(data[3]) / 1000, int(data[4]) / 1000, int(
|
||||
data[5]) / 1000, int(data[6]) / 1000,
|
||||
(float(data[7]) + 1) / (rt_real + 1))
|
||||
int(data[3]) / 1000, int(data[4]) / 1000,
|
||||
int(data[5]) / 1000, int(data[6]) / 1000,
|
||||
(float(data[7]) + 1) / (rt_real + 1))
|
||||
|
||||
self.data_buffer[cur_time].append(data_item)
|
||||
|
||||
spent = time.time() - time_before
|
||||
if spent:
|
||||
self.log.debug(
|
||||
"Parsing speed: %s lines/sec", int(len(phout) / spent))
|
||||
self.log.debug("Parsing speed: %s lines/sec", int(len(phout) / spent))
|
||||
self.log.debug("Read lines total: %s", self.read_lines_count)
|
||||
self.log.debug("Seconds queue: %s", self.data_queue)
|
||||
self.log.debug("Seconds buffer (up to %s): %s",
|
||||
@ -581,7 +572,6 @@ class PhantomReader(AbstractReader):
|
||||
|
||||
|
||||
class UsedInstancesCriteria(AbstractCriteria):
|
||||
|
||||
"""
|
||||
Autostop criteria, based on active instances count
|
||||
"""
|
||||
|
@ -38,7 +38,7 @@ setup_t stat_setup = setup_stat_t {
|
||||
|
||||
|
||||
io_t monitor_io = io_monitor_t {
|
||||
list = { benchmark_io $stat_benchmarks }
|
||||
list = { main_scheduler benchmark_io $stat_benchmarks }
|
||||
stat_id = default
|
||||
|
||||
period = 1s
|
||||
|
@ -15,107 +15,107 @@ class PhantomPluginTestCase(TankTestCase):
|
||||
core.load_plugins()
|
||||
core.plugins_configure()
|
||||
core.plugins_prepare_test()
|
||||
self.foo = PhantomPlugin(core)
|
||||
self.phantom_plugin_instance = PhantomPlugin(core)
|
||||
|
||||
def tearDown(self):
|
||||
del self.foo
|
||||
self.foo = None
|
||||
del self.phantom_plugin_instance
|
||||
self.phantom_plugin_instance = None
|
||||
if os.path.exists("ready_conf_phout.txt"):
|
||||
os.remove("ready_conf_phout.txt")
|
||||
|
||||
def test_run(self):
|
||||
self.foo.core.set_option(PhantomPlugin.SECTION, "config", '')
|
||||
self.foo.configure()
|
||||
self.foo.prepare_test()
|
||||
reader = PhantomReader(AggregatorPlugin(self.foo.core), self.foo)
|
||||
reader.phout_file = self.foo.phantom.phout_file
|
||||
self.foo.start_test()
|
||||
self.phantom_plugin_instance.core.set_option(PhantomPlugin.SECTION, "config", '')
|
||||
self.phantom_plugin_instance.configure()
|
||||
self.phantom_plugin_instance.prepare_test()
|
||||
reader = PhantomReader(AggregatorPlugin(self.phantom_plugin_instance.core), self.phantom_plugin_instance)
|
||||
reader.phout_file = self.phantom_plugin_instance.phantom.phout_file
|
||||
self.phantom_plugin_instance.start_test()
|
||||
|
||||
while self.foo.is_test_finished() < 0:
|
||||
self.foo.log.debug("Not finished")
|
||||
while self.phantom_plugin_instance.is_test_finished() < 0:
|
||||
self.phantom_plugin_instance.log.debug("Not finished")
|
||||
reader.check_open_files()
|
||||
reader.get_next_sample(False)
|
||||
time.sleep(1)
|
||||
if self.foo.is_test_finished() != 0:
|
||||
raise RuntimeError("RC: %s" % self.foo.is_test_finished())
|
||||
self.foo.end_test(0)
|
||||
if self.phantom_plugin_instance.is_test_finished() != 0:
|
||||
raise RuntimeError("RC: %s" % self.phantom_plugin_instance.is_test_finished())
|
||||
self.phantom_plugin_instance.end_test(0)
|
||||
reader.get_next_sample(True)
|
||||
|
||||
|
||||
def test_run_ready_conf(self):
|
||||
self.foo.core.set_option(PhantomPlugin.SECTION, "config", 'data/phantom_ready.conf')
|
||||
self.foo.core.add_artifact_file("ready_conf_phout.txt")
|
||||
self.foo.configure()
|
||||
self.foo.prepare_test()
|
||||
self.foo.start_test()
|
||||
while self.foo.is_test_finished() < 0:
|
||||
self.foo.log.debug("Not finished")
|
||||
self.phantom_plugin_instance.core.set_option(PhantomPlugin.SECTION, "config", 'data/phantom_ready.conf')
|
||||
self.phantom_plugin_instance.core.add_artifact_file("ready_conf_phout.txt")
|
||||
self.phantom_plugin_instance.configure()
|
||||
self.phantom_plugin_instance.prepare_test()
|
||||
self.phantom_plugin_instance.start_test()
|
||||
while self.phantom_plugin_instance.is_test_finished() < 0:
|
||||
self.phantom_plugin_instance.log.debug("Not finished")
|
||||
time.sleep(1)
|
||||
if self.foo.is_test_finished() != 0:
|
||||
raise RuntimeError("RC: %s" % self.foo.is_test_finished())
|
||||
if self.phantom_plugin_instance.is_test_finished() != 0:
|
||||
raise RuntimeError("RC: %s" % self.phantom_plugin_instance.is_test_finished())
|
||||
self.assertTrue(os.path.getsize("ready_conf_phout.txt") > 0)
|
||||
self.foo.end_test(0)
|
||||
self.phantom_plugin_instance.end_test(0)
|
||||
|
||||
|
||||
def test_run_uri_style(self):
|
||||
self.foo.set_option("ammofile", "")
|
||||
self.foo.set_option("uris", "/")
|
||||
self.foo.configure()
|
||||
self.foo.prepare_test()
|
||||
self.foo.start_test()
|
||||
while self.foo.is_test_finished() < 0:
|
||||
self.foo.log.debug("Not finished")
|
||||
self.phantom_plugin_instance.set_option("ammofile", "")
|
||||
self.phantom_plugin_instance.set_option("uris", "/")
|
||||
self.phantom_plugin_instance.configure()
|
||||
self.phantom_plugin_instance.prepare_test()
|
||||
self.phantom_plugin_instance.start_test()
|
||||
while self.phantom_plugin_instance.is_test_finished() < 0:
|
||||
self.phantom_plugin_instance.log.debug("Not finished")
|
||||
time.sleep(1)
|
||||
if self.foo.is_test_finished() != 0:
|
||||
raise RuntimeError("RC: %s" % self.foo.is_test_finished())
|
||||
self.foo.end_test(0)
|
||||
if self.phantom_plugin_instance.is_test_finished() != 0:
|
||||
raise RuntimeError("RC: %s" % self.phantom_plugin_instance.is_test_finished())
|
||||
self.phantom_plugin_instance.end_test(0)
|
||||
|
||||
def test_run_interrupt(self):
|
||||
self.foo.configure()
|
||||
self.foo.prepare_test()
|
||||
self.foo.start_test()
|
||||
self.phantom_plugin_instance.configure()
|
||||
self.phantom_plugin_instance.prepare_test()
|
||||
self.phantom_plugin_instance.start_test()
|
||||
time.sleep(2)
|
||||
self.foo.end_test(0)
|
||||
self.phantom_plugin_instance.end_test(0)
|
||||
|
||||
def test_run_stepper_cache(self):
|
||||
self.foo.configure()
|
||||
self.foo.prepare_test()
|
||||
self.foo.prepare_test()
|
||||
self.phantom_plugin_instance.configure()
|
||||
self.phantom_plugin_instance.prepare_test()
|
||||
self.phantom_plugin_instance.prepare_test()
|
||||
|
||||
def test_domain_name(self):
|
||||
self.foo.core.set_option('phantom', 'address', 'yandex.ru:443')
|
||||
self.foo.configure()
|
||||
self.assertEqual("443", self.foo.get_info().port)
|
||||
self.assertEqual("yandex.ru", self.foo.get_info().address)
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'address', 'yandex.ru:443')
|
||||
self.phantom_plugin_instance.configure()
|
||||
self.assertEqual("443", self.phantom_plugin_instance.get_info().port)
|
||||
self.assertEqual("yandex.ru", self.phantom_plugin_instance.get_info().address)
|
||||
|
||||
def test_domain_name_and_port(self):
|
||||
self.foo.core.set_option('phantom', 'address', 'yandex.ru:80')
|
||||
self.foo.configure()
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'address', 'yandex.ru:80')
|
||||
self.phantom_plugin_instance.configure()
|
||||
|
||||
def test_ipv4(self):
|
||||
self.foo.core.set_option('phantom', 'address', '127.0.0.1')
|
||||
self.foo.configure()
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'address', '127.0.0.1')
|
||||
self.phantom_plugin_instance.configure()
|
||||
|
||||
def test_ipv6(self):
|
||||
self.foo.core.set_option('phantom', 'address', '2a02:6b8:0:c1f::161:cd')
|
||||
self.foo.configure()
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'address', '2a02:6b8:0:c1f::161:cd')
|
||||
self.phantom_plugin_instance.configure()
|
||||
|
||||
def test_ipv4_and_port(self):
|
||||
self.foo.core.set_option('phantom', 'address', '127.0.0.1:80')
|
||||
self.foo.configure()
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'address', '127.0.0.1:80')
|
||||
self.phantom_plugin_instance.configure()
|
||||
|
||||
def test_domain_name_fail(self):
|
||||
self.foo.core.set_option('phantom', 'address', 'ya.ru')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'address', 'ya.ru')
|
||||
try:
|
||||
self.foo.configure()
|
||||
self.phantom_plugin_instance.configure()
|
||||
raise RuntimeError()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def test_reader(self):
|
||||
self.foo.phantom_start_time = time.time()
|
||||
reader = PhantomReader(AggregatorPlugin(self.foo.core), self.foo)
|
||||
self.phantom_plugin_instance.phantom_start_time = time.time()
|
||||
reader = PhantomReader(AggregatorPlugin(self.phantom_plugin_instance.core), self.phantom_plugin_instance)
|
||||
reader.phout_file = 'data/phout_timeout_mix.txt'
|
||||
reader.check_open_files()
|
||||
|
||||
@ -130,76 +130,75 @@ class PhantomPluginTestCase(TankTestCase):
|
||||
|
||||
|
||||
def test_stepper_no_steps(self):
|
||||
self.foo.core.set_option('phantom', 'rps_schedule', '')
|
||||
self.foo.core.set_option('phantom', 'instances_schedule', '')
|
||||
wrapper = StepperWrapper(self.foo.core, PhantomPlugin.SECTION)
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule', '')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'instances_schedule', '')
|
||||
wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
|
||||
wrapper.ammo_file = 'data/dummy.ammo'
|
||||
wrapper.prepare_stepper()
|
||||
wrapper.prepare_stepper()
|
||||
|
||||
def test_stepper_instances_sched(self):
|
||||
self.foo.core.set_option('phantom', 'instances', '1000')
|
||||
self.foo.core.set_option('phantom', 'rps_schedule', '')
|
||||
self.foo.core.set_option('phantom', 'instances_schedule', 'line(1,100,1m)')
|
||||
self.foo.core.set_option('phantom', 'use_caching', '0')
|
||||
self.foo.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
|
||||
wrapper = StepperWrapper(self.foo.core, PhantomPlugin.SECTION)
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'instances', '1000')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule', '')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'instances_schedule', 'line(1,100,1m)')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'use_caching', '0')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
|
||||
wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
|
||||
wrapper.read_config()
|
||||
wrapper.prepare_stepper()
|
||||
self.assertEqual(100, wrapper.instances)
|
||||
|
||||
def test_stepper_instances_override(self):
|
||||
self.foo.core.set_option('phantom', 'instances', '20000')
|
||||
self.foo.core.set_option('phantom', 'rps_schedule', 'line(1,100,1m)')
|
||||
self.foo.core.set_option('phantom', 'use_caching', '0')
|
||||
self.foo.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
|
||||
wrapper = StepperWrapper(self.foo.core, PhantomPlugin.SECTION)
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'instances', '20000')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule', 'line(1,100,1m)')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'use_caching', '0')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
|
||||
wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
|
||||
wrapper.read_config()
|
||||
wrapper.prepare_stepper()
|
||||
self.assertEqual(20000, wrapper.instances)
|
||||
|
||||
|
||||
def test_cached_stepper_instances_sched(self):
|
||||
|
||||
# Making cache file
|
||||
self.foo.core.set_option('phantom', 'instances', '1000')
|
||||
self.foo.core.set_option('phantom', 'rps_schedule', '')
|
||||
self.foo.core.set_option('phantom', 'instances_schedule', 'line(1,100,1m)')
|
||||
self.foo.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
|
||||
wrapper = StepperWrapper(self.foo.core, PhantomPlugin.SECTION)
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'instances', '1000')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule', '')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'instances_schedule', 'line(1,100,1m)')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
|
||||
wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
|
||||
wrapper.read_config()
|
||||
wrapper.prepare_stepper()
|
||||
self.tearDown()
|
||||
|
||||
|
||||
self.setUp()
|
||||
self.foo.core.set_option('phantom', 'instances', '1000')
|
||||
self.foo.core.set_option('phantom', 'rps_schedule', '')
|
||||
self.foo.core.set_option('phantom', 'instances_schedule', 'line(1,100,1m)')
|
||||
self.foo.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
|
||||
wrapper = StepperWrapper(self.foo.core, PhantomPlugin.SECTION)
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'instances', '1000')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'rps_schedule', '')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'instances_schedule', 'line(1,100,1m)')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'ammo_file', 'data/dummy.ammo')
|
||||
wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
|
||||
wrapper.read_config()
|
||||
wrapper.prepare_stepper()
|
||||
self.assertEqual(100, wrapper.instances)
|
||||
|
||||
def test_phout_import(self):
|
||||
self.foo.core.set_option('phantom', 'phout_file', 'data/phout_timeout_mix.txt')
|
||||
self.foo.core.set_option('phantom', 'instances', '1')
|
||||
self.foo.core.set_option('phantom', 'ammo_count', '1')
|
||||
self.foo.configure()
|
||||
self.foo.prepare_test()
|
||||
self.foo.start_test()
|
||||
self.assertEqual(self.foo.is_test_finished(), -1)
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'phout_file', 'data/phout_timeout_mix.txt')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'instances', '1')
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'ammo_count', '1')
|
||||
self.phantom_plugin_instance.configure()
|
||||
self.phantom_plugin_instance.prepare_test()
|
||||
self.phantom_plugin_instance.start_test()
|
||||
self.assertEqual(self.phantom_plugin_instance.is_test_finished(), -1)
|
||||
sec = SecondAggregateData()
|
||||
sec.overall.RPS = 1
|
||||
self.foo.aggregate_second(sec)
|
||||
self.assertEqual(self.foo.is_test_finished(), -1)
|
||||
self.assertEqual(self.foo.is_test_finished(), 0)
|
||||
self.foo.end_test(0)
|
||||
self.foo.post_process(0)
|
||||
self.phantom_plugin_instance.aggregate_second(sec)
|
||||
self.assertEqual(self.phantom_plugin_instance.is_test_finished(), -1)
|
||||
self.assertEqual(self.phantom_plugin_instance.is_test_finished(), 0)
|
||||
self.phantom_plugin_instance.end_test(0)
|
||||
self.phantom_plugin_instance.post_process(0)
|
||||
|
||||
def test_cached_stpd_info(self):
|
||||
self.foo.core.set_option('phantom', 'stpd_file', 'data/dummy.ammo.stpd')
|
||||
wrapper = StepperWrapper(self.foo.core, PhantomPlugin.SECTION)
|
||||
self.phantom_plugin_instance.core.set_option('phantom', 'stpd_file', 'data/dummy.ammo.stpd')
|
||||
wrapper = StepperWrapper(self.phantom_plugin_instance.core, PhantomPlugin.SECTION)
|
||||
wrapper.read_config()
|
||||
wrapper.prepare_stepper()
|
||||
self.assertEqual(10, wrapper.instances)
|
||||
|
@ -7,7 +7,24 @@ phantom_path=phantom
|
||||
#config=data/phantom_ready.conf
|
||||
ammofile=data/dummy.ammo
|
||||
#instances_schedule=line(1,10,1m)
|
||||
loop=1
|
||||
#loop=1
|
||||
ammo_limit=100
|
||||
rps_schedule=const(1,1) line(1,5,10)
|
||||
#uris=/
|
||||
# /test
|
||||
# /test2
|
||||
headers=Host: www.ya.ru
|
||||
Connection: close
|
||||
|
||||
use_caching=1
|
||||
|
||||
|
||||
[phantom-1]
|
||||
phantom_path=phantom
|
||||
#config=data/phantom_ready.conf
|
||||
ammofile=data/dummy.ammo
|
||||
#instances_schedule=line(1,10,1m)
|
||||
#loop=1
|
||||
ammo_limit=100
|
||||
rps_schedule=const(1,1) line(1,5,10)
|
||||
#uris=/
|
||||
|
396
Tests/data/phantom_stat.example
Normal file
396
Tests/data/phantom_stat.example
Normal file
@ -0,0 +1,396 @@
|
||||
"2014-03-31 21:09:10.798 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "674 -- 1074" : 18, "423 -- 674" : 37 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [482, 459],
|
||||
"in" : [1469370, 1399557],
|
||||
"out" : [8676, 8263],
|
||||
"mmtasks" : [0, 952, 1000],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Success" : 55 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "OK" : 55 }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [0, 45812, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [55, 52],
|
||||
"out" : [3701, 3524]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:11.799 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "1710 -- 2723" : 12, "1074 -- 1710" : 85, "674 -- 1074" : 5 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [0, 0],
|
||||
"in" : [1966188, 1964954],
|
||||
"out" : [0, 0],
|
||||
"mmtasks" : [843, 881, 945],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Success" : 102 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "OK" : 102 }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 48016, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [102, 101],
|
||||
"out" : [7104, 7099]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:12.799 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "2723 -- 4337" : 38, "1710 -- 2723" : 68 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [144, 144],
|
||||
"in" : [1859994, 1860232],
|
||||
"out" : [2592, 2592],
|
||||
"mmtasks" : [737, 784, 843],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Success" : 106 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "OK" : 106 }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 48005, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [106, 106],
|
||||
"out" : [7435, 7435]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:13.799 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "2723 -- 4337" : 94 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [0, 0],
|
||||
"in" : [1970467, 1970977],
|
||||
"out" : [0, 0],
|
||||
"mmtasks" : [643, 687, 737],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Success" : 94 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "OK" : 94 }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 48012, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [94, 94],
|
||||
"out" : [6722, 6723]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:14.799 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "4337 -- 6907" : 47, "2723 -- 4337" : 25 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [0, 0],
|
||||
"in" : [1643815, 1643272],
|
||||
"out" : [0, 0],
|
||||
"mmtasks" : [571, 598, 643],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Success" : 72 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "OK" : 72 }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 47984, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [72, 71],
|
||||
"out" : [5210, 5208]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:15.799 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "4337 -- 6907" : 100 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [0, 0],
|
||||
"in" : [1594333, 1594191],
|
||||
"out" : [0, 0],
|
||||
"mmtasks" : [471, 510, 571],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Success" : 100 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "OK" : 100 }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 47995, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [100, 99],
|
||||
"out" : [7269, 7268]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:16.798 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "4337 -- 6907" : 97 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [56, 56],
|
||||
"in" : [1837381, 1839245],
|
||||
"out" : [1008, 1009],
|
||||
"mmtasks" : [374, 416, 471],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Success" : 97 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "OK" : 97 }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 48000, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [97, 97],
|
||||
"out" : [7043, 7050]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:17.799 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "6907 -- 11000" : 85 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [117, 116],
|
||||
"in" : [1967289, 1965557],
|
||||
"out" : [2106, 2104],
|
||||
"mmtasks" : [289, 335, 374],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Success" : 85 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "OK" : 85 }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 48005, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [85, 84],
|
||||
"out" : [6079, 6073]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:18.799 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "6907 -- 11000" : 88 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [0, 0],
|
||||
"in" : [1443060, 1443049],
|
||||
"out" : [0, 0],
|
||||
"mmtasks" : [201, 233, 289],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Success" : 88 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "OK" : 88 }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 47999, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [88, 87],
|
||||
"out" : [6354, 6353]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:19.799 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [0, 0],
|
||||
"in" : [0, 0],
|
||||
"out" : [0, 0],
|
||||
"mmtasks" : [201, 201, 201],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 48013, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [0, 0],
|
||||
"out" : [0, 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:20.799 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "11000 --" : 198 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [0, 0],
|
||||
"in" : [0, 0],
|
||||
"out" : [0, 0],
|
||||
"mmtasks" : [3, 199, 201],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Connection timed out" : 198 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 47997, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [199, 198],
|
||||
"out" : [11741, 11740]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2014-03-31 21:09:20.799 +0400" : {
|
||||
"benchmark_io" : {
|
||||
"simple_times" : {
|
||||
"mcount" : {
|
||||
"mcount" : { "11000 --" : 3 }
|
||||
}
|
||||
},
|
||||
"stream_method" : {
|
||||
"conns" : [0, 0],
|
||||
"in" : [0, 0],
|
||||
"out" : [0, 0],
|
||||
"mmtasks" : [0, 1, 3],
|
||||
"load" : 0.000,
|
||||
"mcount" : {
|
||||
"mcount" : { "Connection timed out" : 3 }
|
||||
},
|
||||
"http_proto0" : {
|
||||
"mcount" : {
|
||||
"mcount" : { }
|
||||
}
|
||||
},
|
||||
"source_log" : {
|
||||
"delta" : [47508, 0, 47508]
|
||||
},
|
||||
"loggers" : {
|
||||
"brief_logger" : {
|
||||
"records" : [2, 7299],
|
||||
"out" : [118, 430656]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user