aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools
diff options
context:
space:
mode:
authorpmikus <peter.mikus@protonmail.ch>2022-12-09 08:50:06 +0000
committerPeter Mikus <peter.mikus@protonmail.ch>2023-01-11 08:37:32 +0000
commit86138e3eb1fbaad89eb1f91937ae6bd6ba55da37 (patch)
tree16c1ae44048315cebdafd1025722df9a2f6f623f /resources/tools
parent89c40769ccf9558024a23a4de1563355a39db5a8 (diff)
feat(model): Hoststack type
Signed-off-by: pmikus <peter.mikus@protonmail.ch> Change-Id: Ia7eefc28645c78ad346d294099ef6258faa9814f
Diffstat (limited to 'resources/tools')
-rwxr-xr-xresources/tools/ab/ABFork.py4
-rw-r--r--resources/tools/ab/ABTools.py87
2 files changed, 29 insertions, 62 deletions
diff --git a/resources/tools/ab/ABFork.py b/resources/tools/ab/ABFork.py
index 8436ed38be..55288a9c92 100755
--- a/resources/tools/ab/ABFork.py
+++ b/resources/tools/ab/ABFork.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# Copyright (c) 2021 Intel and/or its affiliates.
+# Copyright (c) 2023 Intel and/or its affiliates.
# 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:
@@ -136,7 +136,7 @@ def main():
# Output results.
print(f"Transfer Rate: {round(info_list[6], 2)} [Kbytes/sec]")
print(f"Latency: {round(info_list[4] / 8, 2)} ms")
- print(f"Connection {mode} rate:{round(info_list[3], 2)} per sec")
+ print(f"Connection {mode} rate: {round(info_list[3], 2)} per sec")
print(f"Total data transferred: {round(info_list[2])} bytes")
print(f"Completed requests: {round(info_list[0])} ")
print(f"Failed requests: {round(info_list[1])} ")
diff --git a/resources/tools/ab/ABTools.py b/resources/tools/ab/ABTools.py
index 54aff19e92..f3e97a720a 100644
--- a/resources/tools/ab/ABTools.py
+++ b/resources/tools/ab/ABTools.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2022 Intel and/or its affiliates.
+# Copyright (c) 2023 Intel and/or its affiliates.
# 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:
@@ -13,11 +13,13 @@
"""ab implementation into CSIT framework."""
-from robot.api import logger
-from resources.libraries.python.topology import NodeType
from resources.libraries.python.Constants import Constants
-from resources.libraries.python.ssh import exec_cmd_no_error
+from resources.libraries.python.model.ExportResult import (
+ export_hoststack_results
+)
from resources.libraries.python.OptionString import OptionString
+from resources.libraries.python.ssh import exec_cmd_no_error
+from resources.libraries.python.topology import NodeType
class ABTools:
@@ -153,66 +155,31 @@ class ABTools:
port=port,
mode=rps_cps,
)
- stdout, _ = exec_cmd_no_error(tg_node, cmd, timeout=180, sudo=True,
- message=u"ab runtime error!")
- log_msg = ABTools._parse_ab_output(stdout, rps_cps, tls_tcp)
-
- logger.info(log_msg)
-
- return log_msg
-
- @staticmethod
- def _parse_ab_output(msg, rps_cps, tls_tcp):
- """Parse the ab stdout with the results.
-
- :param msg: Ab Stdout.
- :param rps_cps: RPS or CPS.
- :param tls_tcp: TLS or TCP.
- :type msg: str
- :type rps_cps: str
- :type tls_tcp: str
- :return: Message with measured data.
- :rtype: str
- """
-
- msg_lst = msg.splitlines(keepends=False)
-
- total_cps = u""
- latency = u""
- processing = u""
- complete_req = u""
- failed_req = u""
- total_bytes = u""
- rate = u""
-
- if tls_tcp == u"tls":
- log_msg = u"\nMeasured HTTPS values:\n"
- else:
- log_msg = u"\nMeasured HTTP values:\n"
+ stdout, _ = exec_cmd_no_error(
+ tg_node, cmd, timeout=180, sudo=True, message=u"ab runtime error!"
+ )
- for line in msg_lst:
+ rate_unit = rps_cps
+ rate = None
+ bandwidth = None
+ latency = None
+ completed_requests = None
+ failed_requests = None
+ for line in stdout.splitlines():
if f"Connection {rps_cps} rate:" in line:
- # rps (cps)
- total_cps = line + u"\n"
+ rate = float(line.split(u" ")[3])
elif u"Transfer Rate:" in line:
- # Rate
- rate = line + u"\n"
+ bandwidth = float(line.split(u" ")[2]) * 8000
elif u"Latency:" in line:
- # Latency
- latency = line + u"\n"
- elif u"Total data transferred" in line:
- total_bytes = line + u"\n"
- elif u"Completed requests" in line:
- complete_req = line + u"\n"
+ latency = float(line.split(u" ")[1])
+ elif u"Completed requests:" in line:
+ completed_requests = int(line.split(u" ")[2])
elif u"Failed requests" in line:
- failed_req = line + u"\n"
+ failed_requests = int(line.split(u" ")[2])
- log_msg += rate
- log_msg += latency
- log_msg += processing
- log_msg += complete_req
- log_msg += failed_req
- log_msg += total_bytes
- log_msg += total_cps
+ export_hoststack_results(
+ rate, rate_unit, bandwidth, latency, failed_requests,
+ completed_requests
+ )
- return log_msg
+ return stdout