Skip test_dhcp_agent_scheduler tests if there is no DHCP agent available

Previously those tests were skipped only if there wasn't
"dhcp_agent_scheduler" API extension available.
But in some cases, like e.g. when Neutron is run with ML2/OVN backend
this extension is available (after [1] will be merged) but still in
typical deployment there is no Neutron DHCP agent deployed together with
ML2/OVN backend.

So those tests should be skipped not only if there isn't API extension
at all but also when there is no any DHCP agent available in the
deployment.

[1] https://review.opendev.org/c/openstack/neutron/+/897528

Related-bug: #2038655
Change-Id: I9ccb710c8dc32765962a18bee1771c86fe1aaacd
This commit is contained in:
Slawek Kaplonski 2023-10-12 10:15:38 +02:00
parent 88e165a4a8
commit 14f893e822

View File

@ -31,6 +31,15 @@ class DHCPAgentSchedulersTestJSON(base.BaseAdminNetworkTest):
@classmethod
def resource_setup(cls):
super(DHCPAgentSchedulersTestJSON, cls).resource_setup()
# NOTE(slaweq): In some cases (like default ML2/OVN deployment)
# extension is enabled but there may not be any DHCP agent available.
# In such case those tests should be also skipped.
dhcp_agents = cls.admin_agents_client.list_agents(
agent_type="DHCP Agent")['agents']
if not dhcp_agents:
msg = ("At least one DHCP agent is required to be running in "
"the environment for those tests.")
raise cls.skipException(msg)
# Create a network and make sure it will be hosted by a
# dhcp agent: this is done by creating a regular port
cls.network = cls.create_network()