2012-09-13 12:10:34 +00:00
|
|
|
from Tank.Plugins.Stepper import Stepper
|
2012-09-13 13:11:01 +00:00
|
|
|
from Tests.TankTests import TankTestCase
|
|
|
|
import tempfile
|
2012-09-13 13:56:25 +00:00
|
|
|
import os
|
2012-09-13 12:10:34 +00:00
|
|
|
|
|
|
|
class StepperTestCase(TankTestCase):
|
|
|
|
data = None
|
|
|
|
|
2012-09-13 13:11:01 +00:00
|
|
|
def test_regular(self):
|
2012-09-13 15:46:36 +00:00
|
|
|
stepper = Stepper(tempfile.mkstemp()[1])
|
2012-09-13 13:11:01 +00:00
|
|
|
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))
|
2012-09-13 13:11:01 +00:00
|
|
|
|
|
|
|
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))
|
2012-09-13 13:11:01 +00:00
|
|
|
|
|
|
|
def test_free_inst_sched(self):
|
2012-09-13 15:46:36 +00:00
|
|
|
stepper = Stepper(tempfile.mkstemp()[1])
|
2012-09-13 13:11:01 +00:00
|
|
|
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))
|
2012-09-13 13:11:01 +00:00
|
|
|
|
|
|
|
def test_free_inst(self):
|
2012-09-13 15:46:36 +00:00
|
|
|
stepper = Stepper(tempfile.mkstemp()[1])
|
2012-09-13 13:11:01 +00:00
|
|
|
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))
|