def test_all(self): """Add a content unit to a repo in the middle of several publishes.""" cfg = config.get_config() if selectors.bug_is_untestable(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')): utils.upload_import_unit(cfg, rpms[i], {'unit_type_id': 'rpm'}, repo) utils.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': utils.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 selectors.bug_is_untestable(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, utils.publish_repo(*args).json()) # Verify that the rsync distributor hasn't placed files. sudo = '' if utils.is_root(cfg) else 'sudo ' cmd = (sudo + 'ls -1 /home/{}'.format(ssh_user)).split() dirs = set(cli.Client(cfg).run(cmd).stdout.strip().split('\n')) self.assertNotIn('content', dirs) # Publish with the rsync distributor again, and verify again. if selectors.bug_is_testable(2722, cfg.pulp_version): self.verify_publish_is_skip(cfg, utils.publish_repo(*args).json()) dirs = set(cli.Client(cfg).run(cmd).stdout.strip().split('\n')) self.assertNotIn('content', dirs)
def test_all(self): """Use the ``force_full`` RPM rsync distributor option.""" cfg = config.get_config() cli_client = cli.Client(cfg) sudo = '' if utils.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, } }) utils.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'): utils.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, utils.publish_repo(cfg, repo, { 'id': distribs['rpm_rsync_distributor']['id'] }).json()) cmd = sudo + 'ls -1 /home/{}'.format(ssh_user) dirs = set(cli_client.run(cmd.split()).stdout.strip().split('\n')) self.assertNotIn('content', dirs) # Publish the repo with ``force_full`` set to true. Verify that the RPM # rsync distributor placed files. if selectors.bug_is_untestable(2202, cfg.pulp_version): return utils.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): """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) utils.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'): utils.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): """Publish with a yum and rsync distributor twice.""" cfg = config.get_config() if selectors.bug_is_untestable(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): utils.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 = (utils.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 = (utils.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 ``delete`` RPM rsync distributor option.""" cfg = config.get_config() if selectors.bug_is_untestable(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, } }) utils.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'): utils.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': {}}) utils.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 selectors.bug_is_untestable(2657, self.cfg.pulp_version): self.skipTest('https://pulp.plan.io/issues/2657') if (selectors.bug_is_untestable(3313, self.cfg.pulp_version) and utils.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) # utils.sync_repo(self.cfg, repo) dists = get_dists_by_type_id(self.cfg, repo) utils.publish_repo(self.cfg, repo, { 'id': dists['iso_distributor']['id'], }) utils.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) sudo = () if utils.is_root(self.cfg) else ('sudo',) path = dists['iso_rsync_distributor']['config']['remote']['root'] path = os.path.join(path, 'content/units') cmd = sudo + ('find', path, '-name', '*.iso') files = cli_client.run(cmd).stdout.strip().split('\n') self.assertEqual(len(files), FILE_FEED_COUNT, files)