-# Copyright (c) 2016 Cisco and/or its affiliates.
+# Copyright (c) 2018 Cisco 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:
from resources.libraries.python.ssh import SSH
from resources.libraries.python.constants import Constants as con
from resources.libraries.python.topology import NodeType
+from resources.libraries.python.topology import Topology
__all__ = ["SetupDPDKTest"]
def pack_framework_dir():
- """Pack the testing WS into temp file, return its name."""
+ """Pack the testing WS into temp file, return its name.
+
+ :raise RuntimeError: If command returns nonzero return code."""
tmpfile = NamedTemporaryFile(suffix=".tgz", prefix="DPDK-testing-")
file_name = tmpfile.name
return_code = proc.wait()
if return_code != 0:
- raise Exception("Could not pack testing framework.")
+ raise RuntimeError("Could not pack testing framework.")
return file_name
:type tarball: str
:type node: dict
:returns: nothing
+ :raise RuntimeError: If command returns nonzero return code.
"""
logger.console('Extracting tarball to {0} on {1}'.format(
con.REMOTE_FW_DIR, node['host']))
(ret_code, _, stderr) = ssh.exec_command(cmd, timeout=30)
if ret_code != 0:
logger.error('Unpack error: {0}'.format(stderr))
- raise Exception('Failed to unpack {0} at node {1}'.format(
+ raise RuntimeError('Failed to unpack {0} at node {1}'.format(
tarball, node['host']))
:param node: Dictionary created from topology, will only install in the TG
:type node: dict
:returns: nothing
+ :raise RuntimeError: If command returns nonzero return code.
"""
logger.console('Extracting virtualenv, installing requirements.txt '
'on {0}'.format(node['host']))
.format(con.REMOTE_FW_DIR), timeout=100)
if ret_code != 0:
logger.error('Virtualenv creation error: {0}'.format(stdout + stderr))
- raise Exception('Virtualenv setup failed')
+ raise RuntimeError('Virtualenv setup failed')
else:
logger.console('Virtualenv created on {0}'.format(node['host']))
:param node: Dictionary created from topology
:type node: dict
:returns: nothing
+ :raise RuntimeError: If command returns nonzero return code.
"""
- logger.console('Install the DPDK on {0}'.format(node['host']))
+ arch = Topology.get_node_arch(node)
+ logger.console('Install the DPDK on {0} ({1})'.format(node['host'],
+ arch))
ssh = SSH()
ssh.connect(node)
(ret_code, _, stderr) = ssh.exec_command(
- 'cd {0}/dpdk-tests/dpdk_scripts/ && ./install_dpdk.sh'
- .format(con.REMOTE_FW_DIR), timeout=600)
+ 'cd {0}/tests/dpdk/dpdk_scripts/ && ./install_dpdk.sh {1}'
+ .format(con.REMOTE_FW_DIR, arch), timeout=600)
if ret_code != 0:
logger.error('Install the DPDK error: {0}'.format(stderr))
- raise Exception('Install the DPDK failed')
+ raise RuntimeError('Install the DPDK failed')
else:
logger.console('Install the DPDK on {0} success!'.format(node['host']))
-#pylint: disable=broad-except
def setup_node(args):
"""Run all set-up methods for a node.
:rtype: bool
"""
tarball, remote_tarball, node = args
+
+ # if unset, arch defaults to x86_64
+ if 'arch' not in node or not node['arch']:
+ node['arch'] = 'x86_64'
+
try:
copy_tarball_to_node(tarball, node)
extract_tarball_at_node(remote_tarball, node)
install_dpdk_test(node)
if node['type'] == NodeType.TG:
create_env_directory_at_node(node)
- except Exception as exc:
+ except RuntimeError as exc:
logger.error("Node setup failed, error:'{0}'".format(exc.message))
return False
else:
'Executed node setups in parallel, waiting for processes to end')
result.wait()
- logger.info('Results: {0}'.format(result.get()))
+ results = result.get()
+ node_setup_success = all(results)
+ logger.info('Results: {0}'.format(results))
logger.trace('Test framework copied to all topology nodes')
delete_local_tarball(tarball)
- logger.console('All nodes are ready')
-
+ if node_setup_success:
+ logger.console('All nodes are ready')
+ else:
+ logger.console('Failed to setup dpdk on all the nodes')