From a82f926a21b9af81f296f584451e8efdb4c9b0cb Mon Sep 17 00:00:00 2001 From: Jaroslav Henner Date: Tue, 7 Aug 2018 10:44:43 +0200 Subject: [PATCH] Fix test_sdn_nsg_firewall_rules. * Do network provider refresh. It should be refreshed to get new port rules. * Move port rule params to the test case * address issues in wrapanapi PR https://github.com/ManageIQ/integration_tests/pull/7596 * Fix filtering in security_group --- cfme/networks/security_group.py | 5 ++-- .../networks/test_sdn_inventory_collection.py | 29 ++++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/cfme/networks/security_group.py b/cfme/networks/security_group.py index 13b889ef69..4ced381889 100644 --- a/cfme/networks/security_group.py +++ b/cfme/networks/security_group.py @@ -35,8 +35,8 @@ def network_provider(self): view = navigate_to(self, 'Details') try: prov_name = view.entities.relationships.get_text_of("Network Manager") - collection = self.appliance.collections.network_provider - return collection.instantiate(name=prov_name) + net_prov_collection = self.appliance.collections.network_provider + return net_prov_collection.instantiate(name=prov_name) except ItemNotFound: # BZ 1480577 return None @@ -54,6 +54,7 @@ def all(self): else: view = navigate_to(self, 'All') list_networks_obj = view.entities.get_all(surf_pages=True) + return [self.instantiate(name=s.name) for s in list_networks_obj] diff --git a/cfme/tests/networks/test_sdn_inventory_collection.py b/cfme/tests/networks/test_sdn_inventory_collection.py index fff9a3aac5..6907b4bfa5 100644 --- a/cfme/tests/networks/test_sdn_inventory_collection.py +++ b/cfme/tests/networks/test_sdn_inventory_collection.py @@ -1,5 +1,6 @@ import fauxfactory import pytest +from wait_for import wait_for from cfme.cloud.provider.azure import AzureProvider from cfme.cloud.provider.ec2 import EC2Provider @@ -109,7 +110,10 @@ def secgroup_with_rule(provider): res_group = provider.data['provisioning']['resource_group'] secgroup_name = 'secgroup_with_rule_{}'.format(fauxfactory.gen_alpha(8).lower()) provider.mgmt.create_netsec_group(secgroup_name, res_group) - provider.mgmt.create_netsec_group_port_allow(secgroup_name, 22, res_group) + provider.mgmt.create_netsec_group_port_allow(secgroup_name, + 'Tcp', '*', '*', 'Allow', 'Inbound', description='Allow port 22', + source_port_range='*', destination_port_range='22', priority=100, + name='Port_22_allow', resource_group=res_group) provider.refresh_provider_relationships() yield secgroup_name provider.mgmt.remove_netsec_group(secgroup_name, res_group) @@ -125,16 +129,25 @@ def test_sdn_nsg_firewall_rules(provider, appliance, secgroup_with_rule): """ # Navigate to network provider. - collection = appliance.collections.network_providers.filter({'provider': provider}) - network_provider = collection.all()[0] + prov_collection = appliance.collections.network_providers.filter({'provider': provider}) + network_provider = prov_collection.all()[0] + network_provider.refresh_provider_relationships() + wait_for(network_provider.is_refreshed, func_kwargs=dict(refresh_delta=10), timeout=600) view = navigate_to(network_provider, 'Details') parent_name = view.entities.relationships.get_text_of("Parent Cloud Provider") assert parent_name == provider.name - # Navigate to secgroup. - collection = appliance.collections.network_security_groups.filter({'name': secgroup_with_rule}) - secgroup = collection.all()[0] + secgrp_collection = appliance.collections.network_security_groups + secgroup = [i for i in secgrp_collection.all() if i.name == secgroup_with_rule][0] view = navigate_to(secgroup, 'Details') - assert 'Port' == view.entities.firewall_rules[0][3].text - assert '22' == view.entities.firewall_rules[1][3].text + if appliance.version < '5.10': + # The table has one header row. The first non-header row has column + # names. + assert 'Port' == view.entities.firewall_rules[1][3].text + assert '22' == view.entities.firewall_rules[2][3].text + else: + # The table has two header rows. We cannot access the second one with + # widgetastic. So let's hope the column of index 3 is the Port Range + # column. + assert '22' == view.entities.firewall_rules[1][3].text