def test_free_inst(self): stepper = Stepper(tempfile.mkstemp()[1]) stepper.ammofile = "data/dummy.ammo" stepper.loop_limit = 2 stepper.generate_stpd() res = open(stepper.stpd_file, 'r').read() self.assertNotEquals("", res) self.assertEquals(56, os.path.getsize(stepper.stpd_file))
def test_uri(self): stepper = Stepper(tempfile.mkstemp()[1]) stepper.rps_schedule = ["const(1,10)"] stepper.uris = ["/", "/test"] stepper.header_http = "1.1" stepper.headers = ["[Host: ya.ru]", "[Connection: close]"] stepper.generate_stpd() res = open(stepper.stpd_file, 'r').read() self.assertNotEquals("", res) self.assertEquals(619, os.path.getsize(stepper.stpd_file))
def test_manual_inst(self): temp_stpd = tempfile.mkstemp()[1] with open(temp_stpd, 'w') as stpd_file: Stepper( instances=20000, rps_schedule=["line(1,5,15)"], http_ver='1.1', uris=["/", "/test"], headers=["[Host: ya.ru]", "[Connection: close]"], ).write(stpd_file) res = open(temp_stpd, 'r').read() self.assertNotEquals("", res) self.assertEquals(2985, os.path.getsize(temp_stpd))
def test_empty_uri(self): from Tank.stepper.module_exceptions import AmmoFileError temp_stpd = tempfile.mkstemp()[1] with open(temp_stpd, 'w') as stpd_file: with self.assertRaises(AmmoFileError): Stepper( rps_schedule=[], instances_schedule=[], loop_limit=-1, ammo_limit=10, headers=[], ammo_file="data/empty.uri", ).write(stpd_file)
def test_free_inst_sched(self): stepper = Stepper(tempfile.mkstemp()[1]) stepper.ammofile = "data/dummy.ammo" stepper.instances_schedule = "line(1,5,15)" stepper.loop_limit = 15 stepper.generate_stpd() res = open(stepper.stpd_file, 'r').read() self.assertNotEquals("", res) self.assertEquals(406, os.path.getsize(stepper.stpd_file))
def test_free_inst_sched(self): temp_stpd = tempfile.mkstemp()[1] with open(temp_stpd, 'w') as stpd_file: Stepper( rps_schedule=[], http_ver='1.1', instances_schedule=["line(1,5,15)"], loop_limit=15, ammo_limit=-1, uris=["/", "/test"], headers=["[Host: ya.ru]", "[Connection: close]"], ).write(stpd_file) res = open(temp_stpd, 'r').read() self.assertNotEquals("", res) self.assertEquals(1900, os.path.getsize(temp_stpd))
def test_uri_style(self): temp_stpd = tempfile.mkstemp()[1] with open(temp_stpd, 'w') as stpd_file: Stepper( rps_schedule=["const(1,10)"], http_ver='1.1', ammo_file="data/uri.ammo", instances_schedule=[], loop_limit=-1, ammo_limit=-1, headers=["[Host: ya.ru]", "[Connection: close]"], ).write(stpd_file) res = open(temp_stpd, 'r').read() self.assertNotEquals("", res) self.assertEquals(1567, os.path.getsize(temp_stpd))
def test_access_log(self): temp_stpd = tempfile.mkstemp()[1] with open(temp_stpd, 'w') as stpd_file: Stepper( rps_schedule=[], instances_schedule=[], loop_limit=-1, ammo_limit=10, ammo_type='access', headers=[], ammo_file="data/access1.log", ).write(stpd_file) res = open(temp_stpd, 'r').read() self.assertNotEquals("", res) self.assertEquals(1459, os.path.getsize(temp_stpd))
def test_chosen_cases(self): temp_stpd = tempfile.mkstemp()[1] with open(temp_stpd, 'w') as stpd_file: Stepper( rps_schedule=["const(1, 10)"], loop_limit=-1, ammo_limit=10, uris=["/one", "/two"], autocases=1, headers=["[Connection: close]"], chosen_cases="_one", ).write(stpd_file) res = open(temp_stpd, 'r').read() self.assertNotEquals("", res) self.assertEquals(res.count('_two'), 0) self.assertEquals(res.count('_one'), 10)
def test_regular(self): temp_stpd = tempfile.mkstemp()[1] with open(temp_stpd, 'w') as stpd_file: Stepper( rps_schedule=["const(1,10)"], http_ver='1.1', ammo_file='data/dummy.ammo', instances_schedule=[], loop_limit=-1, ammo_limit=-1, uris=[], headers=[], autocases=0, ).write(stpd_file) res = open(temp_stpd, 'r').read() self.assertNotEquals("", res) self.assertEquals(277, os.path.getsize(temp_stpd))
def test_regular_gziped(self): """ Call stepper on dummy HTTP ammo file with 1 req. Source ammo file compressed with gzip 1.4 lib. """ temp_stpd = tempfile.mkstemp()[1] with open(temp_stpd, 'w') as stpd_file: Stepper( rps_schedule=["const(1,10)"], http_ver='1.1', ammo_file='data/dummy-ammo-compressed.gz', instances_schedule=[], loop_limit=-1, ammo_limit=-1, uris=[], headers=[], autocases=0, ).write(stpd_file) res = open(temp_stpd, 'r').read() self.assertNotEquals("", res) self.assertEquals(277, os.path.getsize(temp_stpd))