[WiP] Add negative tests for VIF attach/detach operations
Add tests: test_vif_already_attached_on_internal_info test_vif_already_attached_with_portgroups test_vif_attach_no_free_port Change-Id: I657fbecd37ceec424da6182507f324b653288857
This commit is contained in:
parent
227a519fc9
commit
81c1182b95
|
@ -413,6 +413,88 @@ class TestNodesVif(base.BaseBaremetalTest):
|
|||
|
||||
self.client.vif_detach(self.node['uuid'], self.nport_id)
|
||||
|
||||
@decorators.attr(type='negative')
|
||||
@decorators.idempotent_id('628350f8-4498-4204-b546-f3c01b93c7e3')
|
||||
def test_vif_already_attached_on_internal_info(self):
|
||||
"""Negative test for duplicated attachment/detachment of VIFs.
|
||||
|
||||
Test steps:
|
||||
1) Create chassis and node in setUp.
|
||||
2) Create port for the node.
|
||||
3) Attach VIF to the node.
|
||||
4) Try to attach the same VIF to the node.
|
||||
5) Detach VIF from the node.
|
||||
6) Try to detach the same VIF from the node.
|
||||
"""
|
||||
self.useFixture(
|
||||
api_microversion_fixture.APIMicroversionFixture('1.28'))
|
||||
_, self.port = self.create_port(self.node['uuid'],
|
||||
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)
|
||||
self.assertRaises(lib_exc.BadRequest, self.client.vif_detach,
|
||||
self.node['uuid'], self.nport_id)
|
||||
|
||||
@decorators.attr(type='negative')
|
||||
@decorators.idempotent_id('ec0c14a4-6853-4907-9091-755c9c6c152f')
|
||||
def test_vif_already_attached_with_portgroups(self):
|
||||
"""Negative test: try duplicated attachment of VIFs with port groups.
|
||||
|
||||
Test steps:
|
||||
1) Create chassis and node in setUp.
|
||||
2) Create port for the node.
|
||||
3) Create port group for the node.
|
||||
4) Plug port into port group.
|
||||
5) Attach VIF to the node.
|
||||
6) Try to attach the same VIF to the node.
|
||||
7) Check that VIF was not attached to port when portgroup is busy.
|
||||
8) Detach VIF from the node.
|
||||
9) Check there is no VIF data in port group internal info.
|
||||
"""
|
||||
_, self.port = self.create_port(self.node['uuid'],
|
||||
data_utils.rand_mac_address())
|
||||
_, self.portgroup = self.create_portgroup(
|
||||
self.node['uuid'], address=data_utils.rand_mac_address())
|
||||
|
||||
patch = [{'path': '/portgroup_uuid',
|
||||
'op': 'add',
|
||||
'value': self.portgroup['uuid']}]
|
||||
self.client.update_port(self.port['uuid'], patch)
|
||||
self.client.vif_attach(self.node['uuid'], self.nport_id)
|
||||
self.assertRaises(lib_exc.Conflict, self.client.vif_attach,
|
||||
self.node['uuid'], self.nport_id)
|
||||
|
||||
_, port = self.client.show_port(self.port['uuid'])
|
||||
self.assertNotIn('tenant_vif_port_id', port['internal_info'])
|
||||
|
||||
self.client.vif_detach(self.node['uuid'], self.nport_id)
|
||||
_, portgroup = self.client.show_portgroup(self.portgroup['uuid'])
|
||||
self.assertNotIn('tenant_vif_port_id', portgroup['internal_info'])
|
||||
|
||||
@decorators.attr(type='negative')
|
||||
@decorators.idempotent_id('91e08d6a-0438-4171-b404-bc86b0bc8861')
|
||||
def test_vif_attach_no_free_port(self):
|
||||
"""Negative test for VIF attachment attempt with no free ports.
|
||||
Test steps:
|
||||
1) Create chassis and node in setUp.
|
||||
2) Create port for the node.
|
||||
3) Attach VIF to the node.
|
||||
4) Try to attach new VIF to the same node with port.
|
||||
5) Check that VIF still attached with original port.
|
||||
"""
|
||||
_, self.port = self.create_port(self.node['uuid'],
|
||||
data_utils.rand_mac_address())
|
||||
self.client.vif_attach(self.node['uuid'], self.nport_id)
|
||||
self.assertRaises(lib_exc.BadRequest, self.client.vif_attach,
|
||||
self.node['uuid'], 'test-vif-new')
|
||||
_, port = self.client.show_port(self.port['uuid'])
|
||||
self.assertEqual(self.nport_id,
|
||||
port['internal_info']['tenant_vif_port_id'])
|
||||
|
||||
|
||||
class TestHardwareInterfaces(base.BaseBaremetalTest):
|
||||
|
||||
|
|
Loading…
Reference in New Issue