1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
"""
vsperf2dashboard
"""
# Copyright 2015-2017 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import csv
import logging
import requests
def results2opnfv_dashboard(results_path, int_data):
"""
the method open the csv file with results and calls json encoder
"""
testcases = os.listdir(results_path)
for test in testcases:
if not ".csv" in test:
continue
resfile = results_path + '/' + test
with open(resfile, 'r') as in_file:
reader = csv.DictReader(in_file)
_push_results(reader, int_data)
def _push_results(reader, int_data):
"""
the method encodes results and sends them into opnfv dashboard
"""
db_url = int_data['db_url']
url = db_url + "/results"
casename = ""
version_ovs = ""
version_dpdk = ""
version = ""
allowed_pkt = ["64", "128", "512", "1024", "1518"]
details = {"64": '', "128": '', "512": '', "1024": '', "1518": ''}
test_start = None
test_stop = None
for row_reader in reader:
if allowed_pkt.count(row_reader['packet_size']) == 0:
logging.error("The framesize is not supported in opnfv dashboard")
continue
# test execution time includes all frame sizes, so start & stop time
# is the same (repeated) for every framesize in CSV file
if test_start is None:
test_start = row_reader['start_time']
test_stop = row_reader['stop_time']
casename = _generate_test_name(row_reader['id'], int_data)
if "back2back" in row_reader['id']:
details[row_reader['packet_size']] = row_reader['b2b_frames']
else:
details[row_reader['packet_size']] = row_reader['throughput_rx_fps']
# Create version field
with open(int_data['pkg_list'], 'r') as pkg_file:
for line in pkg_file:
if "OVS_TAG" in line:
version_ovs = line.replace(' ', '')
version_ovs = version_ovs.replace('OVS_TAG?=', '')
if "DPDK_TAG" in line:
if int_data['vanilla'] is False:
version_dpdk = line.replace(' ', '')
version_dpdk = version_dpdk.replace('DPDK_TAG?=', '')
else:
version_dpdk = "not used"
version = "OVS " + version_ovs.replace('\n', '') + " DPDK " + version_dpdk.replace('\n', '')
# Build body
body = {"project_name": "vsperf",
"scenario": "vsperf",
"start_date": test_start,
"stop_date": test_stop,
"case_name": casename,
"pod_name": int_data['pod'],
"installer": int_data['installer'],
"version": version,
"build_tag": int_data['build_tag'],
"criteria": int_data['criteria'],
"details": details}
my_data = requests.post(url, json=body)
logging.info("Results for %s sent to opnfv, http response: %s", casename, my_data)
logging.debug("opnfv url: %s", db_url)
logging.debug("the body sent to opnfv")
logging.debug(body)
def _generate_test_name(testcase, int_data):
"""
the method generates testcase name for releng
"""
vanilla = int_data['vanilla']
res_name = ""
names = {'phy2phy_tput': ["tput_ovsdpdk", "tput_ovs"],
'back2back': ["b2b_ovsdpdk", "b2b_ovs"],
'phy2phy_tput_mod_vlan': ["tput_mod_vlan_ovsdpdk", "tput_mod_vlan_ovs"],
'phy2phy_cont': ["cont_ovsdpdk", "cont_ovs"],
'pvp_cont': ["pvp_cont_ovsdpdkuser", "pvp_cont_ovsvirtio"],
'pvvp_cont': ["pvvp_cont_ovsdpdkuser", "pvvp_cont_ovsvirtio"],
'phy2phy_scalability': ["scalability_ovsdpdk", "scalability_ovs"],
'pvp_tput': ["pvp_tput_ovsdpdkuser", "pvp_tput_ovsvirtio"],
'pvp_back2back': ["pvp_b2b_ovsdpdkuser", "pvp_b2b_ovsvirtio"],
'pvvp_tput': ["pvvp_tput_ovsdpdkuser", "pvvp_tput_ovsvirtio"],
'pvvp_back2back': ["pvvp_b2b_ovsdpdkuser", "pvvp_b2b_ovsvirtio"],
'phy2phy_cpu_load': ["cpu_load_ovsdpdk", "cpu_load_ovs"],
'phy2phy_mem_load': ["mem_load_ovsdpdk", "mem_load_ovs"]}
for name, name_list in names.items():
if name != testcase:
continue
if vanilla is True:
res_name = name_list[1]
else:
res_name = name_list[0]
break
return res_name
|