aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/wrk/wrk.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2018-01-10 15:48:25 +0100
committerJan Gelety <jgelety@cisco.com>2018-01-16 09:06:34 +0000
commit54ad6efd342695d0a7dad5380cc989a8d846f518 (patch)
tree96a4f2f0cdc4696302113d89c955250e5ecfea76 /resources/tools/wrk/wrk.py
parent5f153c5987d9774dc67063cb4aaff352ac785ba3 (diff)
CSIT-898: WRK improvments
Change-Id: I92aafaaedce5891727a983b8cf024a0fb0db7524 Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/wrk/wrk.py')
-rw-r--r--resources/tools/wrk/wrk.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/resources/tools/wrk/wrk.py b/resources/tools/wrk/wrk.py
index 33cfd08174..a891fd6ae9 100644
--- a/resources/tools/wrk/wrk.py
+++ b/resources/tools/wrk/wrk.py
@@ -16,6 +16,9 @@
import re
+from copy import deepcopy
+from time import sleep
+
from robot.api import logger
from resources.libraries.python.ssh import SSH
@@ -100,17 +103,19 @@ def destroy_wrk(tg_node):
raise RuntimeError('Removal of wrk from the TG node failed.')
-def run_wrk(tg_node, profile_name, tg_numa, test_type):
+def run_wrk(tg_node, profile_name, tg_numa, test_type, warm_up=False):
"""Send the traffic as defined in the profile.
:param tg_node: Traffic generator node.
:param profile_name: The name of wrk traffic profile.
:param tg_numa: Numa node on which wrk will run.
:param test_type: The type of the tests: cps, rps, bw
+ :param warm_up: If True, warm-up traffic is generated before test traffic.
:type profile_name: str
:type tg_node: dict
:type tg_numa: int
:type test_type: str
+ :type warm_up: bool
:returns: Message with measured data.
:rtype: str
:raises: RuntimeError if node type is not a TG.
@@ -140,6 +145,9 @@ def run_wrk(tg_node, profile_name, tg_numa, test_type):
str(profile["latency"]),
"'{0}'".format(" ".join(profile["urls"]))
]
+ if warm_up:
+ warm_up_params = deepcopy(params)
+ warm_up_params[4] = "10s"
elif len(profile["urls"]) == profile["cpus"]:
params = [
"traffic_n_urls_n_cores",
@@ -153,6 +161,9 @@ def run_wrk(tg_node, profile_name, tg_numa, test_type):
str(profile["latency"]),
"'{0}'".format(" ".join(profile["urls"]))
]
+ if warm_up:
+ warm_up_params = deepcopy(params)
+ warm_up_params[4] = "10s"
else:
params = [
"traffic_n_urls_m_cores",
@@ -167,11 +178,24 @@ def run_wrk(tg_node, profile_name, tg_numa, test_type):
str(profile["latency"]),
"'{0}'".format(" ".join(profile["urls"]))
]
+ if warm_up:
+ warm_up_params = deepcopy(params)
+ warm_up_params[5] = "10s"
+
args = " ".join(params)
ssh = SSH()
ssh.connect(tg_node)
+ if warm_up:
+ warm_up_args = " ".join(warm_up_params)
+ ret, _, _ = ssh.exec_command(
+ "{0}/resources/tools/wrk/wrk_utils.sh {1}".
+ format(Constants.REMOTE_FW_DIR, warm_up_args), timeout=1800)
+ if int(ret) != 0:
+ raise RuntimeError('wrk runtime error.')
+ sleep(60)
+
ret, stdout, _ = ssh.exec_command(
"{0}/resources/tools/wrk/wrk_utils.sh {1}".
format(Constants.REMOTE_FW_DIR, args), timeout=1800)
@@ -190,7 +214,7 @@ def run_wrk(tg_node, profile_name, tg_numa, test_type):
log_msg += "Requests/sec: Avg / Stdev / Max / +/- Stdev\n"
for item in stats["rps-stats-lst"]:
log_msg += "{0} / {1} / {2} / {3}\n".format(*item)
- log_msg += "Total rps: {0}cps\n".format(stats["rps-sum"])
+ log_msg += "Total rps: {0}rps\n".format(stats["rps-sum"])
elif test_type == "bw":
log_msg += "Transfer/sec: {0}Bps".format(stats["bw-sum"])