diff options
author | DanielMartinBuckley <daniel.m.buckley@intel.com> | 2018-02-16 15:39:41 +0000 |
---|---|---|
committer | Abhijit Sinha <abhijit.sinha@intel.com> | 2018-02-28 11:40:09 +0000 |
commit | b0b7366493d0dabf5d886c6eea07cd0fc055264d (patch) | |
tree | b24731fb733f18c7779a4d7ebb4d8734af55636a /yardstick/network_services | |
parent | a301d172e9b7df272a882e88407c8e14cfed2b62 (diff) |
Addition of storage of extra counters for Grafana
JIRA: YARDSTICK-1036
This stores a number of extra counters in influxdb for Prox test cases.
It also stores existing counters with a "succcess_" tag.
Previously throughput where stored without success or failure indication.
Also "Result_" counters are also stored.
These can now be used by Grafana to graph output.
Change-Id: Ie5636c14ecbab1b53a988bdfbd47ddd1fcdbd695
Signed-off-by: Daniel Martin Buckley <daniel.m.buckley@intel.com>
Diffstat (limited to 'yardstick/network_services')
3 files changed, 98 insertions, 21 deletions
diff --git a/yardstick/network_services/traffic_profile/prox_binsearch.py b/yardstick/network_services/traffic_profile/prox_binsearch.py index 1fd6ec41a..5700f98e5 100644 --- a/yardstick/network_services/traffic_profile/prox_binsearch.py +++ b/yardstick/network_services/traffic_profile/prox_binsearch.py @@ -16,6 +16,8 @@ from __future__ import absolute_import import logging +import datetime +import time from yardstick.network_services.traffic_profile.prox_profile import ProxProfile @@ -81,19 +83,66 @@ class ProxBinSearchProfile(ProxProfile): # success, the binary search will complete on an integer multiple # of the precision, rather than on a fraction of it. + theor_max_thruput = 0 + + result_samples = {} + + # Store one time only value in influxdb + single_samples = { + "test_duration" : traffic_gen.scenario_helper.scenario_cfg["runner"]["duration"], + "test_precision" : self.params["traffic_profile"]["test_precision"], + "tolerated_loss" : self.params["traffic_profile"]["tolerated_loss"], + "duration" : duration + } + self.queue.put(single_samples) + self.prev_time = time.time() + # throughput and packet loss from the most recent successful test successful_pkt_loss = 0.0 for test_value in self.bounds_iterator(LOG): result, port_samples = self._profile_helper.run_test(pkt_size, duration, test_value, self.tolerated_loss) + self.curr_time = time.time() + diff_time = self.curr_time - self.prev_time + self.prev_time = self.curr_time if result.success: LOG.debug("Success! Increasing lower bound") self.current_lower = test_value successful_pkt_loss = result.pkt_loss + samples = result.get_samples(pkt_size, successful_pkt_loss, port_samples) + samples["TxThroughput"] = samples["TxThroughput"] * 1000 * 1000 + + # store results with success tag in influxdb + success_samples = {'Success_' + key: value for key, value in samples.items()} + + success_samples["Success_rx_total"] = int(result.rx_total / diff_time) + success_samples["Success_tx_total"] = int(result.tx_total / diff_time) + success_samples["Success_can_be_lost"] = int(result.can_be_lost / diff_time) + success_samples["Success_drop_total"] = int(result.drop_total / diff_time) + self.queue.put(success_samples) + + # Store Actual throughput for result samples + result_samples["Result_Actual_throughput"] = \ + success_samples["Success_RxThroughput"] else: LOG.debug("Failure... Decreasing upper bound") self.current_upper = test_value + samples = result.get_samples(pkt_size, successful_pkt_loss, port_samples) + + for k in samples: + tmp = samples[k] + if isinstance(tmp, dict): + for k2 in tmp: + samples[k][k2] = int(samples[k][k2] / diff_time) - samples = result.get_samples(pkt_size, successful_pkt_loss, port_samples) + if theor_max_thruput < samples["TxThroughput"]: + theor_max_thruput = samples['TxThroughput'] + self.queue.put({'theor_max_throughput': theor_max_thruput}) + + LOG.debug("Collect TG KPIs %s %s", datetime.datetime.now(), samples) self.queue.put(samples) + + result_samples["Result_pktSize"] = pkt_size + result_samples["Result_theor_max_throughput"] = theor_max_thruput/ (1000 * 1000) + self.queue.put(result_samples) diff --git a/yardstick/network_services/vnf_generic/vnf/prox_helpers.py b/yardstick/network_services/vnf_generic/vnf/prox_helpers.py index 285ead3b6..61775b963 100644 --- a/yardstick/network_services/vnf_generic/vnf/prox_helpers.py +++ b/yardstick/network_services/vnf_generic/vnf/prox_helpers.py @@ -929,6 +929,7 @@ class ProxResourceHelper(ClientResourceHelper): func = getattr(self.sut, cmd, None) if func: return func(*args, **kwargs) + return None def _connect(self, client=None): """Run and connect to prox on the remote system """ @@ -1005,11 +1006,18 @@ class ProxDataHelper(object): def samples(self): samples = {} for port_name, port_num in self.vnfd_helper.ports_iter(): - port_rx_total, port_tx_total = self.sut.port_stats([port_num])[6:8] - samples[port_name] = { - "in_packets": port_rx_total, - "out_packets": port_tx_total, - } + try: + port_rx_total, port_tx_total = self.sut.port_stats([port_num])[6:8] + samples[port_name] = { + "in_packets": port_rx_total, + "out_packets": port_tx_total, + } + except (KeyError, TypeError, NameError, MemoryError, ValueError, + SystemError, BufferError): + samples[port_name] = { + "in_packets": 0, + "out_packets": 0, + } return samples def __enter__(self): @@ -1127,7 +1135,7 @@ class ProxProfileHelper(object): for key, value in section: if key == "mode" and value == mode: core_tuple = CoreSocketTuple(section_name) - core = core_tuple.find_in_topology(self.cpu_topology) + core = core_tuple.core_id cores.append(core) return cores @@ -1149,6 +1157,10 @@ class ProxProfileHelper(object): :return: return lat_min, lat_max, lat_avg :rtype: list """ + + if not self._latency_cores: + self._latency_cores = self.get_cores(self.PROX_CORE_LAT_MODE) + if self._latency_cores: return self.sut.lat_stats(self._latency_cores) return [] @@ -1198,12 +1210,12 @@ class ProxMplsProfileHelper(ProxProfileHelper): if item_value.startswith("tag"): core_tuple = CoreSocketTuple(section_name) - core_tag = core_tuple.find_in_topology(self.cpu_topology) + core_tag = core_tuple.core_id cores_tagged.append(core_tag) elif item_value.startswith("udp"): core_tuple = CoreSocketTuple(section_name) - core_udp = core_tuple.find_in_topology(self.cpu_topology) + core_udp = core_tuple.core_id cores_plain.append(core_udp) return cores_tagged, cores_plain @@ -1276,23 +1288,23 @@ class ProxBngProfileHelper(ProxProfileHelper): if item_value.startswith("cpe"): core_tuple = CoreSocketTuple(section_name) - cpe_core = core_tuple.find_in_topology(self.cpu_topology) + cpe_core = core_tuple.core_id cpe_cores.append(cpe_core) elif item_value.startswith("inet"): core_tuple = CoreSocketTuple(section_name) - inet_core = core_tuple.find_in_topology(self.cpu_topology) + inet_core = core_tuple.core_id inet_cores.append(inet_core) elif item_value.startswith("arp"): core_tuple = CoreSocketTuple(section_name) - arp_core = core_tuple.find_in_topology(self.cpu_topology) + arp_core = core_tuple.core_id arp_cores.append(arp_core) # We check the tasks/core separately if item_value.startswith("arp_task"): core_tuple = CoreSocketTuple(section_name) - arp_task_core = core_tuple.find_in_topology(self.cpu_topology) + arp_task_core = core_tuple.core_id arp_tasks_core.append(arp_task_core) return cpe_cores, inet_cores, arp_cores, arp_tasks_core @@ -1455,12 +1467,12 @@ class ProxVpeProfileHelper(ProxProfileHelper): if item_value.startswith("cpe"): core_tuple = CoreSocketTuple(section_name) - core_tag = core_tuple.find_in_topology(self.cpu_topology) + core_tag = core_tuple.core_id cpe_cores.append(core_tag) elif item_value.startswith("inet"): core_tuple = CoreSocketTuple(section_name) - inet_core = core_tuple.find_in_topology(self.cpu_topology) + inet_core = core_tuple.core_id inet_cores.append(inet_core) return cpe_cores, inet_cores @@ -1639,7 +1651,7 @@ class ProxlwAFTRProfileHelper(ProxProfileHelper): continue core_tuple = CoreSocketTuple(section_name) - core_tag = core_tuple.find_in_topology(self.cpu_topology) + core_tag = core_tuple.core_id for item_value in (v for k, v in section if k == 'name'): if item_value.startswith('tun'): tun_cores.append(core_tag) diff --git a/yardstick/network_services/vnf_generic/vnf/prox_vnf.py b/yardstick/network_services/vnf_generic/vnf/prox_vnf.py index b7d295eee..ee7735972 100644 --- a/yardstick/network_services/vnf_generic/vnf/prox_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/prox_vnf.py @@ -14,6 +14,8 @@ import errno import logging +import datetime +import time from yardstick.common.process import check_if_process_failed @@ -39,6 +41,9 @@ class ProxApproxVnf(SampleVNF): if resource_helper_type is None: resource_helper_type = ProxResourceHelper + self.prev_packets_in = 0 + self.prev_packets_sent = 0 + self.prev_time = time.time() super(ProxApproxVnf, self).__init__(name, vnfd, setup_env_helper_type, resource_helper_type) @@ -79,12 +84,13 @@ class ProxApproxVnf(SampleVNF): raise RuntimeError("Failed ..Invalid no of ports .. " "1, 2 or 4 ports only supported at this time") - port_stats = self.vnf_execute('port_stats', range(port_count)) + self.port_stats = self.vnf_execute('port_stats', range(port_count)) + curr_time = time.time() try: - rx_total = port_stats[6] - tx_total = port_stats[7] + rx_total = self.port_stats[6] + tx_total = self.port_stats[7] except IndexError: - LOG.error("port_stats parse fail %s", port_stats) + LOG.debug("port_stats parse fail ") # return empty dict so we don't mess up existing KPIs return {} @@ -96,7 +102,17 @@ class ProxApproxVnf(SampleVNF): # collectd KPIs here and not TG KPIs, so use a different method name "collect_stats": self.resource_helper.collect_collectd_kpi(), } - LOG.debug("%s collect KPIs %s", self.APP_NAME, result) + curr_packets_in = int((rx_total - self.prev_packets_in) / (curr_time - self.prev_time)) + curr_packets_fwd = int((tx_total - self.prev_packets_sent) / (curr_time - self.prev_time)) + + result["curr_packets_in"] = curr_packets_in + result["curr_packets_fwd"] = curr_packets_fwd + + self.prev_packets_in = rx_total + self.prev_packets_sent = tx_total + self.prev_time = curr_time + + LOG.debug("%s collect KPIs %s %s", self.APP_NAME, datetime.datetime.now(), result) return result def _tear_down(self): |