X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fcmd%2FNSBperf.py;h=5d0aa746d14a30d40fbbe28c02ea2469daeee573;hb=b2971b66a73ed9068697920eddf6a17cfc0e4a0c;hp=c3730f8344acdace3c3a0bd73b9a8b345d8cd397;hpb=dd8ca59fd7421a1f362e50f0d3413a903761d179;p=yardstick.git diff --git a/yardstick/cmd/NSBperf.py b/yardstick/cmd/NSBperf.py index c3730f834..5d0aa746d 100755 --- a/yardstick/cmd/NSBperf.py +++ b/yardstick/cmd/NSBperf.py @@ -24,28 +24,19 @@ import argparse import json import subprocess import signal - +from oslo_serialization import jsonutils from six.moves import input CLI_PATH = os.path.dirname(os.path.realpath(__file__)) REPO_PATH = os.path.abspath(os.path.join(CLI_PATH, os.pardir)) -PYTHONPATH = os.environ.get("PYTHONPATH", False) -VIRTUAL_ENV = os.environ.get("VIRTUAL_ENV", False) - -if not PYTHONPATH or not VIRTUAL_ENV: - print("Please setup env PYTHONPATH & VIRTUAL_ENV environment varaible.") - raise SystemExit(1) - -def handler(): +def sigint_handler(*args, **kwargs): """ Capture ctrl+c and exit cli """ subprocess.call(["pkill", "-9", "yardstick"]) raise SystemExit(1) -signal.signal(signal.SIGINT, handler) - class YardstickNSCli(object): """ This class handles yardstick network serivce testing """ @@ -117,20 +108,22 @@ class YardstickNSCli(object): and generates final report in rst format. """ + tc_name = os.path.splitext(test_case)[0] report_caption = '{}\n{} ({})\n{}\n\n'.format( '================================================================', - 'Performance report for', - os.path.splitext(test_case)[0].upper(), + 'Performance report for', tc_name.upper(), '================================================================') print(report_caption) if os.path.isfile("/tmp/yardstick.out"): lines = [] with open("/tmp/yardstick.out") as infile: - lines = infile.readlines() + lines = jsonutils.load(infile) if lines: - tc_res = json.loads(lines.pop(len(lines) - 1)) - for key, value in tc_res["benchmark"]["data"].items(): + lines = \ + lines['result']["testcases"][tc_name]["tc_data"] + tc_res = lines.pop(len(lines) - 1) + for key, value in tc_res["data"].items(): self.generate_kpi_results(key, value) self.generate_nfvi_results(value) @@ -157,8 +150,24 @@ class YardstickNSCli(object): testcases = os.listdir(test_path + vnf) print(("VNF :(%s)" % vnf)) print("================") - for testcase in [tc for tc in testcases if "tc" in tc]: - print('%s' % testcase) + test_cases = [tc for tc in testcases if "tc_" in tc and "template" not in tc] + + print("\tBareMetal Testcase:") + print("\t===================") + for testcase in [tc for tc in test_cases if "baremetal" in tc]: + print("\t%s" % testcase) + + print(os.linesep) + print("\tStandalone Virtualization Testcase:") + print("\t===================================") + for testcase in [tc for tc in test_cases if "ovs" in tc or "sriov" in tc]: + print("\t%s" % testcase) + + print(os.linesep) + print("\tOpenstack Testcase:") + print("\t===================") + for testcase in [tc for tc in test_cases if "heat" in tc]: + print("\t%s" % testcase) print(os.linesep) raise SystemExit(0) @@ -213,5 +222,6 @@ class YardstickNSCli(object): self.run_test(args, test_path) if __name__ == "__main__": + signal.signal(signal.SIGINT, sigint_handler) NS_CLI = YardstickNSCli() NS_CLI.main()