Open Alpherie opened 4 years ago
Some more info, that may be useful: My python code for bfg:
# -*- coding: utf-8 -*-
import os
import json
import logging
log = logging.getLogger(__name__)
import requests as r
class LoadTest(object):
def __init__(self, gun):
self.gun = gun
self.addr = self.gun.get_option("address")
def case1(self, missile):
with self.gun.measure('test') as m:
try:
res = r.post(self.addr)
except r.exceptions.Timeout:
m['proto_code'] = 601
except Exception:
m['proto_code'] = 602
else:
m['proto_code'] = res.status_code
try:
log.info(res.content)
except Exception:
log.info('Error!!!')
def setup(self, param):
''' this will be executed in each worker before the test starts '''
pass
def teardown(self):
''' this will be executed in each worker after the end of the test '''
os._exit(0)
return 0
Test target I made for this problem (python3):
import time
import datetime
import random
import tornado.ioloop
import tornado.web
import tornado.locks
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
@tornado.web.asynchronous
async def post(self):
condition = tornado.locks.Condition()
await condition.wait(datetime.timedelta(seconds=random.randint(10, 20)))
self.write('Test answer')
def make_app():
return tornado.web.Application([
(r"/.*", MainHandler),
])
if __name__ == "__main__":
print('Started')
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
When the response times are high (15-20s), yandextank loses some of statistics. For example, tank had made 28 requests (according to logs), but only 22 are displayed in stats. Sometimes even more is lost, with 3-5 requests only displayed.
Version of tank: YandexTank/1.12.6
My log: tmp_log.txt
My config: