aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/virl/bin/start-testcase
diff options
context:
space:
mode:
authorAndrej Kilvady <andrej.kilvady@pantheon.tech>2017-10-26 13:46:18 +0200
committerJan Gelety <jgelety@cisco.com>2018-03-16 08:35:10 +0000
commit237ac98ad0cca7a24e3f38ec9f8b73c106a8b00a (patch)
treeb88fab524c778e91aa260a5fb59a47a7950be874 /resources/tools/virl/bin/start-testcase
parentf491bc6a03bae995321dc912661c4c628f4d156f (diff)
VPP install and verify in __init__.robot
Move VPP installation to separate test in test suite setup phase to clearly indicate any issue with VPP installation. Added test to check VPP responsiveness after installation. Change-Id: Idc2c78152e23aa7301bb5dbf9b1b6f4b639c3e84 Signed-off-by: Andrej Kilvady <andrej.kilvady@pantheon.tech>
Diffstat (limited to 'resources/tools/virl/bin/start-testcase')
-rwxr-xr-xresources/tools/virl/bin/start-testcase112
1 files changed, 62 insertions, 50 deletions
diff --git a/resources/tools/virl/bin/start-testcase b/resources/tools/virl/bin/start-testcase
index f6c3cc32b8..ce47378188 100755
--- a/resources/tools/virl/bin/start-testcase
+++ b/resources/tools/virl/bin/start-testcase
@@ -32,6 +32,7 @@ import requests
IPS_PER_SIMULATION = 5
+
def indent(lines, amount, fillchar=' '):
"""Indent the string by amount of fill chars.
@@ -47,6 +48,7 @@ def indent(lines, amount, fillchar=' '):
padding = amount * fillchar
return padding + ('\n'+padding).join(lines.split('\n'))
+
def print_to_stderr(msg, end='\n'):
"""Writes any text to stderr.
@@ -60,6 +62,7 @@ def print_to_stderr(msg, end='\n'):
except ValueError:
pass
+
def get_assigned_interfaces(args, network="flat"):
"""Retrieve assigned interfaces in openstack network.
@@ -81,6 +84,7 @@ def get_assigned_interfaces(args, network="flat"):
"Status other than 200 HTTP OK:\n{}"
.format(req.content))
+
def get_assigned_interfaces_count(args, network="flat"):
"""Count assigned interfaces in openstack network.
@@ -93,6 +97,7 @@ def get_assigned_interfaces_count(args, network="flat"):
"""
return len(get_assigned_interfaces(args, network=network))
+
def check_ip_addresses(args):
"""Check IP address availability.
@@ -101,8 +106,8 @@ def check_ip_addresses(args):
:raises RuntimeError: If not enough free addresses available.
"""
for i in range(args.wait_count):
- if (args.quota - \
- get_assigned_interfaces_count(args) >= IPS_PER_SIMULATION):
+ if (args.quota -
+ get_assigned_interfaces_count(args) >= IPS_PER_SIMULATION):
break
if args.verbosity >= 2:
print_to_stderr("DEBUG: - Attempt {} out of {}, waiting for free "
@@ -112,6 +117,7 @@ def check_ip_addresses(args):
else:
raise RuntimeError("ERROR: Not enough IP addresses to run simulation")
+
def check_virl_resources(args):
"""Check virl resources availability.
@@ -125,6 +131,8 @@ def check_virl_resources(args):
# function executed in sequence. This should be broken down into multiple
# functions.
#
+
+
def main():
""" Main function."""
#
@@ -189,6 +197,8 @@ def main():
parser.add_argument("-q", "--quota",
help="VIRL quota for max number of allowed IPs",
type=int, default=74)
+ parser.add_argument("-si", "--skip-install", help="Skip VPP installation",
+ action='store_true')
args = parser.parse_args()
@@ -216,14 +226,15 @@ def main():
#
# Check if VPP package exists
#
- for package in args.packages:
- if args.verbosity >= 2:
- print_to_stderr("DEBUG: Checking if file {} exists"
- .format(package))
- if not os.path.isfile(package):
- print_to_stderr("ERROR: Debian package {} does not exist"
- .format(package))
- sys.exit(1)
+ if not args.skip_install:
+ for package in args.packages:
+ if args.verbosity >= 2:
+ print_to_stderr("DEBUG: Checking if file {} exists"
+ .format(package))
+ if not os.path.isfile(package):
+ print_to_stderr("ERROR: Required package {} does not exist"
+ .format(package))
+ sys.exit(1)
#
# Start VIRL topology
@@ -496,46 +507,47 @@ def main():
#
# Upgrade VPP
#
- if args.verbosity >= 1:
- print_to_stderr("DEBUG: Uprading VPP")
-
- for key1 in nodeaddrs:
- if not key1 == 'tg':
- for key2 in nodeaddrs[key1]:
- ipaddr = nodeaddrs[key1][key2]
- if args.verbosity >= 2:
- print_to_stderr("DEBUG: Upgrading VPP on node {}"
- .format(ipaddr))
- paramiko.util.log_to_file(os.path.join(scratch_directory,
- "ssh.log"))
- client = paramiko.SSHClient()
- client.load_system_host_keys()
- client.load_host_keys("/dev/null")
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client.connect(ipaddr, username=args.ssh_user,
- key_filename=args.ssh_privkey)
- if 'centos' in args.topology:
- if args.verbosity >= 1:
- print_to_stderr("DEBUG: Installing RPM packages")
- vpp_install_command = 'sudo rpm -ivh /scratch/vpp/*.rpm'
- elif 'trusty' in args.topology or 'xenial' in args.topology:
- if args.verbosity >= 1:
- print_to_stderr("DEBUG: Installing DEB packages")
- vpp_install_command = 'sudo dpkg -i --force-all ' \
- '/scratch/vpp/*.deb'
- else:
- print_to_stderr("ERROR: Unsupported OS requested: {}"
- .format(args.topology))
- vpp_install_command = ''
- _, stdout, stderr = \
- client.exec_command(vpp_install_command)
- c_stdout = stdout.read()
- c_stderr = stderr.read()
- if args.verbosity >= 2:
- print_to_stderr("DEBUG: Command output was:")
- print_to_stderr(c_stdout)
- print_to_stderr("DEBUG: Command stderr was:")
- print_to_stderr(c_stderr)
+ if not args.skip_install:
+ if args.verbosity >= 1:
+ print_to_stderr("DEBUG: Uprading VPP")
+
+ for key1 in nodeaddrs:
+ if not key1 == 'tg':
+ for key2 in nodeaddrs[key1]:
+ ipaddr = nodeaddrs[key1][key2]
+ if args.verbosity >= 2:
+ print_to_stderr("DEBUG: Upgrading VPP on node {}"
+ .format(ipaddr))
+ paramiko.util.log_to_file(os.path.join(scratch_directory,
+ "ssh.log"))
+ client = paramiko.SSHClient()
+ client.load_system_host_keys()
+ client.load_host_keys("/dev/null")
+ client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+ client.connect(ipaddr, username=args.ssh_user,
+ key_filename=args.ssh_privkey)
+ if 'centos' in args.topology:
+ if args.verbosity >= 1:
+ print_to_stderr("DEBUG: Installing RPM packages")
+ vpp_install_command = 'sudo rpm -ivh /scratch/vpp/*.rpm'
+ elif 'trusty' in args.topology or 'xenial' in args.topology:
+ if args.verbosity >= 1:
+ print_to_stderr("DEBUG: Installing DEB packages")
+ vpp_install_command = 'sudo dpkg -i --force-all ' \
+ '/scratch/vpp/*.deb'
+ else:
+ print_to_stderr("ERROR: Unsupported OS requested: {}"
+ .format(args.topology))
+ vpp_install_command = ''
+ _, stdout, stderr = \
+ client.exec_command(vpp_install_command)
+ c_stdout = stdout.read()
+ c_stderr = stderr.read()
+ if args.verbosity >= 2:
+ print_to_stderr("DEBUG: Command output was:")
+ print_to_stderr(c_stdout)
+ print_to_stderr("DEBUG: Command stderr was:")
+ print_to_stderr(c_stderr)
#
# Write a file with timestamp to scratch directory. We can use this to track