yandex-tank/Tests/StepperTest.py

47 lines
1.7 KiB
Python
Raw Normal View History

from Tank.Plugins.Stepper import Stepper
from Tests.TankTests import TankTestCase
import tempfile
2012-09-13 13:56:25 +00:00
import os
class StepperTestCase(TankTestCase):
data = None
def test_regular(self):
2012-09-13 15:46:36 +00:00
stepper = Stepper(tempfile.mkstemp()[1])
stepper.ammofile = "data/dummy.ammo"
2012-09-14 16:57:04 +00:00
stepper.rps_schedule = ["const(1,10)"]
2012-09-13 15:46:36 +00:00
stepper.generate_stpd()
2012-09-14 13:47:27 +00:00
res = open(stepper.stpd_file, 'r').read()
2012-09-13 13:56:25 +00:00
self.assertNotEquals("", res)
self.assertEquals(269, os.path.getsize(stepper.stpd_file))
def test_uri(self):
2012-09-13 15:46:36 +00:00
stepper = Stepper(tempfile.mkstemp()[1])
2012-09-14 16:57:04 +00:00
stepper.rps_schedule = ["const(1,10)"]
2012-09-14 13:47:27 +00:00
stepper.uris = ["/", "/test"]
stepper.header_http = "1.1"
stepper.headers = ["[Host: ya.ru]", "[Connection: close]"]
2012-09-13 15:46:36 +00:00
stepper.generate_stpd()
2012-09-14 13:47:27 +00:00
res = open(stepper.stpd_file, 'r').read()
2012-09-13 13:56:25 +00:00
self.assertNotEquals("", res)
self.assertEquals(619, os.path.getsize(stepper.stpd_file))
def test_free_inst_sched(self):
2012-09-13 15:46:36 +00:00
stepper = Stepper(tempfile.mkstemp()[1])
stepper.ammofile = "data/dummy.ammo"
2012-09-13 13:56:25 +00:00
stepper.instances_schedule = "line(1,5,15)"
2012-09-14 13:47:27 +00:00
stepper.loop_limit = 15
2012-09-13 15:46:36 +00:00
stepper.generate_stpd()
2012-09-14 13:47:27 +00:00
res = open(stepper.stpd_file, 'r').read()
2012-09-13 13:56:25 +00:00
self.assertNotEquals("", res)
self.assertEquals(406, os.path.getsize(stepper.stpd_file))
def test_free_inst(self):
2012-09-13 15:46:36 +00:00
stepper = Stepper(tempfile.mkstemp()[1])
stepper.ammofile = "data/dummy.ammo"
stepper.loop_limit = 2
2012-09-13 15:46:36 +00:00
stepper.generate_stpd()
2012-09-14 13:47:27 +00:00
res = open(stepper.stpd_file, 'r').read()
2012-09-13 13:56:25 +00:00
self.assertNotEquals("", res)
self.assertEquals(56, os.path.getsize(stepper.stpd_file))