aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools
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
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')
-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
} /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# Copyright (c) 2023 Cisco and/or its affiliates.
# Copyright (c) 2023 PANTHEON.tech s.r.o.
# 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:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -exuo pipefail

# This library defines functions used mainly by per patch entry scripts.
# Generally, the functions assume "common.sh" library has been sourced already.
# Keep functions ordered alphabetically, please.

function archive_test_results () {

    # Arguments:
    # - ${1}: Directory to archive to. Required. Parent has to exist.
    # Variable set:
    # - TARGET - Target directory.
    # Variables read:
    # - ARCHIVE_DIR - Path to where robot result files are created in.
    # - VPP_DIR - Path to existing directory, root for to relative paths.
    # Directories updated:
    # - ${1} - Created, and robot and parsing files are moved/created there.
    # Functions called:
    # - die - Print to stderr and exit, defined in common.sh

    set -exuo pipefail

    cd "${VPP_DIR}" || die "Change directory command failed."
    TARGET="$(readlink -f "$1")"
    mkdir -p "${TARGET}" || die "Directory creation failed."
    file_list=("output.xml" "log.html" "report.html" "tests")
    for filename in "${file_list[@]}"; do
        mv "${ARCHIVE_DIR}/${filename}" "${TARGET}/${filename}" || {
            die "Attempt to move '${filename}' failed."
        }
    done
}


function archive_parse_test_results () {

    # Arguments:
    # - ${1}: Directory to archive to. Required. Parent has to exist.
    # Variables read:
    # - TARGET - Target directory.
    # Functions called:
    # - die - Print to stderr and exit, defined in common.sh
    # - archive_test_results - Archiving results.
    # - parse_bmrr_results - See definition in this file.

    set -exuo pipefail

    archive_test_results "$1" || die
    parse_bmrr_results "${TARGET}" || {
        die "The function should have died on error."
    }
}


function build_vpp_ubuntu_amd64 () {

    # This function is using make pkg-verify to build VPP with all dependencies
    # that is ARCH/OS aware. VPP repo is SSOT for building mechanics and CSIT
    # is consuming artifacts. This way if VPP will introduce change in building
    # mechanics they will not be blocked by CSIT repo.
    # Arguments:
    # - ${1} - String identifier for echo, can be unset.
    # Variables read:
    # - MAKE_PARALLEL_FLAGS - Make flags when building VPP.
    # - MAKE_PARALLEL_JOBS - Number of cores to use when building VPP.
    # - VPP_DIR - Path to existing directory, parent to accessed directories.
    # Directories updated:
    # - ${VPP_DIR} - Whole subtree, many files (re)created by the build process.
    # Functions called:
    # - die - Print to stderr and exit, defined in common.sh

    set -exuo pipefail

    cd "${VPP_DIR}" || die "Change directory command failed."
    if [ -n "${MAKE_PARALLEL_FLAGS-}" ]; then
        echo "Building VPP. Number of cores for build set with" \
             "MAKE_PARALLEL_FLAGS='${MAKE_PARALLEL_FLAGS}'."
    elif [ -n "${MAKE_PARALLEL_JOBS-}" ]; then
        echo "Building VPP. Number of cores for build set with" \
             "MAKE_PARALLEL_JOBS='${MAKE_PARALLEL_JOBS}'."
    else
        echo "Building VPP. Number of cores not set, " \
             "using build default ($(grep -c ^processor /proc/cpuinfo))."
    fi

    make UNATTENDED=y pkg-verify || die "VPP build with make pkg-verify failed."
    echo "* VPP ${1-} BUILD SUCCESSFULLY COMPLETED" || {
        die "Argument not found."
    }
}


function compare_test_results () {

    # Variables read:
    # - VPP_DIR - Path to directory with VPP git repo (at least built parts).
    # - ARCHIVE_DIR - Path to where robot result files are created in.
    # - PYTHON_SCRIPTS_DIR - Path to directory holding comparison utility.
    # Directories recreated:
    # - csit_parent - Sibling to csit directory, for holding results
    #   of parent build.
    # Functions called:
    # - die - Print to stderr and exit, defined in common.sh
    # - parse_bmrr_results - See definition in this file.
    # Exit code:
    # - 0 - If the comparison utility sees no regression (nor data error).
    # - 1 - If the comparison utility sees a regression (or data error).

    set -exuo pipefail

    cd "${VPP_DIR}" || die "Change directory operation failed."
    # Reusing CSIT main virtualenv.
    python3 "${TOOLS_DIR}/integrated/compare_perpatch.py"
    # The exit code determines the vote result.
}


function initialize_csit_dirs () {

    set -exuo pipefail

    # Variables read:
    # - VPP_DIR - Path to WORKSPACE, parent of created directories.
    # Directories created:
    # - csit_current - Holding test results of the patch under test (PUT).
    # - csit_parent - Holding test results of parent of PUT.
    # Functions called:
    # - die - Print to stderr and exit, defined in common.sh

    set -exuo pipefail

    cd "${VPP_DIR}" || die "Change directory operation failed."
    rm -rf "csit_current" "csit_parent" || {
        die "Directory deletion failed."
    }
    mkdir -p "csit_current" "csit_parent" || {
        die "Directory creation failed."
    }
}


