diff options
author | Taseer <taseer94@gmail.com> | 2017-03-09 12:05:46 +0500 |
---|---|---|
committer | Yujun Zhang <zhang.yujunz@zte.com.cn> | 2017-03-21 09:09:10 +0000 |
commit | 19dd4962baca5d7103fe0de55d415e175dbe35e4 (patch) | |
tree | ab416a88be6066a0faefbf6f3d86f0a9d05a3044 | |
parent | 695a881515c40e29fc12eb5003e0f3682bc4d64b (diff) |
Refactor reporter module
- Create templates for report format specific to each metric.
- Outputs the details of the specified metric across all the nodes
in cluster.
- Timeline to be covered in a separate patch
JIRA: QTIP-199
Change-Id: Ic83749725b0c9cc5bd9a7f24f21b2cd113abe0e1
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
(cherry picked from commit 04e50e57819bdf40a2fd7abdd3fc7be798771e0b)
-rw-r--r-- | collector/2017-03-16-20-07/result.json | 265 | ||||
-rw-r--r-- | collector/timeline.json | 39 | ||||
-rw-r--r-- | qtip/cli/commands/cmd_report.py | 8 | ||||
-rw-r--r-- | qtip/reporter/console.py | 34 | ||||
-rw-r--r-- | qtip/reporter/templates/base.j2 | 26 | ||||
-rw-r--r-- | qtip/reporter/templates/dpi.j2 | 5 | ||||
-rw-r--r-- | qtip/reporter/templates/ramspeed.j2 | 13 | ||||
-rw-r--r-- | qtip/reporter/templates/report.j2 | 22 | ||||
-rw-r--r-- | qtip/reporter/templates/ssl.j2 | 21 | ||||
-rw-r--r-- | qtip/reporter/templates/timeline.j2 | 4 | ||||
-rw-r--r-- | qtip/reporter/templates/unixbench.j2 | 10 | ||||
-rw-r--r-- | tests/data/reporter/timeline.pickle | 3 | ||||
-rw-r--r-- | tests/unit/cli/cmd_report.py | 23 | ||||
-rw-r--r-- | tests/unit/cli/cmd_report_test.py | 91 | ||||
-rw-r--r-- | tests/unit/reporter/console_test.py | 82 |
15 files changed, 569 insertions, 77 deletions
diff --git a/collector/2017-03-16-20-07/result.json b/collector/2017-03-16-20-07/result.json new file mode 100644 index 00000000..d26ad400 --- /dev/null +++ b/collector/2017-03-16-20-07/result.json @@ -0,0 +1,265 @@ +{ + "plan_name": "compute_qpi", + "start_time": "2017-03-11-03-14", + "stop_time": "2017-03-11-03-32", + "sut": [ + { + "name": "node-41", + "qpis": [ + { + "benchmarks": [ + { + "name": "ssl", + "cpu_usage": "3%", + "results": { + "aes_128_cbc_1024_bytes": "584709.80k", + "aes_128_cbc_16_bytes": "531050.51k", + "aes_128_cbc_256_bytes": "584951.30k", + "aes_128_cbc_64_bytes": "571063.66k", + "aes_128_cbc_8192_bytes": "584723.11k", + "rsa_sign_1024": "2.6", + "rsa_sign_2048": "9.9", + "rsa_sign_4096": "1.7", + "rsa_sign_512": "0.5", + "rsa_verify_1024": "101616.4", + "rsa_verify_2048": "31104.1", + "rsa_verify_4096": "7688.5", + "rsa_verify_512": "257411.2" + }, + "sysinfo": { + "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1199/3000 MHz", + "disk": "1200.3GB (1.0% used)", + "hostname": "node-41.zte.com.cn", + "kernel": "4.4.0-62-generic x86_64 (64 bit)", + "memory": "4449.9/128524.1MB", + "os": "Ubuntu 16.04 xenial", + "product": "EC600G3" + } + }, + { + "name": "ramspeed", + "cpu_usage": "3%", + "results": { + "float_add": "10217.62", + "float_average": "9176.88", + "float_copy": "8127.13", + "float_scale": "8085.40", + "float_triad": "10277.38", + "integer_add": "11471.63", + "integer_average": "11396.35", + "integer_copy": "11297.18", + "integer_scale": "11316.86", + "integer_triad": "11499.74" + }, + "sysinfo": { + "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1200/3000 MHz", + "disk": "1200.3GB (1.0% used)", + "hostname": "node-41.zte.com.cn", + "kernel": "4.4.0-62-generic x86_64 (64 bit)", + "memory": "4388.3/128524.1MB", + "os": "Ubuntu 16.04 xenial", + "product": "EC600G3" + } + }, + { + "name": "whetstone", + "cpu_usage": "3%", + "results": { + "multi_cpus": { + "num": "40", + "score": "21198.3" + }, + "single_cpu": { + "num": "1", + "score": "633.2" + }, + "total_cpus": "40" + }, + "sysinfo": { + "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1393/3000 MHz", + "disk": "1200.3GB (1.0% used)", + "hostname": "node-41.zte.com.cn", + "kernel": "4.4.0-62-generic x86_64 (64 bit)", + "memory": "4390.1/128524.1MB", + "os": "Ubuntu 16.04 xenial", + "product": "EC600G3" + } + }, + { + "name": "dpi", + "cpu_usage": "3%", + "results": { + "bps": 3.638, + "pps": 1.45 + }, + "sysinfo": { + "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1199/3000 MHz", + "disk": "1200.3GB (1.0% used)", + "hostname": "node-41.zte.com.cn", + "kernel": "4.4.0-62-generic x86_64 (64 bit)", + "memory": "4409.8/128524.1MB", + "os": "Ubuntu 16.04 xenial", + "product": "EC600G3" + } + }, + { + "name": "dhrystone", + "cpu_usage": "3%", + "results": { + "multi_cpus": { + "num": "40", + "score": "63529.6" + }, + "single_cpu": { + "num": "1", + "score": "2981.5" + }, + "total_cpus": "40" + }, + "sysinfo": { + "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1199/3000 MHz", + "disk": "1200.3GB (1.0% used)", + "hostname": "node-41.zte.com.cn", + "kernel": "4.4.0-62-generic x86_64 (64 bit)", + "memory": "4390.9/128524.1MB", + "os": "Ubuntu 16.04 xenial", + "product": "EC600G3" + } + } + ], + "name": "compute_qpi" + } + ], + "type": "baremetal" + }, + { + "name": "node-38", + "qpis": [ + { + "benchmarks": [ + { + "name": "ssl", + "cpu_usage": "3%", + "results": { + "aes_128_cbc_1024_bytes": "654325.42k", + "aes_128_cbc_16_bytes": "602261.15k", + "aes_128_cbc_256_bytes": "663959.64k", + "aes_128_cbc_64_bytes": "650967.68k", + "aes_128_cbc_8192_bytes": "667303.94k", + "rsa_sign_1024": "6.8", + "rsa_sign_2048": "8.8", + "rsa_sign_4096": "7.1", + "rsa_sign_512": "8.5", + "rsa_verify_1024": "100088.3", + "rsa_verify_2048": "31316.4", + "rsa_verify_4096": "8551.8", + "rsa_verify_512": "252476.3" + }, + "sysinfo": { + "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1199/3000 MHz", + "disk": "1200.3GB (1.0% used)", + "hostname": "node-38.zte.com.cn", + "kernel": "4.4.0-62-generic x86_64 (64 bit)", + "memory": "4403.7/128524.1MB", + "os": "Ubuntu 16.04 xenial", + "product": "EC600G3" + } + }, + { + "name": "ramspeed", + "cpu_usage": "3%", + "results": { + "float_add": "10522.33", + "float_average": "9465.11", + "float_copy": "8434.94", + "float_scale": "8436.36", + "float_triad": "10466.82", + "integer_add": "11489.06", + "integer_average": "11466.52", + "integer_copy": "11398.52", + "integer_scale": "11413.87", + "integer_triad": "11564.61" + }, + "sysinfo": { + "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1200/3000 MHz", + "disk": "1200.3GB (1.0% used)", + "hostname": "node-38.zte.com.cn", + "kernel": "4.4.0-62-generic x86_64 (64 bit)", + "memory": "4402.9/128524.1MB", + "os": "Ubuntu 16.04 xenial", + "product": "EC600G3" + } + }, + { + "name": "whetstone", + "cpu_usage": "3%", + "results": { + "multi_cpus": { + "num": "40", + "score": "21194.7" + }, + "single_cpu": { + "num": "1", + "score": "676.6" + }, + "total_cpus": "40" + }, + "sysinfo": { + "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1200/3000 MHz", + "disk": "1200.3GB (1.0% used)", + "hostname": "node-38.zte.com.cn", + "kernel": "4.4.0-62-generic x86_64 (64 bit)", + "memory": "4405.5/128524.1MB", + "os": "Ubuntu 16.04 xenial", + "product": "EC600G3" + } + }, + { + "name": "dpi", + "cpu_usage": "3%", + "results": { + "bps": 3.69, + "pps": 1.458 + }, + "sysinfo": { + "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1200/3000 MHz", + "disk": "1200.3GB (1.0% used)", + "hostname": "node-38.zte.com.cn", + "kernel": "4.4.0-62-generic x86_64 (64 bit)", + "memory": "4418.2/128524.1MB", + "os": "Ubuntu 16.04 xenial", + "product": "EC600G3" + } + }, + { + "name": "dhrystone", + "cpu_usage": "3%", + "results": { + "multi_cpus": { + "num": "40", + "score": "63834.1" + }, + "single_cpu": { + "num": "1", + "score": "3026.2" + }, + "total_cpus": "40" + }, + "sysinfo": { + "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1200/3000 MHz", + "disk": "1200.3GB (1.0% used)", + "hostname": "node-38.zte.com.cn", + "kernel": "4.4.0-62-generic x86_64 (64 bit)", + "memory": "4404.9/128524.1MB", + "os": "Ubuntu 16.04 xenial", + "product": "EC600G3" + } + } + ], + "name": "compute_qpi" + } + ], + "type": "baremetal" + } + ] +} diff --git a/collector/timeline.json b/collector/timeline.json new file mode 100644 index 00000000..dea929e7 --- /dev/null +++ b/collector/timeline.json @@ -0,0 +1,39 @@ +{ + "phases": [{ + "name": "Monitor", + "checkpoints": [{ + "name": "T00", + "timestamp": "1" + }] + }, { + "name": "Inspector", + "checkpoints": [{ + "name": "T01", + "timestamp": "2" + }, { + "name": "T02 ", + "timestamp": "5" + }, { + "name": "T03 ", + "timestamp": "8" + }] + }, { + "name": "Controller", + "checkpoints": [{ + "name": "T04", + "timestamp": "11" + }] + }, { + "name": "Notifier", + "checkpoints": [{ + "name": "T05 ", + "timestamp": "16" + }] + }, { + "name": "Evaluator", + "checkpoints": [{ + "name": "T06 ", + "timestamp": "40" + }] + }] +} diff --git a/qtip/cli/commands/cmd_report.py b/qtip/cli/commands/cmd_report.py index c780e847..cb9c70b6 100644 --- a/qtip/cli/commands/cmd_report.py +++ b/qtip/cli/commands/cmd_report.py @@ -10,6 +10,7 @@ import click from qtip.cli.entry import Context +from qtip.reporter.console import ConsoleReporter pass_context = click.make_pass_decorator(Context, ensure=False) @@ -22,6 +23,9 @@ def cli(ctx): @cli.command('show') +@click.argument('metric') @pass_context -def show(ctx): - pass +def show(ctx, metric): + reporter = ConsoleReporter({}) + report = reporter.render(metric) + click.echo(report) diff --git a/qtip/reporter/console.py b/qtip/reporter/console.py index 2b5130a6..64d677ba 100644 --- a/qtip/reporter/console.py +++ b/qtip/reporter/console.py @@ -7,24 +7,40 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import glob +import json +from os import path + from jinja2 import Environment from jinja2 import FileSystemLoader -from os import path from qtip.base import BaseActor +ROOT_DIR = path.join(path.dirname(__file__), path.pardir, path.pardir) + class ConsoleReporter(BaseActor): - """ - report benchmark result to console - """ + """ report benchmark result to console """ + def __init__(self, config, parent=None): super(ConsoleReporter, self).__init__(config, parent=parent) # TODO (taseer) load template from config - tpl_loader = FileSystemLoader(path.join(path.dirname(__file__), 'templates')) - env = Environment(loader=tpl_loader) - self._template = env.get_template('timeline.j2') + tpl_path = path.join(path.dirname(__file__), 'templates') + tpl_loader = FileSystemLoader(tpl_path) + self._env = Environment(loader=tpl_loader) + self.result_path = path.join(ROOT_DIR, 'collector') + + def load_result(self): + # TODO (taseer) change result directory format more suitable to filter out + result_dirs = glob.glob('{}/20*'.format(self.result_path)) + # select the last (latest) directory for rendering report, result_dirs[-1] + with open(path.join(self.result_path, result_dirs[-1], 'result.json')) as sample: + result = json.load(sample) + return result - def render(self, var_dict): - out = self._template.render(var_dict) + def render(self, metric): + template = self._env.get_template('base.j2') + var_dict = self.load_result() + var_dict['metric_name'] = metric + out = template.render(var_dict) return out diff --git a/qtip/reporter/templates/base.j2 b/qtip/reporter/templates/base.j2 new file mode 100644 index 00000000..26697175 --- /dev/null +++ b/qtip/reporter/templates/base.j2 @@ -0,0 +1,26 @@ +Plan Name: {{ plan_name }} +Start Time: {{ start_time }} +Stop Time: {{ stop_time }} +{%- for sys in sut -%} +{% for qpi in sys.qpis %} +{% for bm in qpi.benchmarks %} +{%- if bm.name == metric_name -%} +{%- if metric_name == 'dhrystone' or metric_name == 'whetstone' -%} +{# TODO (taseer) remove hardcoded material #} +{% include 'unixbench.j2' %} +{% else %} +{% include '%s.j2' % metric_name %} +{%- endif -%} + +System Information: + CPU Brand: {{ bm.sysinfo.cpu }} + Disk: {{ bm.sysinfo.disk }} + Host Name: {{ bm.sysinfo.hostname }} + Kernel: {{ bm.sysinfo.kernel }} + Memory: {{ bm.sysinfo.memory }} + Operating System: {{ bm.sysinfo.os }} + Product: {{ bm.sysinfo.product }} +{%- endif -%} +{%- endfor -%} +{%- endfor -%} +{%- endfor -%}
\ No newline at end of file diff --git a/qtip/reporter/templates/dpi.j2 b/qtip/reporter/templates/dpi.j2 new file mode 100644 index 00000000..758a821e --- /dev/null +++ b/qtip/reporter/templates/dpi.j2 @@ -0,0 +1,5 @@ +Benchmark: {{ bm.name }} +CPU Usage: {{ bm. cpu_usage }} +Results: + Bits per Second: {{ bm.results.bps }} + Packets per Second: {{ bm.results.pps }}
\ No newline at end of file diff --git a/qtip/reporter/templates/ramspeed.j2 b/qtip/reporter/templates/ramspeed.j2 new file mode 100644 index 00000000..d08d7e2e --- /dev/null +++ b/qtip/reporter/templates/ramspeed.j2 @@ -0,0 +1,13 @@ +Benchmark: {{ bm.name }} +CPU Usage: {{ bm. cpu_usage }} +Results: + Float Addition: {{ bm.results.float_add }} + Float Average: {{ bm.results.float_average }} + Float Copy: {{ bm.results.float_copy }} + Float Scale: {{ bm.results.float_scale }} + Float Triad: {{ bm.results.float_triad }} + Integer Addition: {{ bm.results.integer_add }} + Integer Average: {{ bm.results.integer_average }} + Integer Copy: {{ bm.results.integer_copy}} + Integer Scale: {{ bm.results.integer_scale }} + Integer Triad: {{ bm.results.integer_triad}}
\ No newline at end of file diff --git a/qtip/reporter/templates/report.j2 b/qtip/reporter/templates/report.j2 deleted file mode 100644 index 766e6dde..00000000 --- a/qtip/reporter/templates/report.j2 +++ /dev/null @@ -1,22 +0,0 @@ -{{ title }} - -Plan: {{ plan.name }} - -{{ qpi.name }}: {{ qpi.score }} -Sections: -{% for section in sections %} - {{ section.name }}: {{ section.score }} - - Formula: {{ section.formula }} - Metrics: - {% for metric in section.metrics %} - {{ metric.name }}: {{ metric.score }} - Formula: {{ metric.formula }} - Workloads: - {% for workload in workloads %} - {{ workload.name }}: {{ workload.score }} - {% endfor %} - {% endfor %} -{% endfor %} - -{{ signature }} diff --git a/qtip/reporter/templates/ssl.j2 b/qtip/reporter/templates/ssl.j2 new file mode 100644 index 00000000..b46927a8 --- /dev/null +++ b/qtip/reporter/templates/ssl.j2 @@ -0,0 +1,21 @@ +Benchmark: {{ bm.name }} +CPU Usage: {{ bm.cpu_usage }} +Results: + AES 128 CBC (bytes): + 16: {{ bm.results.aes_128_cbc_16_bytes }} + 64: {{ bm.results.aes_128_cbc_64_bytes }} + 256: {{ bm.results.aes_128_cbc_256_bytes }} + 1024: {{ bm.results.aes_128_cbc_1024_bytes }} + 8192: {{ bm.results.aes_128_cbc_8192_bytes }} + + RSA SIGN: + 512: {{ bm.results.rsa_sign_512 }} + 1024: {{ bm.results.rsa_sign_1024 }} + 2048: {{ bm.results.rsa_sign_2048 }} + 4096: {{ bm.results.rsa_sign_4096 }} + + RSA VERIFY: + 512: {{ bm.results.rsa_verify_512 }} + 1024: {{ bm.results.rsa_verify_1024 }} + 2048: {{ bm.results.rsa_verify_2048 }} + 4096: {{ bm.results.rsa_verify_4096 }}
\ No newline at end of file diff --git a/qtip/reporter/templates/timeline.j2 b/qtip/reporter/templates/timeline.j2 index d4c95c46..ccb089e0 100644 --- a/qtip/reporter/templates/timeline.j2 +++ b/qtip/reporter/templates/timeline.j2 @@ -1,8 +1,8 @@ {{ title }} {% for phase in phases %} -{{ phase.name|upper }}{{ "TIME" }} +{{ phase.name|upper }}{{ "TIME"}} {% for cp in phase.checkpoints %} -{{ cp.name }}{{ cp.timestamp}} +{{ cp.name }}{{ cp.timestamp| indent(15, True)}} {% endfor %} {% endfor %} Total: {{ total }} diff --git a/qtip/reporter/templates/unixbench.j2 b/qtip/reporter/templates/unixbench.j2 new file mode 100644 index 00000000..69006da7 --- /dev/null +++ b/qtip/reporter/templates/unixbench.j2 @@ -0,0 +1,10 @@ +Benchmark: {{ bm.name }} +CPU Usage: {{ bm. cpu_usage }} +Results: + Multi CPU: + Number: {{ bm.results.multi_cpus.num }} + Score: {{ bm.results.multi_cpus.score }} + Single CPU: + Number: {{ bm.results.single_cpu.num }} + Score: {{ bm.results.single_cpu.num }} + Total CPUs: {{ bm.results.total_cpus }}
\ No newline at end of file diff --git a/tests/data/reporter/timeline.pickle b/tests/data/reporter/timeline.pickle deleted file mode 100644 index 5c870d93..00000000 --- a/tests/data/reporter/timeline.pickle +++ /dev/null @@ -1,3 +0,0 @@ -VTimeline\u000a\u000aMONITOR TIME\u000a\u000aT00 1\u000a\u000a\u000aINSPECTOR TIME\u000a\u000aT01 2\u000a\u000aT02 5\u000a\u000aT03 8\u000a\u000a\u000aCONTROLLER TIME\u000a\u000aT04 11\u000a\u000a\u000aNOTIFIER TIME\u000a\u000aT05 16\u000a\u000a\u000aEVALUATOR TIME\u000a\u000aT06 40\u000a\u000a\u000aTotal: 312ms -p0 -. diff --git a/tests/unit/cli/cmd_report.py b/tests/unit/cli/cmd_report.py deleted file mode 100644 index e010b960..00000000 --- a/tests/unit/cli/cmd_report.py +++ /dev/null @@ -1,23 +0,0 @@ -############################################################### -# 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 -############################################################################## - -import pytest -from click.testing import CliRunner - -from qtip.cli.entry import cli - - -@pytest.fixture(scope="module") -def runner(): - return CliRunner() - - -def test_show(runner): - result = runner.invoke(cli, ['report', 'show']) - assert result.output == '' diff --git a/tests/unit/cli/cmd_report_test.py b/tests/unit/cli/cmd_report_test.py new file mode 100644 index 00000000..963ce987 --- /dev/null +++ b/tests/unit/cli/cmd_report_test.py @@ -0,0 +1,91 @@ +############################################################### +# Copyright (c) 2017 taseer94@gmail.com 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 +############################################################################## + +import pytest + +from click.testing import CliRunner +from qtip.cli.entry import cli + + +@pytest.fixture(scope="module") +def runner(): + return CliRunner() + + +def test_dhrystone(runner): + """Test dhrystone report""" + + result = runner.invoke(cli, ['report', 'show', 'dhrystone']) + assert "Benchmark: dhrystone" in result.output + assert "CPU Usage: 3%" in result.output + assert "Number: 40" in result.output + assert "Score: 63529.6" in result.output + assert "Single CPU:" in result.output + assert "Total CPUs: 40" in result.output + + +def test_whetstone(runner): + """ Test whetstone output""" + + result = runner.invoke(cli, ['report', 'show', 'whetstone']) + assert "Benchmark: whetstone" in result.output + assert "CPU Usage: 3%" in result.output + assert "Results:" in result.output + assert "Multi CPU:" in result.output + assert "Number: 40" in result.output + assert "Score: 21198.3" in result.output + assert "Single CPU:" in result.output + + +def test_dpi(runner): + """ Test dpi report""" + result = runner.invoke(cli, ['report', 'show', 'dpi']) + assert "Benchmark: dpi" in result.output + assert "CPU Usage: 3%" in result.output + assert "Bits per Second: 3.638" in result.output + assert "Packets per Second: 1.45" in result.output + assert "Bits per Second: 3.69" in result.output + assert "Packets per Second: 1.458" in result.output + + +def test_ramspeed(runner): + """ Test ramspeed report """ + result = runner.invoke(cli, ['report', 'show', 'ramspeed']) + assert "Benchmark: ramspeed" in result.output + assert "CPU Usage: 3%" in result.output + assert "Float Addition: 10217.62" in result.output + assert "Float Average: 9176.88" in result.output + assert "Float Copy: 8127.13" in result.output + assert "Float Scale: 8085.40" in result.output + assert "Float Triad: 10277.38" in result.output + assert "Integer Addition: 11471.63" in result.output + assert "Integer Average: 11396.35" in result.output + + +def test_ssl(runner): + """ Test ssl report""" + + result = runner.invoke(cli, ['report', 'show', 'ssl']) + assert "Benchmark: ssl" in result.output + assert "CPU Usage: 3%" in result.output + assert "AES 128 CBC (bytes):" in result.output + assert "256: 584951.30k" in result.output + assert "RSA SIGN:" in result.output + assert "2048: 9.9" in result.output + assert "RSA VERIFY:" in result.output + assert "4096: 7688.5" in result.output + + +def test_sys(runner): + """ Test sys_info """ + + result = runner.invoke(cli, ['report', 'show', 'ssl']) + assert "System Information:" in result.output + assert "Host Name: node-38.zte.com.cn" in result.output + assert "Memory: 4403.7/128524.1MB" in result.output diff --git a/tests/unit/reporter/console_test.py b/tests/unit/reporter/console_test.py index d2816690..aa7f848b 100644 --- a/tests/unit/reporter/console_test.py +++ b/tests/unit/reporter/console_test.py @@ -7,9 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import pickle import pytest -import os from qtip.reporter.console import ConsoleReporter @@ -23,17 +21,69 @@ def test_constructor(console_reporter): assert isinstance(console_reporter, ConsoleReporter) -def test_render(console_reporter): - var_dict = {'title': 'Timeline', 'total': '312ms', 'phases': [{'name': 'Monitor ', - 'checkpoints': [{'name': 'T00 ', 'timestamp': '1'}]}, - {'name': 'Inspector ', 'checkpoints': [{'name': 'T01 ', 'timestamp': '2'}, - {'name': 'T02 ', 'timestamp': '5'}, {'name': 'T03 ', 'timestamp': '8'}]}, - {'name': 'Controller ', 'checkpoints': [{'name': 'T04 ', 'timestamp': '11'}]}, - {'name': 'Notifier ', 'checkpoints': [{'name': 'T05 ', 'timestamp': '16'}]}, - {'name': 'Evaluator ', 'checkpoints': [{'name': 'T06 ', 'timestamp': '40'}]}]} - - result = console_reporter.render(var_dict=var_dict) - path = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, - os.pardir, 'tests/data/reporter/') - timeline = pickle.load(open(path + 'timeline.pickle', 'rb')) - assert result == timeline +def test_dhrystone(console_reporter): + """ Test dhrystone report""" + + result = console_reporter.render('dhrystone') + assert "Benchmark: dhrystone" in result + assert "Number: 40" in result + assert "Score: 63529.6" in result + assert "Single CPU:" in result + assert "Total CPUs: 40" in result + + +def test_whetstone(console_reporter): + """ Test whetstone output""" + + result = console_reporter.render('whetstone') + assert "Benchmark: whetstone" in result + assert "Results:" in result + assert "Multi CPU:" in result + assert "Number: 40" in result + assert "Score: 21198.3" in result + assert "Single CPU:" in result + + +def test_dpi(console_reporter): + """ Test dpi report""" + + result = console_reporter.render('dpi') + assert "Benchmark: dpi" in result + assert "Bits per Second: 3.638" in result + assert "Packets per Second: 1.45" in result + assert "Bits per Second: 3.69" in result + assert "Packets per Second: 1.458" in result + + +def test_ramspeed(console_reporter): + """ Test ramspeed report """ + + result = console_reporter.render('ramspeed') + assert "Float Addition: 10217.62" in result + assert "Float Average: 9176.88" in result + assert "Float Copy: 8127.13" in result + assert "Float Scale: 8085.40" in result + assert "Float Triad: 10277.38" in result + assert "Integer Addition: 11471.63" in result + assert "Integer Average: 11396.35" in result + + +def test_ssl(console_reporter): + """ Test ssl report""" + + result = console_reporter.render('ssl') + assert "AES 128 CBC (bytes):" in result + assert "256: 584951.30k" in result + assert "RSA SIGN:" in result + assert "2048: 9.9" in result + assert "RSA VERIFY:" in result + assert "4096: 7688.5" in result + + +def test_sys(console_reporter): + """ Test sys_info """ + + result = console_reporter.render('ssl') + assert "System Information:" in result + assert "Host Name: node-38.zte.com.cn" in result + assert "Memory: 4403.7/128524.1MB" in result |