Fix all broken jobs

This patch consists of two squashed patches:

First patch copies in tox_install.sh from oslo libraries. The script
removes ovsdbapp from upper-constraints.txt as we want to install
code from the repository and not from pip.

Second patch is squashed from abandoned Iff59bbf41d166a0918a217cb72a37c547c6506b9.
Issue there was that code uses 'sudo' for running ovs-vsctl but the tests
user is not member of sudoers. It sets the Manager prior to executing
the tests. As ovsdbapp isn't supposed to depend on oslo, there is not
guaranteed way running process with ovsdbapp code will have root
privileges. Hence the Manager should be configured before application
using ovsdbapp is started.

Closes-bug: #1674937

Change-Id: I634ae2eeab7b68a81cb7208f0650705ac5a9a9ef
This commit is contained in:
Jakub Libosvar 2017-03-22 06:09:35 -04:00
parent c5acfb1557
commit f03b87e66a
6 changed files with 51 additions and 2 deletions

View File

@ -3,3 +3,4 @@
openvswitch [platform:rpm test]
openvswitch-switch [platform:dpkg test]
curl [test]

View File

@ -27,6 +27,8 @@ def _connection_to_manager_uri(conn_uri):
return 'p%s:%s' % (proto, addr)
# TODO(jlibosva): Get rid of this runtime configuration and raise a message to
# set Manager outside of ovsdbapp.
def enable_connection_uri(conn_uri, execute=None, **kwargs):
timeout = kwargs.get('timeout', 5)
probe = timeout if kwargs.get('set_timeout') else None

View File

@ -0,0 +1,7 @@
---
other:
- |
ovsdbapp must get granted access to ovsdb by adding a new Manager via ovs-vsctl
command. The command must be executed with root privileges. An example of how to
create a new manager for localhost on port 6640 is as follows:
`sudo ovs-vsctl --id=@manager -- create Manager target=\"ptcp:6640:127.0.0.1\" -- add Open_vSwitch . manager_options @manager'

7
tools/test-setup.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash -xe
# This script is triggered by extra-test-setup macro from project-config
# repository.
# Set manager for native interface
sudo ovs-vsctl --timeout=10 --id=@manager -- create Manager target=\"ptcp:6640:127.0.0.1\" -- add Open_vSwitch . manager_options @manager

30
tools/tox_install.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Client constraint file contains this client version pin that is in conflict
# with installing the client from source. We should remove the version pin in
# the constraints file before applying it for from-source installation.
CONSTRAINTS_FILE=$1
shift 1
set -e
# NOTE(tonyb): Place this in the tox enviroment's log dir so it will get
# published to logs.openstack.org for easy debugging.
localfile="$VIRTUAL_ENV/log/upper-constraints.txt"
if [[ $CONSTRAINTS_FILE != http* ]]; then
CONSTRAINTS_FILE=file://$CONSTRAINTS_FILE
fi
curl $CONSTRAINTS_FILE --insecure --progress-bar --output $localfile
pip install -c$localfile openstack-requirements
# This is the main purpose of the script: Allow local installation of
# the current repo. It is listed in constraints file and thus any
# install will be constrained and we need to unconstrain it.
edit-constraints $localfile -- $CLIENT_NAME
pip install -c$localfile -U $*
exit $?

View File

@ -5,11 +5,12 @@ skipsdist = True
[testenv]
usedevelop = True
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
OS_TEST_PATH=./ovsdbapp/tests/unit
CLIENT_NAME=ovsdbapp
install_command = {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
deps = -r{toxinidir}/test-requirements.txt
commands = python setup.py testr --slowest --testr-args='{posargs}'
@ -33,7 +34,8 @@ commands =
commands = oslo_debug_helper {posargs}
[testenv:functional]
setenv = OS_TEST_PATH=./ovsdbapp/tests/functional
setenv = {[testenv]setenv}
OS_TEST_PATH=./ovsdbapp/tests/functional
[flake8]
# E123, E125 skipped as they are invalid PEP-8.