def test_all(self): """Add a content unit to a repo in the middle of several publishes.""" cfg = config.get_config() if not selectors.bug_is_fixed(2532, cfg.pulp_version): self.skipTest('https://pulp.plan.io/issues/2532') rpms = (utils.http_get(RPM_UNSIGNED_URL), utils.http_get(RPM2_UNSIGNED_URL)) # Create a user and a repository. ssh_user, priv_key = self.make_user(cfg) ssh_identity_file = self.write_private_key(cfg, priv_key) repo = self.make_repo( cfg, { 'remote': { 'host': urlparse(cfg.get_base_url()).hostname, 'root': '/home/' + ssh_user, 'ssh_identity_file': ssh_identity_file, 'ssh_user': ssh_user, } }) # Add content, publish w/yum, add more content, publish w/rsync. dists = get_dists_by_type_id(cfg, repo) for i, key in enumerate(('yum_distributor', 'rpm_rsync_distributor')): upload_import_unit(cfg, rpms[i], {'unit_type_id': 'rpm'}, repo) publish_repo(cfg, repo, {'id': dists[key]['id']}) self.verify_remote_units_path(cfg, dists['rpm_rsync_distributor'], 1) # Publish with yum and rsync, respectively. for key in 'yum_distributor', 'rpm_rsync_distributor': publish_repo(cfg, repo, {'id': dists[key]['id']}) self.verify_remote_units_path(cfg, dists['rpm_rsync_distributor'], 1)
def test_all(self): """Publish the rpm rsync distributor before the yum distributor.""" cfg = config.get_config() if not selectors.bug_is_fixed(2187, cfg.pulp_version): self.skipTest('https://pulp.plan.io/issues/2187') # Create a user and a repository. ssh_user, priv_key = self.make_user(cfg) ssh_identity_file = self.write_private_key(cfg, priv_key) repo = self.make_repo( cfg, { 'remote': { 'host': urlparse(cfg.get_base_url()).hostname, 'root': '/home/' + ssh_user, 'ssh_identity_file': ssh_identity_file, 'ssh_user': ssh_user, } }) # Publish with the rsync distributor. distribs = get_dists_by_type_id(cfg, repo) args = (cfg, repo, {'id': distribs['rpm_rsync_distributor']['id']}) self.verify_publish_is_skip(cfg, publish_repo(*args).json()) # Verify that the rsync distributor hasn't placed files. dirs = self.remote_root_files(cfg, distribs['rpm_rsync_distributor']) self.assertNotIn('content', dirs) # Publish with the rsync distributor again, and verify again. if selectors.bug_is_fixed(2722, cfg.pulp_version): self.verify_publish_is_skip(cfg, publish_repo(*args).json()) dirs = self.remote_root_files(cfg, distribs['rpm_rsync_distributor']) self.assertNotIn('content', dirs)
def test_broken_symlinks(self): """Assert that the rsync yum metadata is not a symlink.""" # Create a user and repo with an importer and distribs. Sync the repo. ssh_user, priv_key = self.make_user(self.cfg) ssh_identity_file = self.write_private_key(self.cfg, priv_key) repo = self.make_repo( self.cfg, { 'remote': { 'host': urlparse(self.cfg.get_base_url()).hostname, 'root': '/home/' + ssh_user, 'ssh_identity_file': ssh_identity_file, 'ssh_user': ssh_user, } }, RPM_YUM_METADATA_FILE) sync_repo(self.cfg, repo) # Publish the repo with the yum and rsync distributors, respectively. # Verify that the RPM rsync distributor has placed files. distribs = get_dists_by_type_id(self.cfg, repo) self.maybe_disable_selinux(self.cfg, 2199) for type_id in ('yum_distributor', 'rpm_rsync_distributor'): publish_repo(self.cfg, repo, {'id': distribs[type_id]['id']}) path = os.path.join( distribs['rpm_rsync_distributor']['config']['remote']['root'], distribs['yum_distributor']['config']['relative_url'], 'repodata') # Assert that the productid was not saved as symlink productid_symlink = self.find_productid(True, path) self.assertEqual(len(productid_symlink), 0, productid_symlink) # Assert that the productid was saved as a file productid_file = self.find_productid(False, path) self.assertEqual(len(productid_file), 1, productid_file)
def test_all(self): """Exercise the ``remote_units_path`` option.""" cfg = config.get_config() # We already know Pulp can deal with 2-segment paths, due to the # default remote_units_path of 'content/units'. paths = ( os.path.join(*[utils.uuid4() for _ in range(3)]), os.path.join(*[utils.uuid4() for _ in range(1)]), ) # Create a user and repo with an importer and distribs. Sync the repo. ssh_user, priv_key = self.make_user(cfg) ssh_identity_file = self.write_private_key(cfg, priv_key) repo = self.make_repo( cfg, { 'remote': { 'host': urlparse(cfg.get_base_url()).hostname, 'root': '/home/' + ssh_user, 'ssh_identity_file': ssh_identity_file, 'ssh_user': ssh_user, }, 'remote_units_path': paths[0], }) distribs = get_dists_by_type_id(cfg, repo) sync_repo(cfg, repo) # Publish the repo with the yum and rpm rsync distributors, # respectively. Verify that files have been correctly placed. distribs = get_dists_by_type_id(cfg, repo) self.maybe_disable_selinux(cfg, 2199) for type_id in ('yum_distributor', 'rpm_rsync_distributor'): publish_repo( cfg, repo, { 'id': distribs[type_id]['id'], 'config': { 'remote_units_path': paths[1] }, }) distribs['rpm_rsync_distributor']['remote_units_path'] = paths[1] self.verify_remote_units_path(cfg, distribs['rpm_rsync_distributor'])
def test_all(self): """Use the ``force_full`` RPM rsync distributor option.""" cfg = config.get_config() cli_client = cli.Client(cfg) sudo = '' if cli.is_root(cfg) else 'sudo ' # Create a user and repo with an importer and distribs. Sync the repo. ssh_user, priv_key = self.make_user(cfg) ssh_identity_file = self.write_private_key(cfg, priv_key) repo = self.make_repo( cfg, { 'remote': { 'host': urlparse(cfg.get_base_url()).hostname, 'root': '/home/' + ssh_user, 'ssh_identity_file': ssh_identity_file, 'ssh_user': ssh_user, } }) sync_repo(cfg, repo) # Publish the repo with the yum and rsync distributors, respectively. # Verify that the RPM rsync distributor has placed files. distribs = get_dists_by_type_id(cfg, repo) self.maybe_disable_selinux(cfg, 2199) for type_id in ('yum_distributor', 'rpm_rsync_distributor'): publish_repo(cfg, repo, {'id': distribs[type_id]['id']}) self.verify_remote_units_path(cfg, distribs['rpm_rsync_distributor']) # Remove all files from the target directory, and publish again. Verify # that the RPM rsync distributor didn't place any files. cmd = sudo + 'rm -rf /home/{}/content'.format(ssh_user) cli_client.run(cmd.split()) self.verify_publish_is_skip( cfg, publish_repo(cfg, repo, { 'id': distribs['rpm_rsync_distributor']['id'] }).json()) dirs = self.remote_root_files(cfg, distribs['rpm_rsync_distributor']) self.assertNotIn('content', dirs) # Publish the repo with ``force_full`` set to true. Verify that the RPM # rsync distributor placed files. if not selectors.bug_is_fixed(2202, cfg.pulp_version): return publish_repo( cfg, repo, { 'id': distribs['rpm_rsync_distributor']['id'], 'override_config': { 'force_full': True }, }) self.verify_remote_units_path(cfg, distribs['rpm_rsync_distributor'])
def test_all(self): """Publish with a yum and rsync distributor twice.""" cfg = config.get_config() if not selectors.bug_is_fixed(2666, cfg.pulp_version): self.skipTest('https://pulp.plan.io/issues/2666') if check_issue_2844(cfg): self.skipTest('https://pulp.plan.io/issues/2844') # Create a user and a repository. ssh_user, priv_key = self.make_user(cfg) ssh_identity_file = self.write_private_key(cfg, priv_key) repo = self.make_repo( cfg, { 'remote': { 'host': urlparse(cfg.get_base_url()).hostname, 'root': '/home/' + ssh_user, 'ssh_identity_file': ssh_identity_file, 'ssh_user': ssh_user, } }) # Add content. for url in (RPM_UNSIGNED_URL, RPM2_UNSIGNED_URL): upload_import_unit(cfg, utils.http_get(url), {'unit_type_id': 'rpm'}, repo) dists = get_dists_by_type_id(cfg, repo) # See https://pulp.plan.io/issues/2844#note-11 time.sleep(2) # Publish with yum and rsync. for dist in 'yum_distributor', 'rpm_rsync_distributor': report = (publish_repo(cfg, repo, { 'id': dists[dist]['id'] }).json()) publish_task = self.get_publish_task(cfg, report) num_processed = self.get_num_processed(publish_task) with self.subTest(comment='first rsync publish'): self.assertEqual(num_processed, 2, publish_task) # Publish with yum and rsync again. for dist in 'yum_distributor', 'rpm_rsync_distributor': report = (publish_repo(cfg, repo, { 'id': dists[dist]['id'] }).json()) publish_task = self.get_publish_task(cfg, report) num_processed = self.get_num_processed(publish_task) with self.subTest(comment='second rsync publish'): self.assertEqual(num_processed, 0, publish_task)
def test_all(self): """Use the ``rsync_extra_args`` RPM rsync distributor option.""" cfg = config.get_config() if not selectors.bug_is_fixed(3317, cfg.pulp_version): self.skipTest('https://pulp.plan.io/issues/3317') # Create a user and repo with an importer and distribs. Sync the repo. ssh_user, priv_key = self.make_user(cfg) ssh_identity_file = self.write_private_key(cfg, priv_key) repo = self.make_repo( cfg, { 'remote': { 'host': urlparse(cfg.get_base_url()).hostname, 'root': '/home/' + ssh_user, 'ssh_identity_file': ssh_identity_file, 'ssh_user': ssh_user, } }) sync_repo(cfg, repo) # Publish the repo with the yum and rsync distributors, respectively. distribs = get_dists_by_type_id(cfg, repo) self.maybe_disable_selinux(cfg, 2199) publish_repo(cfg, repo, {'id': distribs['yum_distributor']['id']}) publish_repo( cfg, repo, { 'id': distribs['rpm_rsync_distributor']['id'], 'override_config': { 'rsync_extra_args': ['--dry-run'] }, }) # Verify that the rsync distributor hasn't placed any files. files = self.remote_root_files(cfg, distribs['rpm_rsync_distributor']) self.assertSetEqual(files, set()) # Publish the repo again with the rsync distributor (force full) publish_repo( cfg, repo, { 'id': distribs['rpm_rsync_distributor']['id'], 'override_config': { 'force_full': True }, }) self.verify_remote_units_path(cfg, distribs['rpm_rsync_distributor'])
def test_all(self): """Use the ``delete`` RPM rsync distributor option.""" cfg = config.get_config() if not selectors.bug_is_fixed(2221, cfg.pulp_version): self.skipTest('https://pulp.plan.io/issues/2221') api_client = api.Client(cfg) # Create a user and repo with an importer and distribs. Sync the repo. ssh_user, priv_key = self.make_user(cfg) ssh_identity_file = self.write_private_key(cfg, priv_key) repo = self.make_repo( cfg, { 'remote': { 'host': urlparse(cfg.get_base_url()).hostname, 'root': '/home/' + ssh_user, 'ssh_identity_file': ssh_identity_file, 'ssh_user': ssh_user, } }) sync_repo(cfg, repo) # Publish the repo with the yum and rsync distributors, respectively. # Verify that the RPM rsync distributor has placed files. distribs = get_dists_by_type_id(cfg, repo) self.maybe_disable_selinux(cfg, 2199) for type_id in ('yum_distributor', 'rpm_rsync_distributor'): publish_repo(cfg, repo, {'id': distribs[type_id]['id']}) self.verify_remote_units_path(cfg, distribs['rpm_rsync_distributor']) # Disassociate all units from the repo, publish the repo, and verify. api_client.post(urljoin(repo['_href'], 'actions/unassociate/'), {'criteria': {}}) publish_repo(cfg, repo, {'id': distribs['yum_distributor']['id']}) self._verify_units_not_in_repo(cfg, repo['_href']) # Publish with the RPM rsync distributor, and verify that no RPMs are # in the target directory. api_client.post( urljoin(repo['_href'], 'actions/publish/'), { 'id': distribs['rpm_rsync_distributor']['id'], 'override_config': { 'delete': True }, }) self._verify_files_not_in_dir(cfg, **distribs)
def test_all(self): """Publish w/an rsync distributor when ``serve_https`` is false.""" if not selectors.bug_is_fixed(2657, self.cfg.pulp_version): self.skipTest('https://pulp.plan.io/issues/2657') if (not selectors.bug_is_fixed(3313, self.cfg.pulp_version) and os_is_f27(self.cfg)): self.skipTest('https://pulp.plan.io/issues/3313') # Create a user with which to rsync files ssh_user, priv_key = self.make_user(self.cfg) ssh_identity_file = self.write_private_key(self.cfg, priv_key) # Create a repo client = api.Client(self.cfg, api.json_handler) body = { 'distributors': [], 'id': utils.uuid4(), 'importer_config': {'feed': FILE_FEED_URL}, 'importer_type_id': 'iso_importer', } body['distributors'].append({ 'auto_publish': False, 'distributor_config': {'serve_http': True, 'serve_https': False}, 'distributor_id': utils.uuid4(), 'distributor_type_id': 'iso_distributor', }) body['distributors'].append({ 'auto_publish': False, 'distributor_config': { 'predistributor_id': body['distributors'][0]['distributor_id'], 'remote': { 'host': urlparse(self.cfg.get_base_url()).hostname, 'root': '/home/' + ssh_user, 'ssh_identity_file': ssh_identity_file, 'ssh_user': ssh_user, }, }, 'distributor_id': utils.uuid4(), 'distributor_type_id': 'iso_rsync_distributor', }) repo = client.post(REPOSITORY_PATH, body) self.addCleanup(client.delete, repo['_href']) repo = client.get(repo['_href'], params={'details': True}) # Sync and publish the repo. If Pulp #2657 hasn't been fixed, # publishing the iso_rsync_distributor will fail with an error like: # # pulp.plugins.rsync.publish:ERROR: (1181-98080) rsync: link_stat # "/var/lib/pulp/published/https/isos/repo-id/PULP_MANIFEST" # failed: No such file or directory (2) # sync_repo(self.cfg, repo) dists = get_dists_by_type_id(self.cfg, repo) publish_repo(self.cfg, repo, { 'id': dists['iso_distributor']['id'], }) publish_repo(self.cfg, repo, { 'id': dists['iso_rsync_distributor']['id'], }) # Verify the correct units are on the remote system. cli_client = cli.Client(self.cfg) path = dists['iso_rsync_distributor']['config']['remote']['root'] path = os.path.join(path, 'content/units') cmd = ('find', path, '-name', '*.iso') files = cli_client.run(cmd, sudo=True).stdout.strip().split('\n') self.assertEqual(len(files), FILE_FEED_COUNT, files)