def test_host_delete(provider): navigate_to(provider, 'ProviderNodes') quad_names = [q.name for q in Quadicon.all() if 'Compute' in q.name] host_name = random.choice(quad_names) host = Host(host_name, provider=provider) host.delete(cancel=False) flash.assert_no_errors() wait_for_host_delete(host) navigate_to(provider, 'ProviderNodes') assert host_name not in [q.name for q in Quadicon.all()]
def test_role_delete(provider): navigate_to(DeploymentRoles, 'All') quads = list(Quadicon.all()) assert quads > 0 role_name = choice(quads).name dr = DeploymentRoles(role_name, provider) dr.delete() flash.assert_no_errors() navigate_to(dr, 'AllForProvider') names = [q.name for q in list(Quadicon.all())] assert role_name not in names
def test_roles_summary(provider, soft_assert): err_ptrn = '{} are shown incorrectly' navigate_to(DeploymentRoles('', provider), 'AllForProvider') roles_names = [q.name for q in Quadicon.all()] for name in roles_names: dr = DeploymentRoles(name, provider) navigate_to(dr, 'DetailsFromProvider') for v in ('Nodes', 'Direct VMs', 'All VMs'): res = dr.get_detail('Relationships', v) soft_assert(res.isdigit(), err_ptrn.format(v)) for v in ('Total CPUs', 'Total Node CPU Cores'): res = dr.get_detail('Totals for Nodes', v) soft_assert(res.isdigit() and int(res) > 0, err_ptrn.format(v)) total_cpu = dr.get_detail('Totals for Nodes', 'Total CPU Resources') soft_assert('GHz' in total_cpu, err_ptrn.format('Total CPU Resources')) total_memory = dr.get_detail('Totals for Nodes', 'Total Memory') soft_assert('GB' in total_memory, err_ptrn.format('Total Memory')) for v in ('Total Configured Memory', 'Total Configured CPUs'): res = dr.get_detail('Totals for VMs', v) soft_assert(res, err_ptrn.format(v))
def select_two_quads(): count = 0 for quad in Quadicon.all("infra_prov", this_page=True): count += 1 if count > 2: break fill(quad.checkbox(), True)
def test_data_integrity_for_topology(test_data): """ This test verifies that every status box value under Containers Overview is identical to the number present on its page. Steps: * Go to Containers / Overview * All cells should contain the correct relevant information # of nodes # of providers # ... """ section_values = {} sel.force_navigate('container_dashboard') # We should wait ~2 seconds for the StatusBox population # (until we find a better solution) time.sleep(2) status_box = StatusBox(test_data[2]) section_values[test_data[0]] = int(status_box.value()) sel.force_navigate(test_data[1]) if section_values[test_data[0]] > 0: if test_data[0] is Provider: assert len(map(lambda i: i, Quadicon.all())) == section_values[test_data[0]] else: assert len(map(lambda r: r, test_data[3].rows()) ) == section_values[test_data[0]] else: assert sel.is_displayed_text('No Records Found.')
def delete_all_attached_vms(self): self.load_details() sel.click(details_page.infoblock.element("Relationships", "Managed VMs")) for q in Quadicon.all('vm'): fill(q.checkbox(), True) cfg_btn("Remove selected items from the VMDB", invokes_alert=True) sel.handle_alert(cancel=False)
def get_all_clusters(): """Returns list of all clusters""" sel.force_navigate('infrastructure_clusters') clusters = [] for cluster in Quadicon.all(this_page=True): clusters.append(Cluster(cluster.name)) return clusters
def test_host_hostname(provider, soft_assert): provider.summary.relationships.nodes.click() my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name, provider=provider) result = host.get_detail("Properties", "Hostname") soft_assert(result, "Missing hostname in: " + str(result))
def test_host_devices(provider): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name, provider=provider) assert int(host.get_detail("Properties", "Devices")) > 0
def test_delete_instance(new_instance): new_instance.power_control_from_cfme(from_details=True, option=OpenStackInstance.TERMINATE) new_instance.wait_for_instance_state_change(OpenStackInstance.STATE_UNKNOWN) assert new_instance.name not in new_instance.provider.mgmt.list_vm() navigate_to(new_instance, 'AllForProvider') assert new_instance.name not in [q.name for q in Quadicon.all()]
def test_host_auth(provider, soft_assert): navigate_to(provider, 'ProviderNodes') quads = list(Quadicon.all()) for quad in quads: host = Host(name=quad.name, provider=provider) navigate_to(host, 'Details') auth_status = host.get_detail('Authentication Status', 'SSH Key Pair Credentials') soft_assert(auth_status == 'Valid', 'Incorrect SSH authentication status {}'.format(auth_status))
def test_smbios_data(provider): provider.load_details() sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name) result = get_integer_value(host.get_detail("Properties", "Memory")) assert result > 0
def test_host_memory(provider): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name, provider=provider) result = int(host.get_detail("Properties", "Memory").split()[0]) assert result > 0
def get_clusters(self): """returns the list of clusters belonging to the provider""" web_clusters = [] navigate_to(self, "Details") sel.click(InfoBlock.element("Relationships", "Clusters")) icons = Quadicon.all(qtype="cluster") for icon in icons: web_clusters.append(Cluster(icon.name, self)) return web_clusters
def get_clusters(self): """returns the list of clusters belonging to the provider""" web_clusters = [] sel.force_navigate('infrastructure_provider', context={'provider': self}) sel.click(InfoBlock.element('Relationships', 'Clusters')) icons = Quadicon.all(qtype='cluster') for icon in icons: web_clusters.append(Cluster(icon.name, self)) return web_clusters
def test_host_role_type(provider): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: role_name = str(quad.name) role_name = re.search(r'\((\w+)\)', role_name).group(1) assert role_name in ROLES
def test_roles_name(provider): sel.force_navigate("infrastructure_clusters") my_roles_quads = list(Quadicon.all()) result = True while result: for quad in my_roles_quads: role_name = str(quad.name).split('-')[1] if role_name not in ROLES: result = False assert result
def test_roles_name(provider): navigate_to(Cluster, 'All') my_roles_quads = list(Quadicon.all()) result = True while result: for quad in my_roles_quads: role_name = str(quad.name).split('-')[1] if role_name not in ROLES: result = False assert result
def get_clusters(self): """returns the list of clusters belonging to the provider""" web_clusters = [] view = navigate_to(self, 'Details') # todo: create nav location + view later view.contents.relationships.click_at('Clusters') icons = Quadicon.all(qtype='cluster') for icon in icons: web_clusters.append(Cluster(icon.name, self)) return web_clusters
def delete_all_attached_hosts(self): self.load_details() sel.click(details_page.infoblock.element("Relationships", "Hosts")) for q in Quadicon.all('host'): fill(q.checkbox(), True) path = version.pick({ version.LOWEST: "Remove Hosts from the VMDB", "5.4": "Remove items from the VMDB"}) cfg_btn(path, invokes_alert=True) sel.handle_alert(cancel=False)
def test_host_smbios_data(provider, soft_assert): """Checks that Manufacturer/Model values are shown for each infra node""" navigate_to(provider, 'ProviderNodes') names = [q.name for q in list(Quadicon.all())] for node in names: host = Host(node, provider=provider) navigate_to(host, 'Details') res = host.get_detail('Properties', 'Manufacturer / Model') soft_assert(res, 'Manufacturer / Model value are empty') soft_assert(res != 'N/A')
def test_host_zones_assigned(provider): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 my_quads = filter(lambda q: True if 'Compute' in q.name else False, my_quads) for quad in my_quads: host = Host(name=quad.name, provider=provider) result = host.get_detail('Relationships', 'Availability Zone') assert result, "Availability zone doesn't specified"
def get_vms(self): """ Returns names of VMs (from quadicons) that use this datastore Returns: List of strings with names or `[]` if no vms found. """ self.load_details() try: list_acc.select('Relationships', "VMs", by_title=False, partial=True) except (sel.NoSuchElementException, ListAccordionLinkNotFound): sel.click(InfoBlock('Relationships', 'Managed VMs')) return [q.name for q in Quadicon.all("vm")]
def test_host_hostname(provider): provider.summary.relationship.nodes.click() my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name) host.run_smartstate_analysis() wait_for(lambda: is_host_analysis_finished(host.name), delay=15, timeout="10m", fail_func=lambda: toolbar.select('Reload')) result = host.get_detail("Properties", "Hostname") assert result != ''
def get_hosts(self): """ Returns names of hosts (from quadicons) that use this datastore Returns: List of strings with names or `[]` if no hosts found. """ self.load_details() try: sel.click(details_page.infoblock.element("Relationships", "Hosts")) except sel.NoSuchElementException: sel.click(InfoBlock('Relationships', 'Hosts')) return [q.name for q in Quadicon.all("host")]
def test_host_cpu_resources(provider, soft_assert): navigate_to(provider, 'Details') sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name, provider=provider) fields = ['Number of CPUs', 'Number of CPU Cores', 'CPU Cores Per Socket'] for field in fields: value = int(host.get_detail("Properties", field)) soft_assert(value > 0, "Aggregate Node {} is 0".format(field))
def get_hosts(self): """ Returns names of hosts (from quadicons) that use this datastore Returns: List of strings with names or `[]` if no hosts found. """ if not self._on_hosts_page(): sel.force_navigate('infrastructure_datastore', context=self._get_context()) try: sel.click(details_page.infoblock.element("Relationships", "Hosts")) except sel.NoSuchElementException: sel.click(InfoBlock('Relationships', 'Hosts')) return [q.name for q in Quadicon.all("host")]
def get_vms(self): """ Returns names of VMs (from quadicons) that use this datastore Returns: List of strings with names or `[]` if no vms found. """ if not self._on_vms_page(): sel.force_navigate('infrastructure_datastore', context=self._get_context()) try: list_acc.select('Relationships', "VMs", by_title=False, partial=True) except (sel.NoSuchElementException, ListAccordionLinkNotFound): return [] return [q.name for q in Quadicon.all("vm")]
def get_hosts(self): """ Returns names of hosts (from quadicons) that use this datastore Returns: List of strings with names or `[]` if no hosts found. """ if not self._on_hosts_page(): sel.force_navigate('infrastructure_datastore', context=self._get_context()) try: list_acc.select('Relationships', 'Show all registered Hosts') except sel.NoSuchElementException: return [] return [q.name for q in Quadicon.all("host")]
def test_smbios_data(provider): provider.load_details() sel.click(InfoBlock.element("Relationships", "Nodes")) my_quads = list(Quadicon.all()) assert len(my_quads) > 0 for quad in my_quads: host = Host(name=quad.name) host.run_smartstate_analysis() wait_for(lambda: is_host_analysis_finished(host.name), delay=15, timeout="10m", fail_func=lambda: toolbar.select('Reload')) result = get_integer_value(host.get_detail("Properties", "Memory")) assert result > 0
def test_list_vms_infra_node(provider, soft_assert): navigate_to(provider.infra_provider, 'ProviderNodes') # Match hypervisors by IP with count of running VMs hvisors = { hv.host_ip: hv.running_vms for hv in provider.mgmt.api.hypervisors.list() } # Skip non-compute nodes quads = [q.name for q in Quadicon.all() if 'Compute' in q.name] for quad in quads: host = Host(quad, provider=provider.infra_provider) host_ip = host.get_detail('Properties', 'IP Address') vms = int(host.get_detail('Relationships', 'VMs')) soft_assert( vms == hvisors[host_ip], 'Number of instances on UI does not match with real value')
def test_multiple_host_bad_creds(setup_provider, provider): """ Tests multiple host credentialing with bad credentials """ sel.force_navigate('infrastructure_provider', context={'provider': provider}) sel.click(details_page.infoblock.element("Relationships", "Hosts")) quads = Quadicon.all("host", this_page=True) for quad in quads: sel.check(quad.checkbox()) tb.select("Configuration", config_option()) cfme_host = random.choice(provider.data["hosts"]) creds = conf.credentials['bad_credentials'] fill(credential_form, {'default_principal': creds['username'], 'default_secret': creds['password'], 'default_verify_secret': creds['password'], 'validate_host': cfme_host["name"]}) sel.click(credential_form.validate_multi_host) flash.assert_message_match('Cannot complete login due to an incorrect user name or password.') sel.click(credential_form.cancel_changes)
def test_multiple_host_good_creds(setup_provider, provider): """ Tests multiple host credentialing with good credentials """ sel.force_navigate('infrastructure_provider', context={'provider': provider}) sel.click(details_page.infoblock.element("Relationships", "Hosts")) quads = Quadicon.all("host", this_page=True) for quad in quads: sel.check(quad.checkbox()) tb.select("Configuration", config_option()) cfme_host = random.choice(provider.data["hosts"]) cred = cfme_host['credentials'] creds = conf.credentials[cred] fill(credential_form, {'default_principal': creds['username'], 'default_secret': creds['password'], 'default_verify_secret': creds['password'], 'validate_host': cfme_host["name"]}) sel.click(credential_form.validate_multi_host) flash.assert_message_match('Credential validation was successful') sel.click(credential_form.save_btn) flash.assert_message_match('Credentials/Settings saved successfully')
def test_multiple_host_good_creds(setup_provider, provider): """ Tests multiple host credentialing with good credentials """ details_view = navigate_to(provider, 'Details') details_view.contents.relationships.click_at('Hosts') quads = Quadicon.all("host", this_page=True) for quad in quads: sel.check(quad.checkbox()) tb.select("Configuration", config_option()) cfme_host = random.choice(provider.data["hosts"]) cred = cfme_host['credentials'] creds = conf.credentials[cred] fill(credential_form, {'default_principal': creds['username'], 'default_secret': creds['password'], 'default_verify_secret': creds['password'], 'validate_host': cfme_host["name"]}) sel.click(credential_form.validate_multi_host) flash.assert_message_match('Credential validation was successful') sel.click(credential_form.save_btn) flash.assert_message_match('Credentials/Settings saved successfully')
def test_delete_provider(provider): provider.delete(cancel=False) navigate_to(provider, 'All') assert provider.name not in [q.name for q in Quadicon.all()]
def get_all_vms(do_not_navigate=False): """Returns list of all vms""" if not do_not_navigate: navigate_to(Vm, 'VMsOnly') return [q.name for q in Quadicon.all("vm")]
def get_all_datastores(do_not_navigate=False): """Returns names (from quadicons) of all datastores""" if not do_not_navigate: navigate_to(Datastore, 'All') return [q.name for q in Quadicon.all("datastore")]
def test_roles_name(): navigate_to(DeploymentRoles, 'All') my_roles_quads = list(Quadicon.all()) for quad in my_roles_quads: role_name = str(quad.name).split('-')[1] assert role_name in ROLES
def get_all_datastores(do_not_navigate=False): """Returns names (from quadicons) of all datastores""" if not do_not_navigate: sel.force_navigate('infrastructure_datastores') return [q.name for q in Quadicon.all("datastore")]
def get_all_resourcepools(do_not_navigate=False): """Returns list of all resource pools""" if not do_not_navigate: sel.force_navigate('infrastructure_resource_pools') return [q.name for q in Quadicon.all("resource_pool")]
def get_all_resourcepools(do_not_navigate=False): """Returns list of all resource pools""" if not do_not_navigate: navigate_to(ResourcePool, 'All') return [q.name for q in Quadicon.all(qtype='resource_pool')]
def get_datastores(self): """ Gets list of all datastores used by this host""" navigate_to(self, 'Details') list_acc.select('Relationships', 'Datastores', by_title=False, partial=True) return [q.name for q in Quadicon.all("datastore")]
def get_all_hosts(do_not_navigate=False): """Returns list of all hosts""" if not do_not_navigate: navigate_to(Host, 'All') return [q.name for q in Quadicon.all("host")]