aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/cmd
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2017-01-12 07:50:30 +0000
committerchenjiankun <chenjiankun1@huawei.com>2017-01-20 01:58:50 +0000
commit75f55c05789beb4fbe2391d33349058bba4ea5c0 (patch)
tree7372165d15f83de442fa2a5778ee540ae2ced7c0 /yardstick/cmd
parent8f4cc883d89e997320d68c653a12d59f8fba308b (diff)
Create API to get a list of all test cases
JIRA: YARDSTICK-456 Currently we do not have a API to get a list of all test cases; Currently the test case info is from the comment; So I create a API to get a list of all test cases; And create a 'description' attribute to record info of a test case; And use the CLI call this API; Change-Id: Ife800600446683664097835c7b9f11899c85771d Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'yardstick/cmd')
-rw-r--r--yardstick/cmd/commands/__init__.py12
-rw-r--r--yardstick/cmd/commands/testcase.py21
2 files changed, 28 insertions, 5 deletions
diff --git a/yardstick/cmd/commands/__init__.py b/yardstick/cmd/commands/__init__.py
index 5c5356736..9bc0e9fac 100644
--- a/yardstick/cmd/commands/__init__.py
+++ b/yardstick/cmd/commands/__init__.py
@@ -1,10 +1,20 @@
from __future__ import absolute_import
from yardstick.benchmark.core import Param
+from api import client
def change_osloobj_to_paras(args):
param = Param({})
- for k in param.__dict__:
+ for k in vars(param):
if hasattr(args, k):
setattr(param, k, getattr(args, k))
return param
+
+
+class Commands(object):
+ def __init__(self):
+ self.client = client
+
+ def _change_to_dict(self, args):
+ p = Param({})
+ return {k: getattr(args, k) for k in vars(p) if hasattr(args, k)}
diff --git a/yardstick/cmd/commands/testcase.py b/yardstick/cmd/commands/testcase.py
index bd17b1aa5..a151871b3 100644
--- a/yardstick/cmd/commands/testcase.py
+++ b/yardstick/cmd/commands/testcase.py
@@ -9,14 +9,16 @@
""" Handler for yardstick command 'testcase' """
from __future__ import print_function
-
from __future__ import absolute_import
+
from yardstick.benchmark.core.testcase import Testcase
+from yardstick.benchmark.core import print_hbar
from yardstick.common.utils import cliargs
from yardstick.cmd.commands import change_osloobj_to_paras
+from yardstick.cmd.commands import Commands
-class TestcaseCommands(object):
+class TestcaseCommands(Commands):
"""Testcase commands.
Set of commands to discover and display test cases.
@@ -24,11 +26,22 @@ class TestcaseCommands(object):
def do_list(self, args):
"""List existing test cases"""
- param = change_osloobj_to_paras(args)
- Testcase().list_all(param)
+ testcase_list = self.client.get('/yardstick/testcases')['result']
+ self._format_print(testcase_list)
@cliargs("casename", type=str, help="test case name", nargs=1)
def do_show(self, args):
"""Show details of a specific test case"""
param = change_osloobj_to_paras(args)
Testcase().show(param)
+
+ def _format_print(self, testcase_list):
+ """format output"""
+
+ print_hbar(88)
+ print("| %-21s | %-60s" % ("Testcase Name", "Description"))
+ print_hbar(88)
+ for testcase_record in testcase_list:
+ print("| %-16s | %-60s" % (testcase_record['Name'],
+ testcase_record['Description']))
+ print_hbar(88)