def test_positive_proxy_option(self, default_org, form_data, virtwho_config): """Verify http_proxy option by hammer virt-who-config update" :id: 409d108e-e814-482b-93ed-09db89d21dda :expectedresults: http_proxy and no_proxy option can be updated. :CaseLevel: Integration :CaseImportance: Medium :BZ: 1902199 """ # Check the https proxy option, update it via http proxy name https_proxy_url, https_proxy_name, https_proxy_id = create_http_proxy( org=default_org) no_proxy = 'test.satellite.com' VirtWhoConfig.update({ 'id': virtwho_config['id'], 'http-proxy': https_proxy_name, 'no-proxy': no_proxy }) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['http-proxy']['http-proxy-name'] == https_proxy_name assert result['connection']['ignore-proxy'] == no_proxy command = get_configure_command(virtwho_config['id'], default_org.name) deploy_configure_by_command(command, form_data['hypervisor-type'], org=default_org.label) assert get_configure_option('https_proxy', ETC_VIRTWHO_CONFIG) == https_proxy_url assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == no_proxy # Check the http proxy option, update it via http proxy id http_proxy_url, http_proxy_name, http_proxy_id = create_http_proxy( http_type='http', org=default_org) VirtWhoConfig.update({ 'id': virtwho_config['id'], 'http-proxy-id': http_proxy_id }) deploy_configure_by_command(command, form_data['hypervisor-type'], org=default_org.label) assert get_configure_option('http_proxy', ETC_VIRTWHO_CONFIG) == http_proxy_url VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_proxy_option(self, default_org, session, form_data): """Verify 'HTTP Proxy' and 'Ignore Proxy' options. :id: 6659d577-0135-4bf0-81af-14b930011536 :expectedresults: http_proxy/https_proxy and NO_PROXY will be setting in /etc/sysconfig/virt-who. :CaseLevel: Integration :CaseImportance: Medium """ https_proxy, https_proxy_name, https_proxy_id = create_http_proxy( org=default_org) http_proxy, http_proxy_name, http_proxy_id = create_http_proxy( http_type='http', org=default_org) name = gen_string('alpha') form_data['name'] = name with session: session.virtwho_configure.create(form_data) config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) no_proxy = 'test.satellite.com' # Check the https proxy and No_PROXY settings session.virtwho_configure.edit(name, { 'proxy': https_proxy, 'no_proxy': no_proxy }) results = session.virtwho_configure.read(name) assert results['overview']['proxy'] == https_proxy assert results['overview']['no_proxy'] == no_proxy deploy_configure_by_command(config_command, form_data['hypervisor_type'], org=default_org.label) assert get_configure_option('https_proxy', ETC_VIRTWHO_CONFIG) == https_proxy assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == no_proxy # Check the http proxy setting session.virtwho_configure.edit(name, {'proxy': http_proxy}) results = session.virtwho_configure.read(name) assert results['overview']['proxy'] == http_proxy deploy_configure_by_command(config_command, form_data['hypervisor_type'], org=default_org.label) assert get_configure_option('http_proxy', ETC_VIRTWHO_CONFIG) == http_proxy session.virtwho_configure.delete(name) assert not session.virtwho_configure.search(name)
def test_positive_filter_option(self, form_data, virtwho_config): """Verify filter option by hammer virt-who-config update" :id: aaf45c5e-9504-47ce-8f25-b8073c2de036 :expectedresults: filter and filter_hosts can be updated. :CaseLevel: Integration :CaseImportance: Medium """ regex = '.*redhat.com' whitelist = { 'id': virtwho_config['id'], 'filtering-mode': 'whitelist', 'whitelist': regex } blacklist = { 'id': virtwho_config['id'], 'filtering-mode': 'blacklist', 'blacklist': regex } # esx support filter-host-parents and exclude-host-parents options whitelist['filter-host-parents'] = regex blacklist['exclude-host-parents'] = regex config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) # Update Whitelist and check the result VirtWhoConfig.update(whitelist) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['filtering'] == 'Whitelist' assert result['connection']['filtered-hosts'] == regex assert result['connection']['filter-host-parents'] == regex deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('filter_hosts', config_file) == regex assert get_configure_option('filter_host_parents', config_file) == regex # Update Blacklist and check the result VirtWhoConfig.update(blacklist) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['filtering'] == 'Blacklist' assert result['connection']['excluded-hosts'] == regex assert result['connection']['exclude-host-parents'] == regex deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('exclude_hosts', config_file) == regex assert get_configure_option('exclude_host_parents', config_file) == regex VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_deploy_configure_by_id(self, default_org, form_data, virtwho_config): """Verify "POST /foreman_virt_who_configure/api/v2/configs" :id: 2598cfa8-3bec-4f41-9911-979ae92c89c0 :expectedresults: Config can be created and deployed :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config.status == 'unknown' command = get_configure_command(virtwho_config.id, default_org.name) hypervisor_name, guest_name = deploy_configure_by_command( command, form_data['hypervisor_type'], debug=True, org=default_org.label ) virt_who_instance = ( entities.VirtWhoConfig() .search(query={'search': f'name={virtwho_config.name}'})[0] .status ) assert virt_who_instance == 'ok' hosts = [ ( hypervisor_name, f'product_id={settings.virtwho.sku.vdc_physical} and type=NORMAL', ), ( guest_name, f'product_id={settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED', ), ] for hostname, sku in hosts: host = Host.list({'search': hostname})[0] subscriptions = Subscription.list({'organization': default_org.name, 'search': sku}) vdc_id = subscriptions[0]['id'] if 'type=STACK_DERIVED' in sku: for item in subscriptions: if hypervisor_name.lower() in item['type']: vdc_id = item['id'] break entities.HostSubscription(host=host['id']).add_subscriptions( data={'subscriptions': [{'id': vdc_id, 'quantity': 1}]} ) result = entities.Host().search(query={'search': hostname})[0].read_json() assert result['subscription_status_label'] == 'Fully entitled' virtwho_config.delete() assert not entities.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"})
def test_positive_deploy_configure_by_id(self, form_data, virtwho_config): """ Verify " hammer virt-who-config deploy" :id: 1885dd56-e3f9-43a7-af27-e496967b6256 :expectedresults: Config can be created and deployed :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' command = get_configure_command(virtwho_config['id']) hypervisor_name, guest_name = deploy_configure_by_command( command, form_data['hypervisor-type'], debug=True) virt_who_instance = VirtWhoConfig.info( {'id': virtwho_config['id']})['general-information']['status'] assert virt_who_instance == 'OK' hosts = [ ( hypervisor_name, f'product_id={virtwho.sku.vdc_physical} and type=NORMAL', ), ( guest_name, f'product_id={virtwho.sku.vdc_physical} and type=STACK_DERIVED', ), ] for hostname, sku in hosts: host = Host.list({'search': hostname})[0] subscriptions = Subscription.list({ 'organization': DEFAULT_ORG, 'search': sku }) vdc_id = subscriptions[0]['id'] if 'type=STACK_DERIVED' in sku: for item in subscriptions: if hypervisor_name.lower() in item['type']: vdc_id = item['id'] break result = Host.subscription_attach({ 'host-id': host['id'], 'subscription-id': vdc_id }) assert 'attached to the host successfully' in '\n'.join(result) VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_deploy_configure_by_id(self, form_data, virtwho_config): """ Verify "POST /foreman_virt_who_configure/api/v2/configs" :id: b469822f-8b1f-437b-8193-6723ad3648dd :expectedresults: Config can be created and deployed :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config.status == 'unknown' command = get_configure_command(virtwho_config.id) hypervisor_name, guest_name = deploy_configure_by_command(command, debug=True) virt_who_instance = ( entities.VirtWhoConfig() .search(query={'search': f'name={virtwho_config.name}'})[0] .status ) assert virt_who_instance == 'ok' hosts = [ (hypervisor_name, f'product_id={settings.virtwho.sku_vdc_physical} and type=NORMAL',), ( guest_name, f'product_id={settings.virtwho.sku_vdc_physical} and type=STACK_DERIVED', ), ] for hostname, sku in hosts: if 'type=NORMAL' in sku: subscriptions = entities.Subscription().search(query={'search': sku}) vdc_id = subscriptions[0].id if 'type=STACK_DERIVED' in sku: vdc_id = self._get_guest_bonus(hypervisor_name, sku) host, time = wait_for( entities.Host().search, func_args=(None, {'search': hostname}), fail_condition=[], timeout=5, delay=1, ) entities.HostSubscription(host=host[0].id).add_subscriptions( data={'subscriptions': [{'id': vdc_id, 'quantity': 1}]} ) result = entities.Host().search(query={'search': hostname})[0].read_json() assert result['subscription_status_label'] == 'Fully entitled' virtwho_config.delete() assert not entities.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"})
def test_positive_filtering_option(self, session, form_data): """Verify Filtering dropdown options. :id: e17dda14-79cd-4cd2-8f29-60970b24a905 :expectedresults: 1. if filtering is selected to Whitelist, 'Filter hosts' can be set. 2. if filtering is selected to Blacklist, 'Exclude hosts' can be set. :CaseLevel: Integration :CaseImportance: Medium :BZ: 1735670 """ name = gen_string('alpha') form_data['name'] = name with session: session.virtwho_configure.create(form_data) config_id = get_configure_id(name) config_command = get_configure_command(config_id) config_file = get_configure_file(config_id) regex = '.*redhat.com' whitelist = {'filtering': 'Whitelist', 'filtering_content.filter_hosts': regex} blacklist = {'filtering': 'Blacklist', 'filtering_content.exclude_hosts': regex} # esx support filter-host-parents and exclude-host-parents options whitelist['filtering_content.filter_host_parents'] = regex blacklist['filtering_content.exclude_host_parents'] = regex # Update Whitelist and check the result session.virtwho_configure.edit(name, whitelist) results = session.virtwho_configure.read(name) assert results['overview']['filter_hosts'] == regex assert results['overview']['filter_host_parents'] == regex deploy_configure_by_command(config_command, form_data['hypervisor_type']) assert regex == get_configure_option('filter_hosts', config_file) assert regex == get_configure_option('filter_host_parents', config_file) # Update Blacklist and check the result session.virtwho_configure.edit(name, blacklist) results = session.virtwho_configure.read(name) assert results['overview']['exclude_hosts'] == regex assert results['overview']['exclude_host_parents'] == regex deploy_configure_by_command(config_command, form_data['hypervisor_type']) assert regex == get_configure_option('exclude_hosts', config_file) assert regex == get_configure_option('exclude_host_parents', config_file) session.virtwho_configure.delete(name) assert not session.virtwho_configure.search(name)
def test_positive_configure_organization_list(self, form_data, virtwho_config): """ Verify "GET /foreman_virt_who_configure/ api/v2/organizations/:organization_id/configs" :id: 7434a875-e96a-40bd-9652-83d0805997a5 :expectedresults: Config can be searched in org list :CaseLevel: Integration :CaseImportance: Medium """ command = get_configure_command(virtwho_config.id) deploy_configure_by_command(command) search_result = virtwho_config.get_organization_configs(data={'per_page': 1000}) assert [item for item in search_result['results'] if item['name'] == form_data['name']] virtwho_config.delete() assert not entities.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"})
def test_positive_filter_option(self, form_data, virtwho_config): """ Verify filter option by hammer virt-who-config update" :id: f46e4aa8-c325-4281-8744-f85e819e68c1 :expectedresults: filter and filter_hosts can be updated. :CaseLevel: Integration :CaseImportance: Medium """ regex = '.*redhat.com' whitelist = {'id': virtwho_config['id'], 'filtering-mode': 'whitelist', 'whitelist': regex} blacklist = {'id': virtwho_config['id'], 'filtering-mode': 'blacklist', 'blacklist': regex} if settings.virtwho.hypervisor_type == 'esx': whitelist['filter-host-parents'] = regex blacklist['exclude-host-parents'] = regex config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) # Update Whitelist and check the result VirtWhoConfig.update(whitelist) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['filtering'] == 'Whitelist' assert result['connection']['filtered-hosts'] == regex if settings.virtwho.hypervisor_type == 'esx': assert result['connection']['filter-host-parents'] == regex deploy_configure_by_command(command) assert get_configure_option('filter_hosts', config_file) == regex if settings.virtwho.hypervisor_type == 'esx': assert get_configure_option('filter_host_parents', config_file) == regex # Update Blacklist and check the result VirtWhoConfig.update(blacklist) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['filtering'] == 'Blacklist' assert result['connection']['excluded-hosts'] == regex if settings.virtwho.hypervisor_type == 'esx': assert result['connection']['exclude-host-parents'] == regex deploy_configure_by_command(command) assert get_configure_option('exclude_hosts', config_file) == regex if settings.virtwho.hypervisor_type == 'esx': assert get_configure_option('exclude_host_parents', config_file) == regex VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_configure_organization_list(self, form_data, virtwho_config): """Verify "GET /foreman_virt_who_configure/ api/v2/organizations/:organization_id/configs" :id: 5bf34bef-bf68-4557-978d-419bd4df0ba1 :expectedresults: Config can be searched in org list :CaseLevel: Integration :CaseImportance: Medium """ command = get_configure_command(virtwho_config.id) deploy_configure_by_command(command, form_data['hypervisor_type']) search_result = virtwho_config.get_organization_configs(data={'per_page': '1000'}) assert [item for item in search_result['results'] if item['name'] == form_data['name']] virtwho_config.delete() assert not entities.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"})
def test_positive_interval_option(self, default_org, session, form_data): """Verify interval dropdown options and the value changes of VIRTWHO_INTERVAL. :id: 731f8361-38d4-40b9-9530-8d785d61eaab :expectedresults: VIRTWHO_INTERVAL can be changed in /etc/sysconfig/virt-who if the dropdown option is selected to Every 2/4/8/12/24 hours, Every 2/3 days. :CaseLevel: Integration :CaseImportance: Medium """ name = gen_string('alpha') form_data['name'] = name with session: session.virtwho_configure.create(form_data) config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.label) intervals = { 'Every hour': '3600', 'Every 2 hours': '7200', 'Every 4 hours': '14400', 'Every 8 hours': '28800', 'Every 12 hours': '43200', 'Every 24 hours': '86400', 'Every 2 days': '172800', 'Every 3 days': '259200', } for option, value in sorted(intervals.items(), key=lambda item: int(item[1])): session.virtwho_configure.edit(name, {'interval': option}) results = session.virtwho_configure.read(name) assert results['overview']['interval'] == option deploy_configure_by_command(config_command, form_data['hypervisor_type'], org=default_org.label) assert get_configure_option('interval', ETC_VIRTWHO_CONFIG) == value session.virtwho_configure.delete(name) assert not session.virtwho_configure.search(name)
def test_positive_rhsm_option(self, form_data, virtwho_config): """Verify rhsm options in the configure file" :id: b5b93d4d-e780-41c0-9eaa-2407cc1dcc9b :expectedresults: rhsm_hostname, rhsm_prefix are ecpected rhsm_username is not a login account :CaseLevel: Integration :CaseImportance: Medium """ config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command, form_data['hypervisor-type']) rhsm_username = get_configure_option('rhsm_username', config_file) assert not User.exists(search=('login', rhsm_username)) assert get_configure_option('rhsm_hostname', config_file) == settings.server.hostname assert get_configure_option('rhsm_prefix', config_file) == '/rhsm' VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_debug_option(self, form_data, virtwho_config): """ Verify debug option by "PUT /foreman_virt_who_configure/api/v2/configs/:id" :id: 75a20b8c-bed8-4c55-b291-14bca6cac364 :expectedresults: debug option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ options = {'true': '1', 'false': '0', '1': '1', '0': '0'} for key, value in sorted(options.items(), key=lambda item: item[0]): virtwho_config.debug = key virtwho_config.update(['debug']) command = get_configure_command(virtwho_config.id) deploy_configure_by_command(command) assert get_configure_option('VIRTWHO_DEBUG', VIRTWHO_SYSCONFIG) == value virtwho_config.delete() assert not entities.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"})
def test_positive_rhsm_option(self, form_data, virtwho_config): """ Verify rhsm options in the configure file" :id: 5155d145-0a8d-4443-81d3-6fb7cef0533b :expectedresults: rhsm_hostname, rhsm_prefix are ecpected rhsm_username is not a login account :CaseLevel: Integration :CaseImportance: Medium """ config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command) rhsm_username = get_configure_option('rhsm_username', config_file) assert not User.exists(search=('login', rhsm_username)) assert get_configure_option('rhsm_hostname', config_file) == settings.server.hostname assert get_configure_option('rhsm_prefix', config_file) == '/rhsm' VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_hypervisor_id_option(self, form_data, virtwho_config): """Verify hypervisor_id option by hammer virt-who-config update" :id: 57b89c7e-538e-4ab8-98b5-af4b9f587792 :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ values = ['uuid', 'hostname'] for value in values: VirtWhoConfig.update({'id': virtwho_config['id'], 'hypervisor-id': value}) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['hypervisor-id'] == value config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('hypervisor_id', config_file) == value VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_interval_option(self, default_org, form_data, virtwho_config): """Verify interval option by "PUT /foreman_virt_who_configure/api/v2/configs/:id" :id: 65f4138b-ca8f-4f1e-805c-1a331b951be5 :expectedresults: interval option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ options = { '60': '3600', '120': '7200', '240': '14400', '480': '28800', '720': '43200', '1440': '86400', '2880': '172800', '4320': '259200', } for key, value in sorted(options.items(), key=lambda item: int(item[0])): virtwho_config.interval = key virtwho_config.update(['interval']) command = get_configure_command(virtwho_config.id, default_org.name) deploy_configure_by_command(command, form_data['hypervisor_type'], org=default_org.label) assert get_configure_option('interval', ETC_VIRTWHO_CONFIG) == value virtwho_config.delete() assert not entities.VirtWhoConfig().search( query={'search': f"name={form_data['name']}"})
def test_positive_hypervisor_id_option(self, form_data, virtwho_config): """Verify hypervisor_id option by "PUT /foreman_virt_who_configure/api/v2/configs/:id" :id: 37a08451-2add-4c5c-bab6-ebe002a746f1 :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ values = ['uuid', 'hostname'] for value in values: virtwho_config.hypervisor_id = value virtwho_config.update(['hypervisor_id']) config_file = get_configure_file(virtwho_config.id) command = get_configure_command(virtwho_config.id) deploy_configure_by_command(command, form_data['hypervisor_type']) assert get_configure_option('hypervisor_id', config_file) == value virtwho_config.delete() assert not entities.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"})
def test_positive_hypervisor_id_option(self, form_data, virtwho_config): """ Verify hypervisor_id option by hammer virt-who-config update" :id: d8428508-3149-4558-8173-4386db5e3760 :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ # esx and rhevm support hwuuid option values = ['uuid', 'hostname', 'hwuuid'] for value in values: VirtWhoConfig.update({'id': virtwho_config['id'], 'hypervisor-id': value}) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['hypervisor-id'] == value config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('hypervisor_id', config_file) == value VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_debug_option(self, form_data, virtwho_config): """Verify debug option by "PUT /foreman_virt_who_configure/api/v2/configs/:id" :id: be395108-3944-4a04-bee4-6bac3fa03a19 :expectedresults: debug option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ options = {'true': '1', 'false': '0', '1': '1', '0': '0'} for key, value in sorted(options.items(), key=lambda item: item[0]): virtwho_config.debug = key virtwho_config.update(['debug']) command = get_configure_command(virtwho_config.id) deploy_configure_by_command(command, form_data['hypervisor_type']) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == value virtwho_config.delete() assert not entities.VirtWhoConfig().search( query={'search': f"name={form_data['name']}"})
def test_positive_deploy_configure_by_id(self, default_org, form_data, virtwho_config): """Verify " hammer virt-who-config deploy" :id: 7cc0ad4f-e185-4d63-a2f5-1cb0245faa6c :expectedresults: Config can be created and deployed :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' command = get_configure_command(virtwho_config['id'], default_org.name) hypervisor_name, guest_name = deploy_configure_by_command( command, form_data['hypervisor-type'], debug=True, org=default_org.label ) virt_who_instance = VirtWhoConfig.info({'id': virtwho_config['id']})['general-information'][ 'status' ] assert virt_who_instance == 'OK' hosts = [ (hypervisor_name, f'product_id={settings.virtwho.sku.vdc_physical} and type=NORMAL'), (guest_name, f'product_id={settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED'), ] for hostname, sku in hosts: host = Host.list({'search': hostname})[0] subscriptions = Subscription.list({'organization': default_org.name, 'search': sku}) vdc_id = subscriptions[0]['id'] if 'type=STACK_DERIVED' in sku: for item in subscriptions: if hypervisor_name.lower() in item['type']: vdc_id = item['id'] break result = Host.subscription_attach({'host-id': host['id'], 'subscription-id': vdc_id}) assert result.strip() == 'Subscription attached to the host successfully.' VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_foreman_packages_protection(self, form_data, virtwho_config): """foreman-protector should allow virt-who to be installed :id: 635ef99b-c5a3-4ac4-a0f1-09f7036d116e :expectedresults: virt-who packages can be installed the virt-who plugin can be deployed successfully :CaseLevel: Integration :CaseImportance: Medium :BZ: 1783987 """ virtwho_package_locked() command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command, form_data['hypervisor-type']) virt_who_instance = VirtWhoConfig.info( {'id': virtwho_config['id']})['general-information']['status'] assert virt_who_instance == 'OK' VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_hypervisor_id_option(self, form_data, virtwho_config): """ Verify hypervisor_id option by hammer virt-who-config update" :id: eae7e767-8a71-424c-87da-475c91ac2ea1 :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ values = ['uuid', 'hostname'] if settings.virtwho.hypervisor_type in ('esx', 'rhevm'): values.append('hwuuid') for value in values: VirtWhoConfig.update({'id': virtwho_config['id'], 'hypervisor-id': value}) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['hypervisor-id'] == value config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command) assert get_configure_option('hypervisor_id', config_file) == value VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_foreman_packages_protection(self, form_data, virtwho_config): """foreman-protector should allow virt-who to be installed :id: 73dc895f-50b8-4de5-91de-ea55da935fe5 :expectedresults: virt-who packages can be installed the virt-who plugin can be deployed successfully :CaseLevel: Integration :CaseImportance: Medium :BZ: 1783987 """ virtwho_package_locked() command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command) virt_who_instance = VirtWhoConfig.info({'id': virtwho_config['id']})[ 'general-information' ]['status'] assert virt_who_instance == 'OK' VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_hypervisor_id_option(self, default_org, form_data, virtwho_config): """Verify hypervisor_id option by hammer virt-who-config update" :id: 8e234492-33cb-4523-abb3-582626ad704c :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ values = ['uuid', 'hostname'] for value in values: VirtWhoConfig.update({'id': virtwho_config['id'], 'hypervisor-id': value}) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['hypervisor-id'] == value config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id'], default_org.name) deploy_configure_by_command( command, form_data['hypervisor-type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_hypervisor_id_option(self, form_data, virtwho_config): """Verify hypervisor_id option by "PUT /foreman_virt_who_configure/api/v2/configs/:id" :id: f232547f-c4b2-41bc-ab8d-e7579a49ab69 :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ # esx and rhevm support hwuuid option values = ['uuid', 'hostname', 'hwuuid'] for value in values: virtwho_config.hypervisor_id = value virtwho_config.update(['hypervisor_id']) config_file = get_configure_file(virtwho_config.id) command = get_configure_command(virtwho_config.id) deploy_configure_by_command(command, form_data['hypervisor_type']) assert get_configure_option('hypervisor_id', config_file) == value virtwho_config.delete() assert not entities.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"})
def test_pre_create_virt_who_configuration(self, form_data): """Create and deploy virt-who configuration. :id: preupgrade-a36cbe89-47a2-422f-9881-0f86bea0e24e :steps: In Preupgrade Satellite, Create and deploy virt-who configuration. :expectedresults: 1. Config can be created and deployed by command. 2. No error msg in /var/log/rhsm/rhsm.log. 3. Report is sent to satellite. 4. Virtual sku can be generated and attached. """ default_loc_id = entities.Location().search( query={'search': f'name="{DEFAULT_LOC}"'})[0].id default_loc = entities.Location(id=default_loc_id).read() org = entities.Organization(name=ORG_DATA['name']).create() default_loc.organization.append(entities.Organization(id=org.id)) default_loc.update(['organization']) with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) form_data.update({'organization_id': org.id}) vhd = entities.VirtWhoConfig(**form_data).create() assert vhd.status == 'unknown' command = get_configure_command(vhd.id, org=org.name) hypervisor_name, guest_name = deploy_configure_by_command( command, form_data['hypervisor_type'], debug=True, org=org.label) virt_who_instance = (entities.VirtWhoConfig( organization_id=org.id).search( query={'search': f'name={form_data["name"]}'})[0].status) assert virt_who_instance == 'ok' hosts = [ (hypervisor_name, f'product_id={settings.virtwho.sku.vdc_physical} and type=NORMAL' ), (guest_name, f'product_id={settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' ), ] for hostname, sku in hosts: host = Host.list({'search': hostname})[0] subscriptions = Subscription.list({ 'organization-id': org.id, 'search': sku }) vdc_id = subscriptions[0]['id'] if 'type=STACK_DERIVED' in sku: for item in subscriptions: if hypervisor_name.lower() in item['type']: vdc_id = item['id'] break entities.HostSubscription(host=host['id']).add_subscriptions( data={'subscriptions': [{ 'id': vdc_id, 'quantity': 1 }]}) result = (entities.Host(organization=org.id).search( query={'search': hostname})[0].read_json()) assert result['subscription_status_label'] == 'Fully entitled' scenario_dict = { self.__class__.__name__: { 'hypervisor_name': hypervisor_name, 'guest_name': guest_name, } } create_dict(scenario_dict)
def test_positive_virtwho_configs_widget(self, session, form_data): """Check if Virt-who Configurations Status Widget is working in the Dashboard UI :id: 5d61ce00-a640-4823-89d4-7b1d02b50ea6 :Steps: 1. Create a Virt-who Configuration 2. Navigate Monitor -> Dashboard 3. Review the Virt-who Configurations Status widget :expectedresults: The widget is updated with all details. :CaseLevel: Integration :CaseImportance: Low """ org_name = gen_string('alpha') name = gen_string('alpha') form_data['name'] = name with session: session.organization.create({'name': org_name}) session.organization.select(org_name) session.virtwho_configure.create(form_data) expected_values = [ { 'Configuration Status': 'No Reports', 'Count': '1' }, { 'Configuration Status': 'No Change', 'Count': '0' }, { 'Configuration Status': 'OK', 'Count': '0' }, { 'Configuration Status': 'Total Configurations', 'Count': '1' }, ] values = session.dashboard.read('VirtWhoConfigStatus') assert values['config_status'] == expected_values assert values['latest_config'] == 'No configuration found' # Check the 'Status' changed after deployed the virt-who config config_id = get_configure_id(name) config_command = get_configure_command(config_id, org_name) deploy_configure_by_command(config_command, form_data['hypervisor_type']) assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' expected_values = [ { 'Configuration Status': 'No Reports', 'Count': '0' }, { 'Configuration Status': 'No Change', 'Count': '0' }, { 'Configuration Status': 'OK', 'Count': '1' }, { 'Configuration Status': 'Total Configurations', 'Count': '1' }, ] values = session.dashboard.read('VirtWhoConfigStatus') assert values['config_status'] == expected_values assert values['latest_config'] == 'No configuration found' session.virtwho_configure.delete(name) assert not session.virtwho_configure.search(name) session.organization.select("Default Organization") session.organization.delete(org_name)
def test_pre_create_virt_who_configuration(self): """Create and deploy virt-who configuration. :id: preupgrade-a36cbe89-47a2-422f-9881-0f86bea0e24e :steps: In Preupgrade Satellite, Create and deploy virt-who configuration. :expectedresults: 1. Config can be created and deployed by command. 2. No error msg in /var/log/rhsm/rhsm.log. 3. Report is sent to satellite. 4. Virtual sku can be generated and attached. """ default_loc_id = ( entities.Location().search(query={'search': 'name="{}"'.format(DEFAULT_LOC)})[0].id ) default_loc = entities.Location(id=default_loc_id).read() org = entities.Organization(name=self.org_name).create() default_loc.organization.append(entities.Organization(id=org.id)) default_loc.update(['organization']) with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) args = self._make_virtwho_configure() args.update({'name': self.name, 'organization_id': org.id}) vhd = entities.VirtWhoConfig(**args).create() self.assertEqual(vhd.status, 'unknown') command = get_configure_command(vhd.id, org=org.name) hypervisor_name, guest_name = deploy_configure_by_command( command, args['hypervisor_type'], debug=True, org=org.name ) self.assertEqual( entities.VirtWhoConfig(organization_id=org.id) .search(query={'search': 'name={}'.format(self.name)})[0] .status, 'ok', ) hosts = [ (hypervisor_name, 'product_id={} and type=NORMAL'.format(self.vdc_physical)), (guest_name, 'product_id={} and type=STACK_DERIVED'.format(self.vdc_physical)), ] for hostname, sku in hosts: if 'type=NORMAL' in sku: subscriptions = entities.Subscription(organization=org.id).search( query={'search': sku} ) vdc_id = subscriptions[0].id if 'type=STACK_DERIVED' in sku: subscriptions = entities.Subscription(organization=org.id).search( query={'search': sku} ) vdc_id = subscriptions[0].id host, time = wait_for( entities.Host(organization=org.id).search, func_args=(None, {'search': hostname}), fail_condition=[], timeout=5, delay=1, ) entities.HostSubscription(host=host[0].id).add_subscriptions( data={'subscriptions': [{'id': vdc_id, 'quantity': 1}]} ) result = ( entities.Host(organization=org.id) .search(query={'search': hostname})[0] .read_json() ) self.assertEqual(result['subscription_status_label'], 'Fully entitled') scenario_dict = { self.__class__.__name__: { 'hypervisor_name': hypervisor_name, 'guest_name': guest_name, } } create_dict(scenario_dict)