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 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 run_smartstate_analysis(self, wait_for_task_result=False): """Runs smartstate analysis on this host. Note: The host must have valid credentials already set up for this to work. """ view = navigate_to(self, "Details") view.toolbar.configuration.item_select("Perform SmartState Analysis", handle_alert=True) view.flash.assert_success_message('"{}": Analysis successfully initiated'.format(self.name)) if wait_for_task_result: view = self.appliance.browser.create_view(TasksView) wait_for(lambda: is_host_analysis_finished(self.name), delay=15, timeout="10m", fail_func=view.reload.click)
def test_host_assigned_zones(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: if quad.name != NODE_TYPE: break 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('Relationships', 'Availability Zone') assert result == 'nova'
def test_host_security(provider, soft_assert): 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')) soft_assert( int(host.get_detail("Security", "Users")) > 0, 'Nodes number of Users is 0') soft_assert( int(host.get_detail("Security", "Groups")) > 0, 'Nodes number of Groups is 0')
def test_host_cpu_resources(provider, soft_assert): 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')) soft_assert(get_integer_value(host.get_detail("Properties", "Number of CPUs")) > 0, "Aggregate Node CPU resources is 0") soft_assert(get_integer_value( host.get_detail("Properties", "Number of CPU Cores")) > 0, "Aggregate node CPUs is 0") soft_assert(get_integer_value( host.get_detail("Properties", "CPU Cores Per Socket")) > 0, "Aggregate Node CPU Cores is 0")
def test_run_host_analysis(request, setup_provider, provider, host_type, host_name, register_event, soft_assert, bug): """ Run host SmartState analysis Metadata: test_flag: host_analysis """ # Add credentials to host host_data = get_host_data_by_name(provider.key, host_name) test_host = host.Host(name=host_name, provider=provider) wait_for(lambda: test_host.exists, delay=10, num_sec=120) if not test_host.has_valid_credentials: with update(test_host): test_host.credentials = host.get_credentials_from_config(host_data['credentials']) wait_for(lambda: test_host.has_valid_credentials, delay=10, num_sec=120) # Remove creds after test @request.addfinalizer def _host_remove_creds(): with update(test_host): test_host.credentials = host.Host.Credential( principal="", secret="", verify_secret="") builder = EventBuilder(get_or_create_current_appliance()) base_evt = partial(builder.new_event, target_type='Host', target_name=host_name) register_event(base_evt(event_type='request_host_scan'), base_evt(event_type='host_scan_complete')) # Initiate analysis test_host.run_smartstate_analysis() wait_for(lambda: is_host_analysis_finished(host_name), delay=15, timeout="10m", fail_func=lambda: toolbar.select('Reload')) # Check results of the analysis drift_history = test_host.get_detail('Relationships', 'Drift History') soft_assert(drift_history != '0', 'No drift history change found') if provider.type == "rhevm": soft_assert(test_host.get_detail('Configuration', 'Services') != '0', 'No services found in host detail') if host_type in ('rhel', 'rhev'): soft_assert(InfoBlock.text('Security', 'Users') != '0', 'No users found in host detail') soft_assert(InfoBlock.text('Security', 'Groups') != '0', 'No groups found in host detail') soft_assert(InfoBlock.text('Security', 'SSH Root') != '', 'No packages found in host detail') soft_assert(InfoBlock.text('Configuration', 'Packages') != '0', 'No packages found in host detail') soft_assert(InfoBlock.text('Configuration', 'Files') != '0', 'No files found in host detail') soft_assert(InfoBlock.text('Security', 'Firewall Rules') != '0', 'No firewall rules found in host detail') elif host_type in ('esx', 'esxi'): soft_assert(InfoBlock.text('Configuration', 'Advanced Settings') != '0', 'No advanced settings found in host detail') if not(provider.type == "virtualcenter" and provider.version < "5"): # If the Firewall Rules are 0, the element can't be found (it's not a link) try: # This fails for vsphere4... https://bugzilla.redhat.com/show_bug.cgi?id=1055657 list_acc.select('Security', 'Show the firewall rules on this Host') except ListAccordionLinkNotFound: # py.test's .fail would wipe the soft_assert data soft_assert(False, "No firewall rules found in host detail accordion")
def test_run_host_analysis(request, setup_provider, provider, host_type, host_name, register_event, soft_assert, bug): """ Run host SmartState analysis Metadata: test_flag: host_analysis """ # Add credentials to host host_data = get_host_data_by_name(provider.key, host_name) test_host = host.Host(name=host_name) wait_for(lambda: test_host.exists, delay=10, num_sec=120) if not test_host.has_valid_credentials: with update(test_host): test_host.credentials = host.get_credentials_from_config( host_data['credentials']) wait_for(lambda: test_host.has_valid_credentials, delay=10, num_sec=120) # Remove creds after test @request.addfinalizer def _host_remove_creds(): with update(test_host): test_host.credentials = host.Host.Credential(principal="", secret="", verify_secret="") register_event(None, "host", host_name, ["host_analysis_request", "host_analysis_complete"]) # Initiate analysis test_host.run_smartstate_analysis() wait_for(lambda: is_host_analysis_finished(host_name), delay=15, timeout="10m", fail_func=lambda: toolbar.select('Reload')) # Check results of the analysis drift_history = test_host.get_detail('Relationships', 'Drift History') soft_assert(drift_history != '0', 'No drift history change found') if provider.type == "rhevm": soft_assert( test_host.get_detail('Configuration', 'Services') != '0', 'No services found in host detail') if host_type in ('rhel', 'rhev'): soft_assert( InfoBlock.text('Security', 'Users') != '0', 'No users found in host detail') soft_assert( InfoBlock.text('Security', 'Groups') != '0', 'No groups found in host detail') soft_assert( InfoBlock.text('Security', 'SSH Root') != '', 'No packages found in host detail') soft_assert( InfoBlock.text('Configuration', 'Packages') != '0', 'No packages found in host detail') soft_assert( InfoBlock.text('Configuration', 'Files') != '0', 'No files found in host detail') soft_assert( InfoBlock.text('Security', 'Firewall Rules') != '0', 'No firewall rules found in host detail') elif host_type in ('esx', 'esxi'): soft_assert( InfoBlock.text('Configuration', 'Advanced Settings') != '0', 'No advanced settings found in host detail') if not (provider.type == "virtualcenter" and provider.version < "5"): # If the Firewall Rules are 0, the element can't be found (it's not a link) try: # This fails for vsphere4... https://bugzilla.redhat.com/show_bug.cgi?id=1055657 list_acc.select('Security', 'Show the firewall rules on this Host') except ListAccordionLinkNotFound: # py.test's .fail would wipe the soft_assert data soft_assert( False, "No firewall rules found in host detail accordion")
def test_run_host_analysis(appliance, request, setup_provider, provider, host_type, host_name, register_event, soft_assert, bug): """ Run host SmartState analysis Metadata: test_flag: host_analysis """ # Add credentials to host host_data = get_host_data_by_name(provider.key, host_name) host_collection = appliance.collections.hosts test_host = host_collection.instantiate(name=host_name, provider=provider) wait_for(lambda: test_host.exists, delay=10, num_sec=120) if not test_host.has_valid_credentials: with update(test_host): test_host.credentials = host.get_credentials_from_config(host_data['credentials']) wait_for(lambda: test_host.has_valid_credentials, delay=10, num_sec=120) # Remove creds after test @request.addfinalizer def _host_remove_creds(): with update(test_host): test_host.credentials = host.Host.Credential( principal="", secret="", verify_secret="") register_event(target_type='Host', target_name=host_name, event_type='request_host_scan') register_event(target_type='Host', target_name=host_name, event_type='host_scan_complete') # Initiate analysis test_host.run_smartstate_analysis() wait_for(lambda: is_host_analysis_finished(host_name), delay=15, timeout="10m", fail_func=lambda: reload_tasks_page(appliance)) # Check results of the analysis drift_history = test_host.get_detail('Relationships', 'Drift History') soft_assert(drift_history != '0', 'No drift history change found') if provider.type == "rhevm": soft_assert(test_host.get_detail('Configuration', 'Services') != '0', 'No services found in host detail') if host_type in ('rhel', 'rhev'): view = navigate_to(test_host, 'Details') # will return list of values if some of them are active accordion_info = view.security_accordion.navigation.read() soft_assert(not accordion_info) soft_assert(test_host.get_detail('Configuration', 'Packages') != '0', 'No packages found in host detail') soft_assert(test_host.get_detail('Configuration', 'Files') != '0', 'No files found in host detail') elif host_type in ('esx', 'esxi'): soft_assert(test_host.get_detail('Configuration', 'Advanced Settings') != '0', 'No advanced settings found in host detail') if not(provider.type == "virtualcenter" and provider.version < "5"): # If the Firewall Rules are 0, the element can't be found (it's not a link) try: # This fails for vsphere4... https://bugzilla.redhat.com/show_bug.cgi?id=1055657 view = navigate_to(test_host, 'Details') view.security_accordion.navigation.select('Firewall Rules') except NoSuchElementException: # py.test's .fail would wipe the soft_assert data soft_assert(False, "No firewall rules found in host detail accordion")