Merge "fullstack: Don't let dhcp agents failover"
This commit is contained in:
@@ -26,6 +26,7 @@ from neutron.tests.unit import testlib_api
|
|||||||
# This is the directory from which infra fetches log files for fullstack tests
|
# This is the directory from which infra fetches log files for fullstack tests
|
||||||
DEFAULT_LOG_DIR = os.path.join(helpers.get_test_log_path(),
|
DEFAULT_LOG_DIR = os.path.join(helpers.get_test_log_path(),
|
||||||
'dsvm-fullstack-logs')
|
'dsvm-fullstack-logs')
|
||||||
|
ROOTDIR = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
|
||||||
class BaseFullStackTestCase(testlib_api.MySQLTestCaseMixin,
|
class BaseFullStackTestCase(testlib_api.MySQLTestCaseMixin,
|
||||||
|
0
neutron/tests/fullstack/cmd/__init__.py
Normal file
0
neutron/tests/fullstack/cmd/__init__.py
Normal file
@@ -20,8 +20,8 @@ import sys
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from neutron.agent import dhcp_agent
|
|
||||||
from neutron.agent.linux import dhcp as linux_dhcp
|
from neutron.agent.linux import dhcp as linux_dhcp
|
||||||
|
from neutron.cmd.eventlet.agents import dhcp as dhcp_agent
|
||||||
|
|
||||||
|
|
||||||
OPTS = [
|
OPTS = [
|
@@ -87,6 +87,9 @@ class NeutronConfigFixture(ConfigFixture):
|
|||||||
'oslo_policy': {
|
'oslo_policy': {
|
||||||
'policy_file': self._generate_policy_json(),
|
'policy_file': self._generate_policy_json(),
|
||||||
},
|
},
|
||||||
|
'agent': {
|
||||||
|
'report_interval': env_desc.agent_down_time / 2.0
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
def _setUp(self):
|
def _setUp(self):
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from distutils import spawn
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
@@ -25,6 +26,8 @@ from neutron.common import utils
|
|||||||
from neutron.tests.common import machine_fixtures
|
from neutron.tests.common import machine_fixtures
|
||||||
from neutron.tests.common import net_helpers
|
from neutron.tests.common import net_helpers
|
||||||
|
|
||||||
|
FULLSTACK_DHCLIENT_SCRIPT = 'fullstack-dhclient-script'
|
||||||
|
|
||||||
|
|
||||||
class FakeFullstackMachinesList(list):
|
class FakeFullstackMachinesList(list):
|
||||||
"""A list of items implementing the FakeFullstackMachine interface."""
|
"""A list of items implementing the FakeFullstackMachine interface."""
|
||||||
@@ -42,6 +45,8 @@ class FakeFullstackMachinesList(list):
|
|||||||
|
|
||||||
|
|
||||||
class FakeFullstackMachine(machine_fixtures.FakeMachineBase):
|
class FakeFullstackMachine(machine_fixtures.FakeMachineBase):
|
||||||
|
NO_RESOLV_CONF_DHCLIENT_SCRIPT_PATH = (
|
||||||
|
spawn.find_executable(FULLSTACK_DHCLIENT_SCRIPT))
|
||||||
|
|
||||||
def __init__(self, host, network_id, tenant_id, safe_client,
|
def __init__(self, host, network_id, tenant_id, safe_client,
|
||||||
neutron_port=None, bridge_name=None, use_dhcp=False):
|
neutron_port=None, bridge_name=None, use_dhcp=False):
|
||||||
@@ -129,7 +134,8 @@ class FakeFullstackMachine(machine_fixtures.FakeMachineBase):
|
|||||||
self.addCleanup(self._stop_async_dhclient)
|
self.addCleanup(self._stop_async_dhclient)
|
||||||
|
|
||||||
def _start_async_dhclient(self):
|
def _start_async_dhclient(self):
|
||||||
cmd = ["dhclient", '--no-pid', '-d', self.port.name]
|
cmd = ["dhclient", '-sf', self.NO_RESOLV_CONF_DHCLIENT_SCRIPT_PATH,
|
||||||
|
'--no-pid', '-d', self.port.name]
|
||||||
self.dhclient_async = async_process.AsyncProcess(
|
self.dhclient_async = async_process.AsyncProcess(
|
||||||
cmd, run_as_root=True, namespace=self.namespace)
|
cmd, run_as_root=True, namespace=self.namespace)
|
||||||
self.dhclient_async.start()
|
self.dhclient_async.start()
|
||||||
|
@@ -301,8 +301,9 @@ class DhcpAgentFixture(fixtures.Fixture):
|
|||||||
test_name=self.test_name,
|
test_name=self.test_name,
|
||||||
process_name=self.NEUTRON_DHCP_AGENT,
|
process_name=self.NEUTRON_DHCP_AGENT,
|
||||||
exec_name=spawn.find_executable(
|
exec_name=spawn.find_executable(
|
||||||
'fullstack_dhcp_agent.py',
|
'dhcp_agent.py',
|
||||||
path=os.path.join(base.ROOTDIR, 'common', 'agents')),
|
path=os.path.join(
|
||||||
|
fullstack_base.ROOTDIR, 'cmd')),
|
||||||
config_filenames=config_filenames,
|
config_filenames=config_filenames,
|
||||||
namespace=self.namespace
|
namespace=self.namespace
|
||||||
)
|
)
|
||||||
|
@@ -46,7 +46,7 @@ class BaseDhcpAgentTest(base.BaseFullStackTestCase):
|
|||||||
environment.EnvironmentDescription(
|
environment.EnvironmentDescription(
|
||||||
l2_pop=False,
|
l2_pop=False,
|
||||||
arp_responder=False,
|
arp_responder=False,
|
||||||
agent_down_time=10),
|
agent_down_time=self.agent_down_time),
|
||||||
host_descriptions)
|
host_descriptions)
|
||||||
|
|
||||||
super(BaseDhcpAgentTest, self).setUp(env)
|
super(BaseDhcpAgentTest, self).setUp(env)
|
||||||
@@ -88,6 +88,7 @@ class BaseDhcpAgentTest(base.BaseFullStackTestCase):
|
|||||||
class TestDhcpAgentNoHA(BaseDhcpAgentTest):
|
class TestDhcpAgentNoHA(BaseDhcpAgentTest):
|
||||||
|
|
||||||
number_of_hosts = 1
|
number_of_hosts = 1
|
||||||
|
agent_down_time = 60
|
||||||
|
|
||||||
def test_dhcp_assignment(self):
|
def test_dhcp_assignment(self):
|
||||||
# First check if network was scheduled to one DHCP agent
|
# First check if network was scheduled to one DHCP agent
|
||||||
@@ -102,6 +103,7 @@ class TestDhcpAgentNoHA(BaseDhcpAgentTest):
|
|||||||
class TestDhcpAgentHA(BaseDhcpAgentTest):
|
class TestDhcpAgentHA(BaseDhcpAgentTest):
|
||||||
|
|
||||||
number_of_hosts = 2
|
number_of_hosts = 2
|
||||||
|
agent_down_time = 10
|
||||||
|
|
||||||
def _wait_until_network_rescheduled(self, old_agent):
|
def _wait_until_network_rescheduled(self, old_agent):
|
||||||
def _agent_rescheduled():
|
def _agent_rescheduled():
|
||||||
|
28
tools/generate_dhclient_script_for_fullstack.sh
Executable file
28
tools/generate_dhclient_script_for_fullstack.sh
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MAKE_RESOLV_CONF_FUNCTION=make_resolv_conf
|
||||||
|
|
||||||
|
USAGE="$0 <path to virtual environment to place executable>
|
||||||
|
The script takes existing dhclient-script and makes $MAKE_RESOLV_CONF_FUNCTION function a noop function.
|
||||||
|
"
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "Path to virtual environment directory is a required parameter."
|
||||||
|
echo $USAGE
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
VENV_DIR=$1
|
||||||
|
DHCLIENT_SCRIPT_NAME=dhclient-script
|
||||||
|
DHCLIENT_PATH=$(which $DHCLIENT_SCRIPT_NAME)
|
||||||
|
FULLSTACK_DHCLIENT_SCRIPT=$VENV_DIR/bin/fullstack-dhclient-script
|
||||||
|
|
||||||
|
if [ -n "$DHCLIENT_PATH" ]; then
|
||||||
|
# Return from make_resolv_conf function immediately. This will cause
|
||||||
|
# that /etc/resolv.conf will not be updated by fake fullstack machines.
|
||||||
|
sed "/^$MAKE_RESOLV_CONF_FUNCTION()/a\ return" $DHCLIENT_PATH > $FULLSTACK_DHCLIENT_SCRIPT
|
||||||
|
chmod +x $FULLSTACK_DHCLIENT_SCRIPT
|
||||||
|
else
|
||||||
|
echo "$DHCLIENT_SCRIPT_NAME not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
3
tox.ini
3
tox.ini
@@ -76,6 +76,9 @@ setenv = {[testenv]setenv}
|
|||||||
OS_TEST_PATH=./neutron/tests/fullstack
|
OS_TEST_PATH=./neutron/tests/fullstack
|
||||||
deps =
|
deps =
|
||||||
{[testenv:functional]deps}
|
{[testenv:functional]deps}
|
||||||
|
commands =
|
||||||
|
{toxinidir}/tools/generate_dhclient_script_for_fullstack.sh {envdir}
|
||||||
|
{[testenv]commands}
|
||||||
|
|
||||||
[testenv:releasenotes]
|
[testenv:releasenotes]
|
||||||
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
||||||
|
Reference in New Issue
Block a user