function parse_bmrr_results () {

    # Currently "parsing" is just two greps.
    # TODO: Re-use PAL parsing code, make parsing more general and centralized.
    #
    # Arguments:
    # - ${1} - Path to (existing) directory holding robot output.xml result.
    # Files read:
    # - output.xml - From argument location.
    # Files updated:
    # - results.txt - (Re)created, in argument location.
    # Functions called:
    # - die - Print to stderr and exit, defined in common.sh

    set -exuo pipefail

    rel_dir="$(readlink -e "${1}")" || die "Readlink failed."
    in_file="${rel_dir}/output.xml"
    out_file="${rel_dir}/results.txt"
    # TODO: Do we need to check echo exit code explicitly?
    echo "Parsing ${in_file} putting results into ${out_file}"
    echo "TODO: Re-use parts of PAL when they support subsample test parsing."
    pattern='Maximum Receive Rate trial results in .*'
    pattern+=' per second: .*\]</status>'
    grep -o "${pattern}" "${in_file}" | grep -o '\[.*\]' > "${out_file}" || {
        die "Some parsing grep command has failed."
    }
}


function select_build () {

    # Arguments:
    # - ${1} - Path to directory to copy VPP artifacts from. Required.
    # Variables read:
    # - DOWNLOAD_DIR - Path to directory where Robot takes builds to test from.
    # - VPP_DIR - Path to existing directory, root for relative paths.
    # Directories read:
    # - ${1} - Existing directory with built new VPP artifacts (and DPDK).
    # Directories updated:
    # - ${DOWNLOAD_DIR} - Old content removed, .deb files from ${1} copied here.
    # Functions called:
    # - die - Print to stderr and exit, defined in common.sh

    set -exuo pipefail

    cd "${VPP_DIR}" || die "Change directory operation failed."
    source_dir="$(readlink -e "$1")"
    rm -rf "${DOWNLOAD_DIR}"/* || die "Cleanup of download dir failed."
    cp "${source_dir}"/*".deb" "${DOWNLOAD_DIR}" || die "Copy operation failed."
    # TODO: Is there a nice way to create symlinks,
    #   so that if job fails on robot, results can be archived?
}


function set_aside_commit_build_artifacts () {

    # Function is copying VPP built artifacts from actual checkout commit for
    # further use and clean git.
    # Variables read:
    # - VPP_DIR - Path to existing directory, parent to accessed directories.
    # Directories read:
    # - build-root - Existing directory with built VPP artifacts (also DPDK).
    # Directories updated:
    # - ${VPP_DIR} - A local git repository, parent commit gets checked out.
    # - build_current - Old contents removed, content of build-root copied here.
    # Functions called:
    # - die - Print to stderr and exit, defined in common.sh

    set -exuo pipefail

    cd "${VPP_DIR}" || die "Change directory operation failed."
    rm -rf "build_current" || die "Remove operation failed."
    mkdir -p "build_current" || die "Directory creation failed."
    mv "build-root"/*".deb" "build_current"/ || die "Move operation failed."
    # The previous build could have left some incompatible leftovers,
    # e.g. DPDK artifacts of different version (in build/external).
    # Also, there usually is a copy of dpdk artifact in build-root.
    git clean -dffx "build"/ "build-root"/ || die "Git clean operation failed."
    # Finally, check out the parent commit.
    git checkout HEAD~ || die "Git checkout operation failed."
    # Display any other leftovers.
    git status || die "Git status operation failed."
}


function set_aside_parent_build_artifacts () {

    # Function is copying VPP built artifacts from parent checkout commit for
    # further use. Checkout to parent is not part of this function.
    # Variables read:
    # - VPP_DIR - Path to existing directory, parent of accessed directories.
    # Directories read:
    # - build-root - Existing directory with built VPP artifacts (also DPDK).
    # Directories updated:
    # - build_parent - Old directory removed, build-root debs moved here.
    # Functions called:
    # - die - Print to stderr and exit, defined in common.sh

    set -exuo pipefail

    cd "${VPP_DIR}" || die "Change directory operation failed."
    rm -rf "build_parent" || die "Remove failed."
    mkdir -p "build_parent" || die "Directory creation operation failed."
    mv "build-root"/*".deb" "build_parent"/ || die "Move operation failed."
}


function set_perpatch_dut () {

    # Variables set:
    # - DUT - CSIT test/ subdirectory containing suites to execute.

    # TODO: Detect DUT from job name, when we have more than just VPP perpatch.

    set -exuo pipefail

    DUT="vpp"
}


function set_perpatch_vpp_dir () {

    # Variables read:
    # - CSIT_DIR - Path to existing root of local CSIT git repository.
    # Variables set:
    # - VPP_DIR - Path to existing root of local VPP git repository.
    # Functions called:
    # - die - Print to stderr and exit, defined in common.sh

    set -exuo pipefail

    # In perpatch, CSIT is cloned inside VPP clone.
    VPP_DIR="$(readlink -e "${CSIT_DIR}/..")" || die "Readlink failed."
}