Skip to content

Commit

Permalink
Fix: Made VNF stop commands blocking to ensure correct results
Browse files Browse the repository at this point in the history
processing. sonata-nfv#41

Signed-off-by: peusterm <[email protected]>
  • Loading branch information
peusterm committed Dec 14, 2018
1 parent d54815b commit 97cd135
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/peds/ped_suricata_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ service_experiments:
- name: "service_throughput"
description: "iperf test for entire service"
repetitions: 1
time_limit: 10 # seconds per experiment
time_limit: 60 #60 # seconds per experiment
# NSD to be used (vendor.name.version reference)
target:
vendor: "de.upb"
Expand Down
12 changes: 8 additions & 4 deletions src/tngsdk/benchmark/pdriver/vimemu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@


# global configurations
WAIT_SHUTDOWN_TIME = 5 # FIXME give experiment some cooldown time
WAIT_SHUTDOWN_TIME = 2 # FIXME give experiment some cooldown time
WAIT_PADDING_TIME = 3 # FIXME extra time to wait (to have some buffer)
PATH_SHARE = "/tngbench_share"
PATH_CMD_START_LOG = "cmd_start.log"
Expand Down Expand Up @@ -120,6 +120,7 @@ def execute_experiment(self, ec):
# 5. mp_out_cmd_stop
# 6. vnf_cmd_stop
# FIXME make this user-configurable and more flexible
LOG.debug("Executing start commands inside containers ...")
for vnf_cname, cmd in vnf_cmd_start_dict.items():
self.emudocker.execute(vnf_cname, cmd,
os.path.join(PATH_SHARE,
Expand All @@ -132,14 +133,17 @@ def execute_experiment(self, ec):
# hold execution for manual debugging:
if self.args.hold_and_wait_for_user:
input("Press Enter to continue...")
LOG.debug("Executing stop commands inside containers ...")
self.emudocker.execute(MP_IN_NAME, mp_in_cmd_stop,
os.path.join(PATH_SHARE, PATH_CMD_STOP_LOG))
os.path.join(PATH_SHARE,
PATH_CMD_STOP_LOG), block=True)
self.emudocker.execute(MP_OUT_NAME, mp_out_cmd_stop,
os.path.join(PATH_SHARE, PATH_CMD_STOP_LOG))
os.path.join(PATH_SHARE,
PATH_CMD_STOP_LOG), block=True)
for vnf_cname, cmd in vnf_cmd_stop_dict.items():
self.emudocker.execute(vnf_cname, cmd,
os.path.join(PATH_SHARE,
PATH_CMD_STOP_LOG))
PATH_CMD_STOP_LOG), block=True)
self._wait_time(WAIT_SHUTDOWN_TIME,
"Finalizing experiment '{}'".format(ec))
# wait for monitoring thread to finalize
Expand Down
10 changes: 7 additions & 3 deletions src/tngsdk/benchmark/pdriver/vimemu/dockerc.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, endpoint):
LOG.error("Stopping.")
exit(1)

def execute(self, container_name, cmd, logfile):
def execute(self, container_name, cmd, logfile, block=False):
"""
Run command on container.
Non blocking.
Expand All @@ -82,9 +82,13 @@ def execute(self, container_name, cmd, logfile):
c = self.client.containers.get(container_name)
assert(c is not None)
# build full cmd
cmd = "bash -c 'nohup {} > {} 2>&1 &'".format(cmd, logfile)
postfix = ""
if not block:
postfix = " &"
cmd = "bash -c 'nohup {} > {} 2>&1{}'".format(cmd, logfile, postfix)
# execute command in target container (blocks if detach=False)
rcode, rdata = c.exec_run(cmd, stdin=False, stdout=False, detach=False)
rcode, rdata = c.exec_run(
cmd, stdin=False, stdout=False, detach=(not block))
LOG.debug("Out (empty in detach mode): return code: {}; stdout: '{}'"
.format(rcode, rdata))
LOG.debug("Top on '{}': {}".format(container_name, c.top()))
Expand Down

0 comments on commit 97cd135

Please sign in to comment.