Make test test_remove_associated_ports to be compatible with L3HA

Negative API test
neutron_tempest_plugin.api.test_routers_negative.RoutersNegativePolicyTest.\
test_remove_associated_ports

was trying to remove all ports which belongs to the specic device
(router) and expected Conflict response for each of them.
In L3HA environment that's not true and router ha interfaces can be
removed without any problems. That caused failure of the test when L3_ha
was enabled.
This patch fixes it by trying to delete different types of port than ha
interfaces.

Change-Id: Iea2655a4dae2c8e260fb1dff9fdd9f426fe3c1b3
This commit is contained in:
Slawek Kaplonski 2022-04-19 11:30:39 +02:00
parent 1a263ccccb
commit 7c09d72b7e

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
@ -91,7 +92,13 @@ class RoutersNegativePolicyTest(RoutersNegativeTestBase):
self.create_router_interface(self.router['id'], subnet['id'])
port_ids = [
item['id'] for item in self.admin_client.list_ports(
device_id=self.router['id'])['ports']]
device_id=self.router['id'])['ports']
if item['device_owner'] not in [
constants.DEVICE_OWNER_ROUTER_HA_INTF,
constants.DEVICE_OWNER_HA_REPLICATED_INT]]
if not port_ids:
self.fail("No ports other than HA ports found for the router %s" %
self.router['id'])
for port_id in port_ids:
with testtools.ExpectedException(lib_exc.Conflict):
self.admin_client.delete_port(port_id)