diff options
author | Yujun Zhang <zhang.yujunz@zte.com.cn> | 2016-12-06 16:30:11 +0800 |
---|---|---|
committer | Yujun Zhang <zhang.yujunz@zte.com.cn> | 2016-12-06 16:46:18 +0800 |
commit | 89e3f17d136f80c5406cdaff67d33b4c8159aac4 (patch) | |
tree | fafd3500be2b055c09d25e0f04bdd46202d3010e /qtip/runner | |
parent | ab5e5f5d602c4e5c84f99c2b5ba3b97d3379f5cf (diff) |
Implement TestPlan prototype
Refactor common part of Suite to Benchmark since both TestPlan
and Suite are organized by files
Change-Id: I61a97d9489096c4a6305c99e8cf7abb958faa562
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'qtip/runner')
-rw-r--r-- | qtip/runner/benchmark.py | 56 | ||||
-rw-r--r-- | qtip/runner/suite.py | 51 | ||||
-rw-r--r-- | qtip/runner/testplan.py | 21 |
3 files changed, 65 insertions, 63 deletions
diff --git a/qtip/runner/benchmark.py b/qtip/runner/benchmark.py new file mode 100644 index 00000000..46cb069d --- /dev/null +++ b/qtip/runner/benchmark.py @@ -0,0 +1,56 @@ +############################################################################## +# Copyright (c) 2016 ZTE Corp and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +from itertools import chain +from os import listdir +from os import path + + +class Property: + NAME = 'name' + DESCRIPTION = 'description' + ABSPATH = 'abspath' + + +class Benchmark: + """Abstract class of QTIP benchmarks""" + + # paths to search for suites + _paths = [path.join(path.dirname(__file__), path.pardir, path.pardir, + 'benchmarks')] + + def __init__(self, name): + """:param name: suite name""" + # TODO(yujunz) check existence and expand to full path + self.name = name + self._abspath = self._find(name) + + def _find(self, name): + """find a benchmark in searching paths""" + for p in self._paths: + abspath = path.join(p, name) + if path.exists(abspath): + return abspath + return None + + @classmethod + def list_all(cls): + """list all available benchmarks""" + names = chain.from_iterable([listdir(p) for p in cls._paths]) + return [Benchmark(name).describe() for name in names] + + def describe(self): + """description of benchmark""" + # TODO(yujunz) + # - read description from benchmark content + return { + Property.NAME: self.name, + Property.DESCRIPTION: 'QTIP benchmark', + Property.ABSPATH: self._abspath + } diff --git a/qtip/runner/suite.py b/qtip/runner/suite.py index 1892bb28..4179af64 100644 --- a/qtip/runner/suite.py +++ b/qtip/runner/suite.py @@ -7,58 +7,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -from itertools import chain -from os import listdir from os import path +from benchmark import Benchmark -class SuiteProperty: - NAME = 'name' - DESCRIPTION = 'description' - ABSPATH = 'abspath' - -class Suite: +class Suite(Benchmark): """A suite is consist of one or several perf tests and produces one QPI""" # paths to search for suites - _paths = [path.join(path.dirname(__file__), path.pardir, path.pardir, - 'benchmarks', 'suite')] - - def __init__(self, name): - """:param name: suite name""" - # TODO(yujunz) check existence and expand to full path - self.name = name - self._abspath = self._find(name) - - def _find(self, name): - """find a suite in searching paths""" - for p in self._paths: - abspath = path.join(p, name) - if path.exists(abspath): - return abspath - return None - - @classmethod - def list_all(cls): - """list all available suites""" - suite_names = chain.from_iterable([listdir(p) for p in cls._paths]) - return [Suite(name).describe() for name in suite_names] - - def describe(self): - """description of benchmark suite""" - # TODO(yujunz) - # - read description from suite content - # - verbose mode including even more details - # - referred perftests - # - formula of QPI calculation - # - baseline description - return { - SuiteProperty.NAME: self.name, - SuiteProperty.DESCRIPTION: 'QTIP benchmark suite', - SuiteProperty.ABSPATH: self._abspath - } - - def run(self): - """run included perftests in the suite""" - pass + _paths = [path.join(p, 'suite') for p in Benchmark._paths] diff --git a/qtip/runner/testplan.py b/qtip/runner/testplan.py index d20221df..57f3c978 100644 --- a/qtip/runner/testplan.py +++ b/qtip/runner/testplan.py @@ -7,22 +7,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from os import path -class TestPlan: - """A test plan is consist of test configuration and selected test suites""" +from benchmark import Benchmark - def __init__(self): - pass - @staticmethod - def list_all(): - """list all available test plans""" - pass +class TestPlan(Benchmark): + """A suite is consist of one or several perf tests and produces one QPI""" - def desc(self): - """description of the test plan""" - pass - - def run(self): - """run included suites""" - pass + # paths to search for suites + _paths = [path.join(p, 'testplan') for p in Benchmark._paths] |