mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-07 10:49:00 +00:00
Nice recursive data cacher
This commit is contained in:
parent
dc80758396
commit
2994aa16bc
@ -18,3 +18,6 @@ class DataCacher(object):
|
||||
def store(self, data):
|
||||
for ts, subtree in data.iteritems():
|
||||
collect_subtree(self.storage, subtree, ts)
|
||||
|
||||
def get_all_data(self):
|
||||
return self.storage
|
||||
|
@ -55,7 +55,7 @@ class OnlineReportPlugin(AbstractPlugin, Thread, AggregateResultListener):
|
||||
|
||||
def prepare_test(self):
|
||||
try:
|
||||
self.server = ReportServer()
|
||||
self.server = ReportServer(self.cache)
|
||||
self.server.owner = self
|
||||
except Exception, ex:
|
||||
self.log.warning("Failed to start web results server: %s", ex)
|
||||
|
@ -29,11 +29,16 @@ class Client(SocketConnection):
|
||||
Client.CONNECTION = None
|
||||
|
||||
class MainHandler(tornado.web.RequestHandler):
|
||||
cacher = None
|
||||
def get(self):
|
||||
self.render("index.jade")
|
||||
if cacher is not None:
|
||||
cached_data = cacher.get_all_data()
|
||||
else:
|
||||
cached_data = {}
|
||||
self.render("index.jade", cached_data=cached_data)
|
||||
|
||||
class ReportServer(object):
|
||||
def __init__(self):
|
||||
def __init__(self, cacher):
|
||||
router = TornadioRouter(Client)
|
||||
self.app = tornado.web.Application(
|
||||
router.apply_routes([(r"/", MainHandler)]),
|
||||
@ -41,6 +46,7 @@ class ReportServer(object):
|
||||
static_path=os.path.join(os.path.dirname(__file__), "static"),
|
||||
debug=True,
|
||||
)
|
||||
MainHandler.cacher = cacher
|
||||
|
||||
def serve(self):
|
||||
def run_server():
|
||||
|
@ -7,5 +7,6 @@ html(lang="en")
|
||||
script(src="static/js/ws.js")
|
||||
body
|
||||
h1.title="Yandex.Tank report"
|
||||
p {{cached_data}}
|
||||
p My beautiful report
|
||||
#msg
|
||||
|
Loading…
Reference in New Issue
Block a user