def test_produce_add_nonextant_file(setup_bundle_test): margs, out_path = setup_bundle_test os.remove(os.path.join(margs.log_dir, 'server.log')) bundle = DebugBundle(margs) with pytest.raises(TarAdditionNonExtant) as ex: bundle.produce_bundle() assert 'File to add to tarfile does not exist:' in ex.value.message assert 'server.log' in ex.value.message
def test_produce_bundle(setup_bundle_test): margs, out_path = setup_bundle_test bundle = DebugBundle(margs) bundle.produce_bundle() tar_file = os.path.join(out_path, 'debug_bundle.tar.gz') assert os.path.exists(tar_file) is True assert tarfile.is_tarfile(tar_file) is True with tarfile.open(tar_file, 'r:gz') as tar: assert sorted(tar.getnames()) == sorted(TAR_FILE_LIST)
def test_produce_bundle_no_logs(setup_bundle_test): margs, out_path = setup_bundle_test margs.no_log_files = True bundle = DebugBundle(margs) bundle.produce_bundle() tar_file = os.path.join(out_path, 'debug_bundle.tar.gz') assert os.path.exists(tar_file) is True assert tarfile.is_tarfile(tar_file) is True with tarfile.open(tar_file, 'r:gz') as tar: assert sorted(tar.getnames()) == \ sorted( [ 'f5-openstack-agent.ini', 'pip_list.txt', 'neutron.conf', 'neutron_lbaas.conf' ] )
def test_produce_bundle_no_cfgs(setup_bundle_test): margs, out_path = setup_bundle_test margs.no_config_files = True bundle = DebugBundle(margs) bundle.produce_bundle() tar_file = os.path.join(out_path, 'debug_bundle.tar.gz') assert os.path.exists(tar_file) is True assert tarfile.is_tarfile(tar_file) is True with tarfile.open(tar_file, 'r:gz') as tar: assert sorted(tar.getnames()) == \ sorted( [ 'f5-openstack-agent.log', 'f5-openstack-agent.log.1.gz', 'pip_list.txt', 'server.log', 'server.log.1.gz', 'server.log.5.gz' ] )