aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorTaseer <taseer94@gmail.com>2017-03-09 12:05:46 +0500
committerTaseer <taseer94@gmail.com>2017-03-18 12:17:52 +0500
commit04e50e57819bdf40a2fd7abdd3fc7be798771e0b (patch)
treec7028016531c2c4c9152352a066c6b2feeae756a /tests/unit
parent3ce816d42d510ce60ff775f70ef689b1d1d242b2 (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>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/cli/cmd_report.py23
-rw-r--r--tests/unit/cli/cmd_report_test.py91
-rw-r--r--tests/unit/reporter/console_test.py82
3 files changed, 157 insertions, 39 deletions
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