Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #17 from k0s/15-aux

fixes issues 15 and 16
  • Loading branch information...
commit 40f1cca7944d1fda6644201473302f9dc6cd685f 2 parents f7f59aa + 2a639e8
@malini malini authored
Showing with 49 additions and 8 deletions.
  1. +40 −6 dzclient/client.py
  2. +9 −2 dzclient/tests/test_datazilla_result.py
View
46 dzclient/client.py
@@ -22,25 +22,44 @@ class DatazillaResult(object):
Currently, the results are a dictionary of
{"testsuite":{"testname":[values], ...}}
+
+ Each suite may also have an options dictionary
"""
- def __init__(self, results=None):
+ def __init__(self, results=None, results_aux=None, options=None):
self.results = results or {}
+ self.results_aux = results_aux or {}
+ self.options = options or {}
- def add_testsuite(self, suite_name, results=None):
+ def add_testsuite(self, suite_name, results=None, results_aux=None, options=None):
"""Add a testsuite of {"testname":[values],...} to the results."""
self.results[suite_name] = results or {}
+ self.results_aux[suite_name] = results_aux or {}
+ self.options[suite_name] = options or {}
def add_test_results(self, suite_name, test_name, values):
"""Add a list of result values to the given testsuite/testname pair."""
suite = self.results.setdefault(suite_name, {})
suite.setdefault(test_name, []).extend(values)
+ def add_auxiliary_results(self, suite_name, results_name, values):
+ """Add auxiliary results for a test suite"""
+ suite = self.results_aux.setdefault(suite_name, {})
+ suite.setdefault(results_name, []).extend(values)
+
def join_results(self, results):
- """Add a dictionary of {"suite":{"name":[values], ...}} to results."""
- for suite_name, tests in results.items():
+ """merge an existing DatazillaResult instance with this one"""
+
+ for suite_name, tests in results.results.items():
suite = self.results.setdefault(suite_name, {})
for test_name, values in tests.items():
suite.setdefault(test_name, []).extend(values)
+ for suite_name, results_aux in results.results_aux.items():
+ suite = self.results_aux.setdefault(suite_name, {})
+ for results_name, values in results_aux.items():
+ suite.setdefault(results_name, []).extend(values)
+ for suite_name, options in results.options.items():
+ self.options.setdefault(suite_name, {}).update(options)
+
class DatazillaResultsCollection(object):
"""DatazillaResultsCollection manages test information and serialization to JSON"""
@@ -49,7 +68,16 @@ def __init__(self, machine_name="", os="", os_version="", platform="",
build_name="", version="", revision="", branch="", id="",
test_date=None):
"""
- - id : the build ID for which the dzresults are for; a unique identifier to which these results belong
+ - machine_name: host name of the test machine
+ - os: name of the os of the test machine ('linux', 'win', 'mac')
+ - os_version: long string of os version
+ - platform: processor name, e.g. x86_64
+ - build_name: name of the product under test, e.g. Firefox
+ - version: version of the product under test
+ - revision: source stamp of the product, if available
+ - branch: branch of the product under test
+ - id: the build ID for which the dzresults are for; a unique identifier to which these results belong
+ - test_date: time stamp (seconds since epoch) of the test run, or now if not specified
"""
self.machine_name = machine_name
@@ -68,7 +96,7 @@ def __init__(self, machine_name="", os="", os_version="", platform="",
def add_datazilla_result(self, res):
"""Join a DatazillaResult object to the results."""
- self.results.join_results(res.results)
+ self.results.join_results(res)
def datasets(self):
"""Return the datasets in JSON serializable form"""
@@ -97,6 +125,12 @@ def datasets(self):
dataset = deepcopy(perf_json)
dataset['testrun']['suite'] = suite
dataset['results'] = deepcopy(data)
+ options = self.results.options.get(suite)
+ if options:
+ dataset['testrun']['options'] = deepcopy(options)
+ results_aux = self.results.results_aux.get(suite)
+ if results_aux:
+ dataset['results_aux'] = deepcopy(results_aux)
datasets.append(dataset)
return datasets
View
11 dzclient/tests/test_datazilla_result.py
@@ -34,16 +34,23 @@ def test_add_test_results(self):
self.assertEqual(res.results, {"suite": {"test": [1, 2, 3]}})
+ def test_add_auxiliary_results(self):
+ """Can add auxiliary results to a suite"""
+ res = DatazillaResult()
+ res.add_auxiliary_results("suite", "name", [1, 2, 3])
+ self.assertEqual(res.results_aux, {"suite": {"name": [1, 2, 3]}})
+
+
def test_join_results(self):
"""Can merge a full results dictionary into this result."""
res = DatazillaResult({"suite1": {"test1a": [1]}})
- res.join_results(
+ res.join_results(DatazillaResult(
{
"suite1": {"test1a": [2], "test1b": [3]},
"suite2": {"test2a": [4]},
}
- )
+ ))
self.assertEqual(
res.results,
Please sign in to comment.
Something went wrong with that request. Please try again.