From 927646e03a2b89c4e2e5de67e867b82e1b2d59ad Mon Sep 17 00:00:00 2001 From: Hunt Xu Date: Sun, 23 Apr 2017 22:02:40 +0800 Subject: [PATCH] Configure root_helper and root_helper_daemon in fullstack tests Fullstack tests are similar to non-test environments, so rootwrap and rootwrap-daemon should be used instead of plain sudo. L3 agents and DHCP agents used in fullstack tests should be guaranteed to be eventlet monkey patched to avoid race conditions when two threads are trying to issue commands via rootwrap daemon at the same time. Closes-Bug: #1557168 Change-Id: Ida5a45420a8f58c1f5a36eb3fc546a7ea053a661 Signed-off-by: Hunt Xu --- neutron/tests/fullstack/cmd/l3_agent.py | 24 ++++++++++++++++++++ neutron/tests/fullstack/resources/config.py | 7 ++++++ neutron/tests/fullstack/resources/process.py | 2 +- tox.ini | 1 + 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 neutron/tests/fullstack/cmd/l3_agent.py diff --git a/neutron/tests/fullstack/cmd/l3_agent.py b/neutron/tests/fullstack/cmd/l3_agent.py new file mode 100755 index 00000000000..fae5be2d507 --- /dev/null +++ b/neutron/tests/fullstack/cmd/l3_agent.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# Copyright 2017 Eayun, Inc. +# +# 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. + +import sys + +from neutron.common import eventlet_utils +from neutron.tests.common.agents import l3_agent + +eventlet_utils.monkey_patch() + +if __name__ == "__main__": + sys.exit(l3_agent.main()) diff --git a/neutron/tests/fullstack/resources/config.py b/neutron/tests/fullstack/resources/config.py index 8329a41d0ef..d91db273b93 100644 --- a/neutron/tests/fullstack/resources/config.py +++ b/neutron/tests/fullstack/resources/config.py @@ -91,6 +91,13 @@ class NeutronConfigFixture(ConfigFixture): 'report_interval': env_desc.agent_down_time / 2.0 }, }) + # Set root_helper/root_helper_daemon only when env var is set + root_helper = os.environ.get('OS_ROOTWRAP_CMD') + if root_helper: + self.config['agent']['root_helper'] = root_helper + root_helper_daemon = os.environ.get('OS_ROOTWRAP_DAEMON_CMD') + if root_helper_daemon: + self.config['agent']['root_helper_daemon'] = root_helper_daemon def _setUp(self): self.config['DEFAULT'].update({ diff --git a/neutron/tests/fullstack/resources/process.py b/neutron/tests/fullstack/resources/process.py index 127c5d70d76..1508eae3257 100644 --- a/neutron/tests/fullstack/resources/process.py +++ b/neutron/tests/fullstack/resources/process.py @@ -267,7 +267,7 @@ class L3AgentFixture(ServiceFixture): process_name=self.NEUTRON_L3_AGENT, exec_name=spawn.find_executable( 'l3_agent.py', - path=os.path.join(base.ROOTDIR, 'common', 'agents')), + path=os.path.join(fullstack_base.ROOTDIR, 'cmd')), config_filenames=config_filenames, namespace=self.namespace ) diff --git a/tox.ini b/tox.ini index b18cfbbcaca..ef907623ed2 100644 --- a/tox.ini +++ b/tox.ini @@ -78,6 +78,7 @@ deps = {[testenv:functional]deps} commands = {toxinidir}/tools/generate_dhclient_script_for_fullstack.sh {envdir} + {toxinidir}/tools/deploy_rootwrap.sh {toxinidir} {envdir}/etc {envdir}/bin {[testenv]commands} [testenv:releasenotes]