neutron-vpnaas/tools/deploy_rootwrap.sh
Paul Michali d8dd053b0a VPNaaS: Don't clone neutron automatically for tests
As part of the work to allow VPN functionals job to run when Neutron
commits are reviewed, we need to be more intelligent about how
dependencies are resolved in the tox.ini for this repo.

This commit does the same as LBaaS, using a script to determine whether
an existing Neutron repo exists (and use that for a Neutron patch-set
running the VPN tests) or whether the Neutron repo needs to be cloned
(for a VPN patch set).

With the VPN repo, the rootwrap config file and filters need to be set
up. The deploy_rootwrap script is modified to do all actions related to
setup, instead of doing part of that in tox.ini, as before. In addition,
rootwrap config and needed filters for testing from Neutron are added to
this repo, so there is no dependency on Neutron (whose location cannot
be assumed in the gate).

NOTE: To run functional tests locally, one needs to set VENV for the
desired functional target and invoke configure_vpn_for_func_testing.sh.
Next, run tox for the functional target with --notest to setup the
virtual environment. Then, install Neutron into the virtual env. Finally,
the functional test can then be invoked.

This must be upstreamed, before allowing the VPN functional job to run
for Neutron jobs.

Change-Id: Idb3c4dff0dbb40e30b2b49591df0b014b769f167
2015-07-06 09:51:47 -04:00

59 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# 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 -eu
if [ $# -ne 2 ]; then
>&2 echo "Usage: $0 /path/to/repo /path/to/virtual-env
Deploy rootwrap configuration and filters.
Warning: Any existing rootwrap files at the specified etc path will be
removed by this script.
Optional: set OS_SUDO_TESTING=1 to deploy the filters required by
Neutron's functional testing suite."
exit 1
fi
OS_SUDO_TESTING=${OS_SUDO_TESTING:-0}
repo_path=$1
venv_path=$2
src_conf_path=${repo_path}/neutron_vpnaas/tests/contrib
src_conf=${src_conf_path}/functional-test-rootwrap.conf
src_rootwrap_path=${repo_path}/etc/neutron/rootwrap.d
dst_conf_path=${venv_path}/etc/neutron
dst_conf=${dst_conf_path}/rootwrap.conf
dst_rootwrap_path=${dst_conf_path}/rootwrap.d
# Clear any existing filters in virtual env
if [[ -d "$dst_rootwrap_path" ]]; then
rm -rf ${dst_rootwrap_path}
fi
mkdir -p -m 755 ${dst_rootwrap_path}
# Get all needed filters
cp -p ${src_rootwrap_path}/* ${dst_rootwrap_path}/
if [[ "$OS_SUDO_TESTING" = "1" ]]; then
cp -p ${repo_path}/neutron_vpnaas/tests/contrib/functional-testing.filters \
${dst_rootwrap_path}/
fi
# Get config file and modify for this repo
cp -p ${src_conf} ${dst_conf}
sed -i "s:^filters_path=.*$:filters_path=${dst_rootwrap_path}:" ${dst_conf}
sed -i "s:^\(exec_dirs=.*\)$:\1,${venv_path}/bin:" ${dst_conf}
sudo cp ${dst_conf} /etc/neutron/