Added simple HTML reporting
Simple HTML reporting for executed tests
Added the simple HTML reporting for the executed tests:
firstly the text result tables are saved to the CSV files,
and then they are converted to a single HTML report.
The generation of the report is using “pandas” and “jinja2"
modules. The CSS styles are using Mirantis style guides.
The Jijna template and the CSS styles are stored in the
‘templates/’ folder.
The ‘glance_speed_test’ output is improved and is using
a similar text table as the other tests.
At the end of each test case, the results are saved to
a new CSV file named after the test case in the ‘reports/’
folder. If the test is rerun, the new CSV is created
instead of the old one. In the end of the execution of
the tests, a single HTML report is created from all CSV
files in the ‘reports/’ folder.
Related-PROD: PROD-36943
Change-Id: Iceff8b168364219a01b60546bb9908e01d61c434
diff --git a/tests/test_glance.py b/tests/test_glance.py
index 85d070d..1b6f973 100644
--- a/tests/test_glance.py
+++ b/tests/test_glance.py
@@ -6,6 +6,9 @@
import time
import utils
+from utils import helpers
+
+from texttable import Texttable
logger = logging.getLogger(__name__)
@@ -40,7 +43,8 @@
subprocess.call('rm -f /tmp/image_mk_framework.download', shell=True)
-def test_speed_glance(create_image, openstack_clients, record_property):
+def test_speed_glance(create_image, openstack_clients,
+ request, html_report):
"""
Simplified Performance Tests Download / upload Glance
1. Create file with random data (dd)
@@ -48,6 +52,9 @@
3. Download image.
4. Measure download/upload speed and print them into stdout
"""
+ result_table = Texttable(max_width=120)
+ table_rows = [["Test Speed Glance", "Image Size", "Time Consumed",
+ "Result"]]
image_size_megabytes = utils.get_configuration().get("IMAGE_SIZE_MB")
if not is_parsable(image_size_megabytes, int):
pytest.fail("Can't convert IMAGE_SIZE_MB={} to 'int'".format(
@@ -80,7 +87,12 @@
"Occurred error: {}".format(e))
end_time = time.time()
- speed_upload = image_size_megabytes / (end_time - start_time)
+ time_diff = end_time - start_time
+ speed_upload = image_size_megabytes / time_diff
+ table_rows.append(["Upload",
+ "{} MB".format(image_size_megabytes),
+ "{} s".format(round(time_diff, 3)),
+ "{} MB/s".format(round(speed_upload, 2))])
logger.info("Testing download file speed...")
start_time = time.time()
@@ -89,13 +101,18 @@
image_file.write(item)
end_time = time.time()
- speed_download = image_size_megabytes / (end_time - start_time)
+ time_diff = end_time - start_time
+ speed_download = image_size_megabytes / time_diff
+ table_rows.append(["Download",
+ "{} MB".format(image_size_megabytes),
+ "{} s".format(round(time_diff, 3)),
+ "{} MB/s".format(round(speed_download, 2))])
logger.info("Deleted image {}.".format(image.id))
openstack_clients.image.images.delete(image.id)
- record_property("Upload", speed_upload)
- record_property("Download", speed_download)
- sys.stdout.write("\n++++++++++++++++++++++++++++++++++++++++")
- sys.stdout.write(('\nupload - {} MB/s'.format(speed_upload)))
- sys.stdout.write(('\ndownload - {} MB/s'.format(speed_download)))
- sys.stdout.write("\n++++++++++++++++++++++++++++++++++++++++\n")
+ result_table.add_rows(table_rows)
+ sys.stdout.write('\n{}\n'.format(result_table.draw()))
+
+ # Send the results to CSV file at reports/ directory
+ helpers.create_test_result_table_csv_file(
+ table_rows, request.node.name)
diff --git a/tests/test_vm2vm.py b/tests/test_vm2vm.py
index 44b584e..8a94600 100644
--- a/tests/test_vm2vm.py
+++ b/tests/test_vm2vm.py
@@ -6,6 +6,7 @@
from texttable import Texttable
import utils
+from utils import helpers
from utils import os_client
from utils import ssh
@@ -13,7 +14,7 @@
logger = logging.getLogger(__name__)
-def test_vm2vm(openstack_clients, pair, os_resources, record_property):
+def test_vm2vm(openstack_clients, pair, os_resources, request, html_report):
"""
Simplified Performance Tests VM to VM test in different topologies
1. Create 4 VMs admin project
@@ -208,6 +209,10 @@
result_table.add_rows(table_rows)
sys.stdout.write('\n{}\n'.format(result_table.draw()))
+ # Send the results to CSV file at reports/ directory
+ helpers.create_test_result_table_csv_file(
+ table_rows, request.node.name)
+
logger.info("Removing VMs and FIPs...")
for vm in vms:
openstack_clients.compute.servers.delete(vm)
diff --git a/tests/test_vm2vm_different_routers.py b/tests/test_vm2vm_different_routers.py
index 8d20090..31c4478 100644
--- a/tests/test_vm2vm_different_routers.py
+++ b/tests/test_vm2vm_different_routers.py
@@ -6,6 +6,7 @@
from texttable import Texttable
import utils
+from utils import helpers
from utils import os_client
from utils import ssh
@@ -15,8 +16,7 @@
def test_vm2vm_different_project_different_routers(
openstack_clients, openstack_alt_clients, pair,
- os_resources, os_resources_alt_project,
- record_property):
+ os_resources, os_resources_alt_project, request, html_report):
"""
Simplified Performance Tests VM to VM test in different projects, different
networks, different routers, measure by Floating IPs (common floating net):
@@ -226,6 +226,10 @@
result_table.add_rows(table_rows)
sys.stdout.write('\n{}\n'.format(result_table.draw()))
+ # Send the results to CSV file at reports/ directory
+ helpers.create_test_result_table_csv_file(
+ table_rows, request.node.name)
+
logger.info("Removing VMs and FIPs...")
for vm in vms:
openstack_clients.compute.servers.delete(vm)