yandex-tank/Tests/AutostopTest.py

98 lines
3.0 KiB
Python
Raw Normal View History

2012-10-03 16:49:13 +00:00
from Tank.Plugins.Aggregator import SecondAggregateData
2012-09-12 13:18:58 +00:00
from Tank.Plugins.Autostop import AutostopPlugin
from Tests.TankTests import TankTestCase
import tempfile
import unittest
class AutostopTestCase(TankTestCase):
def setUp(self):
2012-09-21 11:47:37 +00:00
core = self.get_core()
2012-09-12 13:18:58 +00:00
core.load_configs(['config/autostop.conf'])
core.load_plugins()
core.plugins_configure()
2012-09-12 13:18:58 +00:00
self.foo = AutostopPlugin(core)
def tearDown(self):
del self.foo
self.foo = None
def test_run(self):
2012-09-20 15:45:27 +00:00
data = SecondAggregateData()
data.overall.avg_response_time = 11
2012-09-12 13:18:58 +00:00
self.foo.core.set_option(self.foo.SECTION, "autostop", "time(1,10)")
self.foo.configure()
self.foo.prepare_test()
self.foo.start_test()
2012-09-12 15:55:59 +00:00
for n in range(1, 15):
2012-09-12 13:18:58 +00:00
self.foo.aggregate_second(data)
2012-09-12 15:55:59 +00:00
if self.foo.is_test_finished() < 0:
2012-09-12 13:18:58 +00:00
raise RuntimeError()
self.foo.end_test(0)
def test_run_http(self):
2012-09-20 15:45:27 +00:00
data = SecondAggregateData()
data.overall.http_codes = {'200':11}
2012-09-12 13:18:58 +00:00
self.foo.core.set_option(self.foo.SECTION, "autostop", "http (200, 10, 5 )\nhttp (3xx, 1.5%, 10m)")
self.foo.configure()
self.foo.prepare_test()
self.foo.start_test()
2012-09-12 15:55:59 +00:00
for n in range(1, 15):
2012-09-12 13:18:58 +00:00
self.foo.aggregate_second(data)
2012-09-12 15:55:59 +00:00
if self.foo.is_test_finished() < 0:
2012-09-12 13:18:58 +00:00
raise RuntimeError()
self.foo.end_test(0)
def test_run_net(self):
2012-09-20 15:45:27 +00:00
data = SecondAggregateData()
data.overall.net_codes = {71:11}
2012-09-12 13:18:58 +00:00
self.foo.core.set_option(self.foo.SECTION, "autostop", "net (71, 1, 5)\nnet (xx, 1.5%, 10m )")
self.foo.configure()
self.foo.prepare_test()
self.foo.start_test()
2012-09-12 15:55:59 +00:00
for n in range(1, 15):
2012-09-12 13:18:58 +00:00
self.foo.aggregate_second(data)
2012-09-12 15:55:59 +00:00
if self.foo.is_test_finished() < 0:
2012-09-12 13:18:58 +00:00
raise RuntimeError()
self.foo.end_test(0)
def test_run_quan(self):
2012-09-20 15:45:27 +00:00
data = SecondAggregateData()
data.overall.quantiles = {99.0:11}
self.foo.core.set_option(self.foo.SECTION, "autostop", "quantile(99,2,3)")
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)
2012-09-25 13:49:53 +00:00
def test_run_false_trigger_bug(self):
data = SecondAggregateData()
data.overall.http_codes = {}
self.foo.core.set_option(self.foo.SECTION, "autostop", "http (5xx, 100%, 1)")
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)
2012-09-12 13:18:58 +00:00
if __name__ == '__main__':
unittest.main()