Fix vif tests

And remove an invalid test at this point, and fix versioning tests.

TL;DR is we didn't run the vif tests for... a very long time, and
I got a report they were failing downstream. In fixing them, since
they were semi-reliant upon specific behavior, I also broke
some other tests, and had to content with legacy behaivor being
tested by the plugin which had to be navigated slightly differently,
such as today some tests needed the fake deploy interface, and
the noop network interface to properly execute in a non-blocking
fashion.

Depends-On: https://review.opendev.org/c/openstack/ironic/+/916128
Change-Id: I285c813c09eece538e66b43107825684f4681d5f
This commit is contained in:
Julia Kreger 2024-04-18 06:32:09 -07:00
parent 0eb9ae7445
commit cff1cdd800
5 changed files with 89 additions and 47 deletions

View File

@ -261,7 +261,12 @@ class BaremetalClient(base.BaremetalClient):
"""
node = {}
for field in ('resource_class', 'name', 'description', 'shard'):
# Explicitly allow definition of network interface and deploy
# interface to allow tests to specify the required values
# as they hold a great deal of logic which is executed upon and
# they can ultimately impact test behavior.
for field in ('resource_class', 'name', 'description', 'shard',
'network_interface', 'deploy_interface'):
if kwargs.get(field):
node[field] = kwargs[field]
@ -271,7 +276,7 @@ class BaremetalClient(base.BaremetalClient):
'cpus': kwargs.get('cpus', 8),
'local_gb': kwargs.get('local_gb', 1024),
'memory_mb': kwargs.get('memory_mb', 4096)},
'driver': kwargs.get('driver', 'fake')}
'driver': kwargs.get('driver', 'fake-hardware')}
)
return self._create_request('nodes', node)

View File

@ -312,7 +312,10 @@ class TestNodesVif(base.BaseBaremetalTest):
super(TestNodesVif, self).setUp()
_, self.chassis = self.create_chassis()
_, self.node = self.create_node(self.chassis['uuid'])
# The tests will mostly fail in this class if exposed to the
# noop network interface, which is what the default is.
_, self.node = self.create_node(self.chassis['uuid'],
network_interface='flat')
if CONF.network.shared_physical_network:
self.net = self.os_admin.networks_client.list_networks(
name=CONF.compute.fixed_network_name)['networks'][0]
@ -432,7 +435,9 @@ class TestNodesVif(base.BaseBaremetalTest):
data_utils.rand_mac_address())
self.client.vif_attach(self.node['uuid'], self.nport_id)
_, body = self.client.vif_list(self.node['uuid'])
self.assertEqual({'vifs': [{'id': self.nport_id}]}, body)
self.assertRaises(lib_exc.Conflict, self.client.vif_attach,
self.node['uuid'], self.nport_id)
self.client.vif_detach(self.node['uuid'], self.nport_id)
@ -495,6 +500,7 @@ class TestNodesVif(base.BaseBaremetalTest):
_, port = self.client.show_port(self.port['uuid'])
self.assertEqual(self.nport_id,
port['internal_info']['tenant_vif_port_id'])
self.client.vif_detach(self.node['uuid'], self.nport_id)
@decorators.attr(type='negative')
@decorators.idempotent_id('85b610cd-5ba8-49a7-8ce2-5e364056fd29')
@ -545,6 +551,7 @@ class TestNodesVif(base.BaseBaremetalTest):
port['internal_info']['tenant_vif_port_id'])
_, portgroup = self.client.show_portgroup(self.portgroup['uuid'])
self.assertNotIn('tenant_vif_port_id', portgroup['internal_info'])
self.client.vif_detach(self.node['uuid'], self.nport_id)
@decorators.attr(type='negative')
@decorators.idempotent_id('3affca81-9f3f-4dab-ad3d-77c892d8d0d7')
@ -555,20 +562,6 @@ class TestNodesVif(base.BaseBaremetalTest):
data_utils.rand_uuid(),
self.nport_id)
@decorators.attr(type='negative')
@decorators.idempotent_id('9290e1f9-7e75-4e12-aea7-3649348e7f36')
def test_vif_attach_no_args(self):
"""Negative test for VIF attachment with lack of arguments."""
self.assertRaises(lib_exc.BadRequest,
self.client.vif_attach,
self.node['uuid'], '')
self.assertRaises(lib_exc.BadRequest,
self.client.vif_attach,
'', '')
self.assertRaises(lib_exc.BadRequest,
self.client.vif_attach,
'', self.nport_id)
@decorators.attr(type='negative')
@decorators.idempotent_id('da036225-47b0-43b7-9586-0d6390bd3cd9')
def test_vif_detach_not_existing(self):
@ -1119,9 +1112,7 @@ class TestNodesProtectedOldApi(base.BaseBaremetalTest):
def setUp(self):
super(TestNodesProtectedOldApi, self).setUp()
_, self.chassis = self.create_chassis()
_, self.node = self.create_node(self.chassis['uuid'],
deploy_interface='fake',
network_interface='noop')
_, self.node = self.create_node(self.chassis['uuid'])
self.deploy_node(self.node['uuid'])
_, self.node = self.client.show_node(self.node['uuid'])

View File

@ -78,9 +78,7 @@ class TestNodeStatesV1_1(TestNodeStatesMixin, base.BaseBaremetalTest):
@decorators.idempotent_id('ccb8fca9-2ba0-480c-a037-34c3bd09dc74')
def test_set_node_provision_state(self):
_, node = self.create_node(self.chassis['uuid'],
deploy_interface='fake',
network_interface='noop')
_, node = self.create_node(self.chassis['uuid'])
# Nodes appear in NONE state by default until v1.1
self.assertIsNone(node['provision_state'])
provision_states_list = ['active', 'deleted']
@ -96,19 +94,33 @@ class TestNodeStatesV1_2(TestNodeStatesMixin, base.BaseBaremetalTest):
def setUp(self):
super(TestNodeStatesV1_2, self).setUp()
self.useFixture(api_microversion_fixture.APIMicroversionFixture('1.2'))
# Make node with 1.2, so the start state written to the DB as expected.
_, self.node = self.create_node(self.chassis['uuid'])
self.useFixture(
api_microversion_fixture.APIMicroversionFixture('1.31'))
# Now with a 1.31 microversion, swap the deploy and network
# interfaces into place so the test doesn't break depending on
# the environment's default state.
self.client.update_node(self.node['uuid'],
[{'path': '/deploy_interface',
'op': 'replace',
'value': 'fake'},
{'path': '/network_interface',
'op': 'replace',
'value': 'noop'}])
self.useFixture(api_microversion_fixture.APIMicroversionFixture('1.2'))
@decorators.idempotent_id('9c414984-f3b6-4b3d-81da-93b60d4662fb')
def test_set_node_provision_state(self):
_, node = self.create_node(self.chassis['uuid'],
deploy_interface='fake',
network_interface='noop')
_, node = self.client.show_node(self.node['uuid'])
# Nodes appear in AVAILABLE state by default from v1.2 to v1.10
self.assertEqual('available', node['provision_state'])
self.assertEqual('available', self.node['provision_state'])
provision_states_list = ['active', 'deleted']
target_states_list = ['active', 'available']
for (provision_state, target_state) in zip(provision_states_list,
target_states_list):
self.client.set_node_provision_state(node['uuid'], provision_state)
self.client.set_node_provision_state(node['uuid'],
provision_state)
self._validate_provision_state(node['uuid'], target_state)
@ -117,12 +129,25 @@ class TestNodeStatesV1_4(TestNodeStatesMixin, base.BaseBaremetalTest):
def setUp(self):
super(TestNodeStatesV1_4, self).setUp()
self.useFixture(api_microversion_fixture.APIMicroversionFixture('1.4'))
_, self.node = self.create_node(self.chassis['uuid'])
self.useFixture(
api_microversion_fixture.APIMicroversionFixture('1.31'))
# Now with a 1.31 microversion, swap the deploy and network
# interfaces into place so the test doesn't break depending on
# the environment's default state.
self.client.update_node(self.node['uuid'],
[{'path': '/deploy_interface',
'op': 'replace',
'value': 'fake'},
{'path': '/network_interface',
'op': 'replace',
'value': 'noop'}])
self.useFixture(api_microversion_fixture.APIMicroversionFixture('1.4'))
@decorators.idempotent_id('3d606003-05ce-4b5a-964d-bdee382fafe9')
def test_set_node_provision_state(self):
_, node = self.create_node(self.chassis['uuid'],
deploy_interface='fake',
network_interface='noop')
# Make node with 1.2, so the start state written to the DB as expected.
_, node = self.client.show_node(self.node['uuid'])
# Nodes appear in AVAILABLE state by default from v1.2 to v1.10
self.assertEqual('available', node['provision_state'])
# MANAGEABLE state and PROVIDE transition have been added in v1.4
@ -132,7 +157,8 @@ class TestNodeStatesV1_4(TestNodeStatesMixin, base.BaseBaremetalTest):
'manageable', 'available', 'active', 'available']
for (provision_state, target_state) in zip(provision_states_list,
target_states_list):
self.client.set_node_provision_state(node['uuid'], provision_state)
self.client.set_node_provision_state(node['uuid'],
provision_state)
self._validate_provision_state(node['uuid'], target_state)
@ -140,13 +166,27 @@ class TestNodeStatesV1_6(TestNodeStatesMixin, base.BaseBaremetalTest):
def setUp(self):
super(TestNodeStatesV1_6, self).setUp()
# Creates a node with 1.31, and is later reset for the rest of the test
# due to Ironic's evolution of drivers.
self.useFixture(api_microversion_fixture.APIMicroversionFixture('1.6'))
_, self.node = self.create_node(self.chassis['uuid'])
self.useFixture(
api_microversion_fixture.APIMicroversionFixture('1.31'))
# Now with a 1.31 microversion, swap the deploy and network
# interfaces into place so the test doesn't break depending on
# the environment's default state.
self.client.update_node(self.node['uuid'],
[{'path': '/deploy_interface',
'op': 'replace',
'value': 'fake'},
{'path': '/network_interface',
'op': 'replace',
'value': 'noop'}])
self.useFixture(api_microversion_fixture.APIMicroversionFixture('1.6'))
@decorators.idempotent_id('6c9ce4a3-713b-4c76-91af-18c48d01f1bb')
def test_set_node_provision_state(self):
_, node = self.create_node(self.chassis['uuid'],
deploy_interface='fake',
network_interface='noop')
_, node = self.client.show_node(self.node['uuid'])
# Nodes appear in AVAILABLE state by default from v1.2 to v1.10
self.assertEqual('available', node['provision_state'])
# INSPECT* states have been added in v1.6
@ -156,33 +196,41 @@ class TestNodeStatesV1_6(TestNodeStatesMixin, base.BaseBaremetalTest):
'manageable', 'manageable', 'available', 'active', 'available']
for (provision_state, target_state) in zip(provision_states_list,
target_states_list):
self.client.set_node_provision_state(node['uuid'], provision_state)
self._validate_provision_state(node['uuid'], target_state)
self.client.set_node_provision_state(node['uuid'],
provision_state)
self._validate_provision_state(node['uuid'],
target_state)
class TestNodeStatesV1_11(TestNodeStatesMixin, base.BaseBaremetalTest):
def setUp(self):
super(TestNodeStatesV1_11, self).setUp()
# Creates a node with 1.31, and is later reset for the rest of the test
# due to Ironic's evolution of drivers.
self.useFixture(
api_microversion_fixture.APIMicroversionFixture('1.31'))
_, self.node = self.create_node(self.chassis['uuid'],
deploy_interface='fake',
network_interface='noop')
self.useFixture(
api_microversion_fixture.APIMicroversionFixture('1.11')
)
@decorators.idempotent_id('31f53828-b83d-40c7-98e5-843e28a1b6b9')
def test_set_node_provision_state(self):
_, node = self.create_node(self.chassis['uuid'],
deploy_interface='fake',
network_interface='noop')
# Nodes appear in ENROLL state by default from v1.11
self.assertEqual('enroll', node['provision_state'])
self.assertEqual('enroll', self.node['provision_state'])
provision_states_list = [
'manage', 'inspect', 'provide', 'active', 'deleted']
target_states_list = [
'manageable', 'manageable', 'available', 'active', 'available']
for (provision_state, target_state) in zip(provision_states_list,
target_states_list):
self.client.set_node_provision_state(node['uuid'], provision_state)
self._validate_provision_state(node['uuid'], target_state)
self.client.set_node_provision_state(self.node['uuid'],
provision_state)
self._validate_provision_state(self.node['uuid'],
target_state)
class TestNodeStatesV1_12(TestNodeStatesMixin, base.BaseBaremetalTest):

View File

@ -25,8 +25,7 @@ class TestPorts(base.BaseBaremetalTest):
super(TestPorts, self).setUp()
_, self.chassis = self.create_chassis()
_, self.node = self.create_node(self.chassis['uuid'],
network_interface='noop')
_, self.node = self.create_node(self.chassis['uuid'])
_, self.port = self.create_port(self.node['uuid'],
data_utils.rand_mac_address())

View File

@ -25,8 +25,7 @@ class TestPortsNegative(base.BaseBaremetalTest):
super(TestPortsNegative, self).setUp()
_, self.chassis = self.create_chassis()
_, self.node = self.create_node(self.chassis['uuid'],
network_interface='noop')
_, self.node = self.create_node(self.chassis['uuid'])
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0a6ee1f7-d0d9-4069-8778-37f3aa07303a')