tests: Handle missing extensions in network tests

Some tests still assume extensions are enabled; those tests are now skipped if the extension is not enabled. Change I25b8811fe09f2a4a9fc20ca5459f5a404b88a337 addressed some but not all of these.

Change-Id: If36550650f143a7efe4190e60961c51a8cd20fb3
This commit is contained in:
ArtofBugs 2023-11-21 09:50:51 -08:00
parent e44d8017ec
commit 6d3490ed7c
5 changed files with 37 additions and 8 deletions

View File

@ -15,9 +15,15 @@ import uuid
from openstackclient.tests.functional.network.v2 import common
class NetworkAgentTests(common.NetworkTests):
class TestAgent(common.NetworkTests):
"""Functional tests for network agent"""
def setUp(self):
super().setUp()
if not self.is_extension_enabled("agent"):
self.skipTest("No agent extension present")
def test_network_agent_list_show_set(self):
"""Test network agent list, set, show commands
@ -79,9 +85,15 @@ class NetworkAgentTests(common.NetworkTests):
)
class NetworkAgentListTests(common.NetworkTests):
class TestAgentList(common.NetworkTests):
"""Functional test for network agent"""
def setUp(self):
super().setUp()
if not self.is_extension_enabled("agent"):
self.skipTest("No agent extension present")
def test_network_dhcp_agent_list(self):
"""Test network agent list"""

View File

@ -21,6 +21,12 @@ from openstackclient.tests.functional.network.v2 import common
class TestMeter(common.NetworkTests):
"""Functional tests for network meter"""
def setUp(self):
super().setUp()
if not self.is_extension_enabled("metering"):
self.skipTest("No metering extension present")
# NOTE(dtroyer): Do not normalize the setup and teardown of the resource
# creation and deletion. Little is gained when each test
# has its own needs and there are collisions when running

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import unittest
import uuid
from openstackclient.tests.functional.network.v2 import common
@ -27,6 +28,10 @@ class TestMeterRule(common.NetworkTests):
@classmethod
def setUpClass(cls):
super().setUpClass()
if not cls.is_extension_enabled("metering"):
raise unittest.SkipTest("No metering extension present")
if cls.haz_network:
cls.METER_NAME = uuid.uuid4().hex
@ -47,12 +52,6 @@ class TestMeterRule(common.NetworkTests):
finally:
super().tearDownClass()
def setUp(self):
super().setUp()
if not self.is_extension_enabled("metering"):
self.skipTest("No metering extension present")
def test_meter_rule_delete(self):
"""test create, delete"""
json_output = self.openstack(

View File

@ -21,6 +21,12 @@ from openstackclient.tests.functional.network.v2 import common
class NetworkQosPolicyTests(common.NetworkTests):
"""Functional tests for QoS policy"""
def setUp(self):
super().setUp()
if not self.is_extension_enabled("qos"):
self.skipTest("No qos extension present")
def test_qos_rule_create_delete(self):
# This is to check the output of qos policy delete
policy_name = uuid.uuid4().hex

View File

@ -29,6 +29,12 @@ class NetworkQosRuleTypeTests(common.NetworkTests):
'minimum_packet_rate',
]
def setUp(self):
super().setUp()
if not self.is_extension_enabled("qos"):
self.skipTest("No qos extension present")
def test_qos_rule_type_list(self):
cmd_output = self.openstack(
'network qos rule type list -f json',