def test_map_rm_conf_to_components_sym_names(): ''' Verify that all symbolic names in uploader.json result as components in the output ''' # commands for cmd in uploader_json['commands']: # run each possible command through the function sym_name = cmd['symbolic_name'] rm_conf = {'commands': [sym_name]} # figure out the destination name should be spec_name = _get_component_by_symbolic_name(sym_name) new_rm_conf = map_rm_conf_to_components(rm_conf, uploader_json) # commands should be empty, components should have 1 item assert len(new_rm_conf['commands']) == 0 assert len(new_rm_conf['components']) == 1 assert new_rm_conf['components'][0] == spec_name # files for fil in uploader_json['files']: # run each possible file through the function sym_name = fil['symbolic_name'] rm_conf = {'files': [sym_name]} # figure out the destination name should be spec_name = _get_component_by_symbolic_name(sym_name) new_rm_conf = map_rm_conf_to_components(rm_conf, uploader_json) # files should be empty, components should have 1 item # except for these which cannot be mapped to specs. # in which case, components empty and these remain in files if sym_name in [ 'grub2_efi_grubenv', 'grub2_grubenv', 'redhat_access_proactive_log' ]: assert len(new_rm_conf['files']) == 1 assert new_rm_conf['files'][0] == sym_name assert len(new_rm_conf['components']) == 0 else: assert len(new_rm_conf['files']) == 0 assert len(new_rm_conf['components']) == 1 assert new_rm_conf['components'][0] == spec_name # globs for glb in uploader_json['globs']: # run each possible glob through the function sym_name = glb['symbolic_name'] rm_conf = {'files': [sym_name]} # figure out the destination name should be spec_name = _get_component_by_symbolic_name(sym_name) new_rm_conf = map_rm_conf_to_components(rm_conf, uploader_json) # files should be empty, components should have 1 item assert len(new_rm_conf['files']) == 0 assert len(new_rm_conf['components']) == 1 assert new_rm_conf['components'][0] == spec_name
def test_get_component_by_symbolic_name(): ''' Verify that all symbolic names in uploader.json can be mapped to valid components as prescribed in the conversion function ''' # some specs have been removed for core release so because they either # A) do not appear in uploader.json, or # B) DO appear in uploader.json, but have no associated rules # Filter out the (B) specs with this list skipped_specs = [ 'ceph_osd_df', 'gluster_peer_status', 'gluster_v_status', 'heat_crontab', 'httpd_on_nfs', 'ls_usr_sbin', 'lvmconfig', 'nova_migration_uid', 'ntpq_pn', 'rabbitmq_queues', 'rhev_data_center', 'root_crontab', 'yum_list_installed', 'zdump_v', 'cni_podman_bridge_conf', 'cobbler_modules_conf', 'cobbler_settings', 'cpu_smt_control', 'cpu_vulns_meltdown', 'cpu_vulns_spectre_v1', 'cpu_vulns_spectre_v2', 'cpu_vulns_spec_store_bypass', 'docker_storage', 'freeipa_healthcheck_log', 'vmware_tools_conf', 'ironic_conf', 'octavia_conf', 'partitions', 'rhn_entitlement_cert_xml', 'rhn_hibernate_conf', 'rhn_schema_version', 'rhn_search_daemon_log', 'rhn_taskomatic_daemon_log', 'rhosp_release', 'secure', 'foreman_tasks_config', 'ssh_foreman_config', 'swift_conf', 'sys_kernel_sched_features', 'sysconfig_memcached', 'sysconfig_mongod', 'systemd_system_origin_accounting', 'tuned_conf', 'vdsm_conf', 'vdsm_id', 'neutron_ml2_conf', 'sap_host_profile', 'sched_rt_runtime_us', 'libvirtd_qemu_log', 'mlx4_port', 'qpid_stat_g', 'lsinitrd' ] # first, make sure our list is proper and one of these # are in the default specs for s in skipped_specs: assert s not in default_specs for category in ['commands', 'files', 'globs']: for entry in uploader_json[category]: full_component = _get_component_by_symbolic_name( entry['symbolic_name']) if full_component is None: # this entry should not be in core, so assert that it's missing assert entry['symbolic_name'] not in default_specs continue module, shortname = full_component.rsplit('.', 1) # filter out specs without associated rules if shortname in skipped_specs: continue if module == "insights.specs.default.DefaultSpecs": assert shortname in default_specs elif module == "insights.specs.sos_archive.SosSpecs": assert shortname in sos_specs else: # invalid module name assert False
def test_map_rm_conf_to_components_raw_cmds_files(): ''' Verify that all raw files/commands in uploader.json result as components in the output ''' # commands for cmd in uploader_json['commands']: # run each possible command through the function rm_conf = {'commands': [cmd['command']]} sym_name = cmd['symbolic_name'] # figure out the destination name should be spec_name = _get_component_by_symbolic_name(sym_name) new_rm_conf = map_rm_conf_to_components(rm_conf, uploader_json) # commands should be empty, components should have 1 item assert len(new_rm_conf['commands']) == 0 assert len(new_rm_conf['components']) == 1 assert new_rm_conf['components'][0] == spec_name # files for fil in uploader_json['files']: # run each possible file through the function rm_conf = {'files': [fil['file']]} sym_name = fil['symbolic_name'] # figure out the destination name should be spec_name = _get_component_by_symbolic_name(sym_name) new_rm_conf = map_rm_conf_to_components(rm_conf, uploader_json) # files should be empty, components should have 1 item # except for these which cannot be mapped to specs. # in which case, components empty and these remain in files if fil['file'] in [ '/boot/efi/EFI/redhat/grubenv', '/boot/grub2/grubenv', '/var/log/redhat_access_proactive/redhat_access_proactive.log' ]: assert len(new_rm_conf['files']) == 1 assert new_rm_conf['files'][0] == fil['file'] assert len(new_rm_conf['components']) == 0 else: assert len(new_rm_conf['files']) == 0 assert len(new_rm_conf['components']) == 1 assert new_rm_conf['components'][0] == spec_name