Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chg: dev: Collecting docker coredumps on teardown and adding checks for p4 simulator #19

Merged
merged 1 commit into from
Sep 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/topology_docker_openswitch/openswitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from subprocess import check_call, check_output, call, CalledProcessError
from socket import AF_UNIX, SOCK_STREAM, socket, gethostname

import re
import yaml

config_timeout = 300
Expand Down Expand Up @@ -155,6 +156,17 @@ def create_interfaces():
.format(hwport=hwport)))
check_call('{ns_exec} ip link set dev {hwport} up'
.format(**locals()), shell=True)
for i in range(0, config_timeout):
link_state = check_output(
'{ns_exec} ip link show {hwport}'
.format(**locals()), shell=True)
if "UP" in link_state:
break;
else:
sleep(0.1)
else:
raise Exception('Emulns interface did not came up...')

out = check_output(
'{ns_exec} echo port_add {hwport} '
' {port} | {ns_exec} '
Expand All @@ -167,6 +179,12 @@ def create_interfaces():
)
logging.info('BM port creation...')
logging.info(out)
re_str = r''''\s*Control utility for runtime P4 table \
manipulation\s*\nRuntimeCmd:\s*\nRuntimeCmd:\s*$''' #noqa

if re.findall(re_str, out, re.MULTILINE) is None:
raise Exception('Control utility for runtime P4 table '
'failed...')
except Exception as error:
raise Exception(
'Failed to map ports with port labels: {}'.format(
Expand Down
18 changes: 18 additions & 0 deletions lib/topology_docker_openswitch/plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ def pytest_runtest_teardown(item):
)
)

try:
core_files = join('/var/diagnostics/coredump', 'core.*')
files = node_obj.send_command('ls {}'.format(core_files),
shell='bash').splitlines()

if len(files) > 0:
for file in files:
path = '/tmp'
node_obj.send_command('cp {file} {path}'
.format(**locals()),
shell='bash')
except:
warning(
'Unable to get coredumps from node {}.'.format(
node_obj.identifier
)
)

try:
copytree(shared_dir, join(path_name, basename(shared_dir)))
rmtree(shared_dir)
Expand Down