Commit eb7b920d authored by Arnaud Fontaine's avatar Arnaud Fontaine

Move creation/closing of Benchmark Result document to ERP5BenchmarkResult


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@45941 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b2834258
...@@ -313,6 +313,7 @@ class CSVBenchmarkResult(BenchmarkResult): ...@@ -313,6 +313,7 @@ class CSVBenchmarkResult(BenchmarkResult):
from cStringIO import StringIO from cStringIO import StringIO
import xmlrpclib import xmlrpclib
import datetime
class ERP5BenchmarkResult(BenchmarkResult): class ERP5BenchmarkResult(BenchmarkResult):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
...@@ -348,6 +349,28 @@ class ERP5BenchmarkResult(BenchmarkResult): ...@@ -348,6 +349,28 @@ class ERP5BenchmarkResult(BenchmarkResult):
def __exit__(self, exc_type, exc_value, traceback): def __exit__(self, exc_type, exc_value, traceback):
super(ERP5BenchmarkResult, self).__exit__(exc_type, exc_value, traceback) super(ERP5BenchmarkResult, self).__exit__(exc_type, exc_value, traceback)
@staticmethod
def createResultDocument(publish_url, publish_project, repeat, nb_users):
test_result_module = xmlrpclib.ServerProxy(publish_url,
verbose=True,
allow_none=True)
# TODO: range of users?
benchmark_result = test_result_module.TestResultModule_addBenchmarkResult(
'%d repeat with %d concurrent users' % (repeat, nb_users),
publish_project, ' '.join(sys.argv), datetime.datetime.now())
return benchmark_result['id']
@staticmethod
def closeResultDocument(publish_document_url, error_message_set):
result = xmlrpclib.ServerProxy(publish_document_url,
verbose=True,
allow_none=True)
result.BenchmarkResult_completed(error_message_set and 'FAIL' or 'PASS',
error_message_set)
import multiprocessing import multiprocessing
import csv import csv
import traceback import traceback
......
...@@ -32,10 +32,9 @@ import argparse ...@@ -32,10 +32,9 @@ import argparse
import os import os
import sys import sys
import multiprocessing import multiprocessing
import datetime
import xmlrpclib import xmlrpclib
from benchmark import ArgumentType, BenchmarkProcess from benchmark import ArgumentType, BenchmarkProcess, ERP5BenchmarkResult
class PerformanceTester(object): class PerformanceTester(object):
def __init__(self, namespace=None): def __init__(self, namespace=None):
...@@ -177,39 +176,18 @@ class PerformanceTester(object): ...@@ -177,39 +176,18 @@ class PerformanceTester(object):
if not self._argument_namespace.erp5_publish_url: if not self._argument_namespace.erp5_publish_url:
return return
test_result_module = xmlrpclib.ServerProxy(
self._argument_namespace.erp5_publish_url, verbose=True, allow_none=True)
# TODO: range of users?
benchmark_result = test_result_module.TestResultModule_addBenchmarkResult(
'%d repeat with %d concurrent users' % (self._argument_namespace.repeat,
self._argument_namespace.users),
self._argument_namespace.erp5_publish_project,
' '.join(sys.argv),
datetime.datetime.now())
try:
benchmark_result_id = benchmark_result['id']
except:
raise RuntimeError, "Cannot create the benchmark result"
self._argument_namespace.erp5_publish_url += \ self._argument_namespace.erp5_publish_url += \
'test_result_module/%s' % benchmark_result_id ERP5BenchmarkResult.createResultDocument(self._argument_namespace.erp5_publish_url,
self._argument_namespace.erp5_publish_project,
self._argument_namespace.repeat,
self._argument_namespace.users)
def postRun(self, error_message_set): def postRun(self, error_message_set):
if not self._argument_namespace.erp5_publish_url: if not self._argument_namespace.erp5_publish_url:
return return
if error_message_set: ERP5BenchmarkResult.closeResultDocument(self._argument_namespace.erp5_publish_url,
result = 'FAIL' error_message_set)
else:
result = 'PASS'
benchmark_result = xmlrpclib.ServerProxy(
self._argument_namespace.erp5_publish_url,
verbose=True, allow_none=True)
benchmark_result.BenchmarkResult_completed(result, error_message_set)
def _run_constant(self, nb_users): def _run_constant(self, nb_users):
process_list = [] process_list = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment