mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-06 18:35:18 +00:00
try to fix config migration error
make single avg times block fix unit tests
This commit is contained in:
parent
33b38d64cb
commit
3ef65e5279
@ -119,15 +119,15 @@ class ConsoleTank:
|
|||||||
|
|
||||||
def __convert_old_multiline_options(self, old_lines):
|
def __convert_old_multiline_options(self, old_lines):
|
||||||
opts = {}
|
opts = {}
|
||||||
option=None
|
option = None
|
||||||
res = ''
|
res = ''
|
||||||
for line in old_lines:
|
for line in old_lines:
|
||||||
try:
|
try:
|
||||||
if line.strip() and line.strip()[0] == '#':
|
if line.strip() and line.strip()[0] == '#':
|
||||||
res+=line
|
res += line
|
||||||
continue
|
continue
|
||||||
option = line[:line.index('=')]
|
option = line[:line.index('=')]
|
||||||
value = line[line.index('=')+1:]
|
value = line[line.index('=') + 1:]
|
||||||
if option not in opts.keys():
|
if option not in opts.keys():
|
||||||
opts[option] = []
|
opts[option] = []
|
||||||
opts[option].append(value.strip())
|
opts[option].append(value.strip())
|
||||||
@ -135,7 +135,7 @@ class ConsoleTank:
|
|||||||
if option:
|
if option:
|
||||||
opts[option].append(line.strip())
|
opts[option].append(line.strip())
|
||||||
else:
|
else:
|
||||||
res += line
|
res += line.strip() + "\n"
|
||||||
|
|
||||||
for option, values in opts.iteritems():
|
for option, values in opts.iteritems():
|
||||||
res += option + '=' + "\n\t".join(values) + "\n"
|
res += option + '=' + "\n\t".join(values) + "\n"
|
||||||
|
@ -18,6 +18,9 @@ def get_terminal_size():
|
|||||||
default_size = (25, 80)
|
default_size = (25, 80)
|
||||||
env = os.environ
|
env = os.environ
|
||||||
def ioctl_gwinsz(file_d):
|
def ioctl_gwinsz(file_d):
|
||||||
|
'''
|
||||||
|
Helper to get console size
|
||||||
|
'''
|
||||||
try:
|
try:
|
||||||
sizes = struct.unpack('hh', fcntl.ioctl(file_d, termios.TIOCGWINSZ, '1234'))
|
sizes = struct.unpack('hh', fcntl.ioctl(file_d, termios.TIOCGWINSZ, '1234'))
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -34,7 +37,7 @@ def get_terminal_size():
|
|||||||
if not sizes:
|
if not sizes:
|
||||||
try:
|
try:
|
||||||
sizes = (env['LINES'], env['COLUMNS'])
|
sizes = (env['LINES'], env['COLUMNS'])
|
||||||
except:
|
except Exception:
|
||||||
sizes = default_size
|
sizes = default_size
|
||||||
return int(sizes[1]), int(sizes[0])
|
return int(sizes[1]), int(sizes[0])
|
||||||
|
|
||||||
@ -57,10 +60,9 @@ class Screen(object):
|
|||||||
|
|
||||||
codes_block = VerticalBlock(CurrentHTTPBlock(self), CurrentNetBlock(self))
|
codes_block = VerticalBlock(CurrentHTTPBlock(self), CurrentNetBlock(self))
|
||||||
codes_answ_block = VerticalBlock(codes_block, AnswSizesBlock(self))
|
codes_answ_block = VerticalBlock(codes_block, AnswSizesBlock(self))
|
||||||
codes_answ_times_block = VerticalBlock(codes_answ_block, AvgTimesBlock(self, 'Average Times for Current RPS:', False))
|
|
||||||
times_block = CurrentTimesDistBlock(self)
|
times_block = CurrentTimesDistBlock(self)
|
||||||
second_row = [times_block, codes_answ_times_block]
|
second_row = [times_block, codes_answ_block]
|
||||||
first_row = [TotalQuantilesBlock(self), AvgTimesBlock(self, 'Cumulative Average Times:', True), CasesBlock(self)]
|
first_row = [AvgTimesBlock(self), TotalQuantilesBlock(self), CasesBlock(self)]
|
||||||
self.block_rows = [first_row, second_row]
|
self.block_rows = [first_row, second_row]
|
||||||
|
|
||||||
def __get_right_line(self, widget_output):
|
def __get_right_line(self, widget_output):
|
||||||
@ -492,43 +494,75 @@ class AnswSizesBlock(AbstractBlock):
|
|||||||
|
|
||||||
|
|
||||||
class AvgTimesBlock(AbstractBlock):
|
class AvgTimesBlock(AbstractBlock):
|
||||||
def __init__(self, screen, header, is_total=False):
|
def __init__(self, screen):
|
||||||
AbstractBlock.__init__(self, screen)
|
AbstractBlock.__init__(self, screen)
|
||||||
self.avg_connect_time = 0
|
self.rps_connect = 0
|
||||||
self.avg_send_time = 0
|
self.rps_send = 0
|
||||||
self.avg_latency = 0
|
self.rps_latency = 0
|
||||||
self.avg_receive_time = 0
|
self.rps_receive = 0
|
||||||
self.avg_response_time = 0
|
self.rps_overall = 0
|
||||||
self.count = 0
|
self.rps_count = 0
|
||||||
self.header = header
|
|
||||||
self.is_total = is_total
|
|
||||||
self.current_rps = 0
|
self.current_rps = 0
|
||||||
|
|
||||||
def add_second(self, data):
|
self.all_connect = 0
|
||||||
if not self.is_total and self.current_rps != data.overall.planned_requests:
|
self.all_send = 0
|
||||||
self.current_rps = data.overall.planned_requests
|
self.all_latency = 0
|
||||||
self.avg_connect_time = 0
|
self.all_receive = 0
|
||||||
self.avg_send_time = 0
|
self.all_overall = 0
|
||||||
self.avg_latency = 0
|
self.all_count = 0
|
||||||
self.avg_receive_time = 0
|
|
||||||
self.avg_response_time = 0
|
|
||||||
self.count = 0
|
|
||||||
|
|
||||||
self.avg_connect_time += data.overall.avg_connect_time * data.overall.RPS
|
self.last_connect = 0
|
||||||
self.avg_send_time += data.overall.avg_send_time * data.overall.RPS
|
self.last_send = 0
|
||||||
self.avg_latency += data.overall.avg_latency * data.overall.RPS
|
self.last_latency = 0
|
||||||
self.avg_receive_time += data.overall.avg_receive_time * data.overall.RPS
|
self.last_receive = 0
|
||||||
self.avg_response_time += data.overall.avg_response_time * data.overall.RPS
|
self.last_overall = 0
|
||||||
self.count += data.overall.RPS
|
self.last_count = 0
|
||||||
|
|
||||||
|
self.header = 'Average Times (all/%s RPS/last):'
|
||||||
|
|
||||||
|
def add_second(self, data):
|
||||||
|
if self.current_rps != data.overall.planned_requests:
|
||||||
|
self.current_rps = data.overall.planned_requests
|
||||||
|
self.rps_connect = 0
|
||||||
|
self.rps_send = 0
|
||||||
|
self.rps_latency = 0
|
||||||
|
self.rps_receive = 0
|
||||||
|
self.rps_overall = 0
|
||||||
|
self.rps_count = 0
|
||||||
|
|
||||||
|
self.rps_connect += data.overall.avg_connect_time * data.overall.RPS
|
||||||
|
self.rps_send += data.overall.avg_send_time * data.overall.RPS
|
||||||
|
self.rps_latency += data.overall.avg_latency * data.overall.RPS
|
||||||
|
self.rps_receive += data.overall.avg_receive_time * data.overall.RPS
|
||||||
|
self.rps_overall += data.overall.avg_response_time * data.overall.RPS
|
||||||
|
self.rps_count += data.overall.RPS
|
||||||
|
|
||||||
|
self.all_connect += data.overall.avg_connect_time * data.overall.RPS
|
||||||
|
self.all_send += data.overall.avg_send_time * data.overall.RPS
|
||||||
|
self.all_latency += data.overall.avg_latency * data.overall.RPS
|
||||||
|
self.all_receive += data.overall.avg_receive_time * data.overall.RPS
|
||||||
|
self.all_overall += data.overall.avg_response_time * data.overall.RPS
|
||||||
|
self.all_count += data.overall.RPS
|
||||||
|
|
||||||
|
self.last_connect = data.overall.avg_connect_time * data.overall.RPS
|
||||||
|
self.last_send = data.overall.avg_send_time * data.overall.RPS
|
||||||
|
self.last_latency = data.overall.avg_latency * data.overall.RPS
|
||||||
|
self.last_receive = data.overall.avg_receive_time * data.overall.RPS
|
||||||
|
self.last_overall = data.overall.avg_response_time * data.overall.RPS
|
||||||
|
self.last_count = data.overall.RPS
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
self.lines = [self.screen.markup.WHITE + self.header + self.screen.markup.RESET]
|
self.lines = [self.screen.markup.WHITE + self.header % self.current_rps + self.screen.markup.RESET]
|
||||||
if self.count:
|
if self.last_count:
|
||||||
self.lines.append(" Overall: %.1f ms" % (float(self.avg_response_time) / self.count))
|
len_all = str(len(str(max([self.all_connect, self.all_latency, self.all_overall, self.all_receive, self.all_send]))))
|
||||||
self.lines.append(" Connect: %.1f ms" % (float(self.avg_connect_time) / self.count))
|
len_rps = str(len(str(max([self.rps_connect, self.rps_latency, self.rps_overall, self.rps_receive, self.rps_send]))))
|
||||||
self.lines.append(" Send: %.1f ms" % (float(self.avg_send_time) / self.count))
|
len_last = str(len(str(max([self.last_connect, self.last_latency, self.last_overall, self.last_receive, self.last_send]))))
|
||||||
self.lines.append(" Latency: %.1f ms" % (float(self.avg_latency) / self.count))
|
tpl = "%" + len_all + "d / %" + len_rps + "d / %" + len_last + "d"
|
||||||
self.lines.append(" Receive: %.1f ms" % (float(self.avg_receive_time) / self.count))
|
self.lines.append(" Overall: " + tpl % (float(self.all_overall) / self.all_count, float(self.rps_overall) / self.rps_count, float(self.last_overall) / self.last_count))
|
||||||
|
self.lines.append(" Connect: " + tpl % (float(self.all_connect) / self.all_count, float(self.rps_connect) / self.rps_count, float(self.last_connect) / self.last_count))
|
||||||
|
self.lines.append(" Send: " + tpl % (float(self.all_send) / self.all_count, float(self.rps_send) / self.rps_count, float(self.rps_send) / self.rps_count))
|
||||||
|
self.lines.append(" Latency: " + tpl % (float(self.all_latency) / self.all_count, float(self.rps_latency) / self.rps_count, float(self.rps_latency) / self.rps_count))
|
||||||
|
self.lines.append(" Receive: " + tpl % (float(self.all_receive) / self.all_count, float(self.rps_receive) / self.rps_count, float(self.rps_receive) / self.rps_count))
|
||||||
for line in self.lines:
|
for line in self.lines:
|
||||||
self.width = max(self.width, len(self.screen.markup.clean_markup(line)))
|
self.width = max(self.width, len(self.screen.markup.clean_markup(line)))
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ class PhantomInfoWidget(AbstractInfoWidget, AggregateResultListener):
|
|||||||
else:
|
else:
|
||||||
res += str(self.instances)
|
res += str(self.instances)
|
||||||
|
|
||||||
res += "\nPlanned requests: %s %s\nActual responses: " % (self.planned, datetime.timedelta(seconds=self.planned_rps_duration))
|
res += "\nPlanned requests: %s for %s\nActual responses: " % (self.planned, datetime.timedelta(seconds=self.planned_rps_duration))
|
||||||
if not self.planned == self.RPS:
|
if not self.planned == self.RPS:
|
||||||
res += screen.markup.YELLOW + str(self.RPS) + screen.markup.RESET
|
res += screen.markup.YELLOW + str(self.RPS) + screen.markup.RESET
|
||||||
else:
|
else:
|
||||||
|
@ -66,21 +66,6 @@ class AutostopTestCase(TankTestCase):
|
|||||||
raise RuntimeError()
|
raise RuntimeError()
|
||||||
self.foo.end_test(0)
|
self.foo.end_test(0)
|
||||||
|
|
||||||
def test_run_inst(self):
|
|
||||||
data = SecondAggregateData()
|
|
||||||
data.overall.active_threads = 10
|
|
||||||
self.foo.core.set_option(self.foo.SECTION, "autostop", "instances (5, 5)\ninstances (90%, 10m)")
|
|
||||||
|
|
||||||
self.foo.configure()
|
|
||||||
self.foo.prepare_test()
|
|
||||||
|
|
||||||
self.foo.start_test()
|
|
||||||
for n in range(1, 15):
|
|
||||||
self.foo.aggregate_second(data)
|
|
||||||
if self.foo.is_test_finished() < 0:
|
|
||||||
raise RuntimeError()
|
|
||||||
self.foo.end_test(0)
|
|
||||||
|
|
||||||
def test_run_quan(self):
|
def test_run_quan(self):
|
||||||
data = SecondAggregateData()
|
data = SecondAggregateData()
|
||||||
data.overall.quantiles = {99.0:11}
|
data.overall.quantiles = {99.0:11}
|
||||||
@ -96,13 +81,6 @@ class AutostopTestCase(TankTestCase):
|
|||||||
raise RuntimeError()
|
raise RuntimeError()
|
||||||
self.foo.end_test(0)
|
self.foo.end_test(0)
|
||||||
|
|
||||||
def test_run_multiconf(self):
|
|
||||||
self.foo.core.set_option(self.foo.SECTION, "autostop", "instances (5, 5)\ninstances (90%, 10m) instances (90%, 10m)")
|
|
||||||
|
|
||||||
self.foo.configure()
|
|
||||||
self.foo.prepare_test()
|
|
||||||
self.assertEquals(3, len(self.foo.criterias))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user