From 5dbef21cb33774cdbaea45f5710ccc7184d6cd61 Mon Sep 17 00:00:00 2001 From: Kyrylo Romanenko Date: Fri, 19 Jan 2024 05:24:44 +0400 Subject: [PATCH] [WiP] Add negative tests for VIF attach/detach operations Change-Id: I657fbecd37ceec424da6182507f324b653288857 --- .../tests/api/admin/test_nodes.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ironic_tempest_plugin/tests/api/admin/test_nodes.py b/ironic_tempest_plugin/tests/api/admin/test_nodes.py index 8e8e217e..914cfbd7 100644 --- a/ironic_tempest_plugin/tests/api/admin/test_nodes.py +++ b/ironic_tempest_plugin/tests/api/admin/test_nodes.py @@ -413,6 +413,31 @@ 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) + class TestHardwareInterfaces(base.BaseBaremetalTest):