def test_all(self): """Test Pulp's handling of its ``PULP_MAX_TASKS_PER_CHILD`` setting.""" cfg = config.get_config() if not selectors.bug_is_fixed(2172, cfg.pulp_version): self.skipTest('https://pulp.plan.io/issues/2172') pulp_3540_testable = selectors.bug_is_fixed(3540, cfg.pulp_version) if os_is_f27(cfg) and not pulp_3540_testable: self.skipTest('https://pulp.plan.io/issues/3540') svc_mgr = cli.GlobalServiceManager(cfg) sudo = () if cli.is_root(cfg) else ('sudo', ) set_cmd = sudo + ( 'sed', '-i', '-e', 's/.*PULP_MAX_TASKS_PER_CHILD=[0-9]*$/PULP_MAX_TASKS_PER_CHILD=2/', '/etc/default/pulp_workers') unset_cmd = sudo + ( 'sed', '-i', '-e', 's/^PULP_MAX_TASKS_PER_CHILD=2$/# PULP_MAX_TASKS_PER_CHILD=2/', '/etc/default/pulp_workers') procs_over_time = [] # Step 1 procs_over_time.append(get_pulp_worker_procs(cfg)) for proc in procs_over_time[-1]: self.assertNotIn('--maxtasksperchild=2', proc, procs_over_time) # Step 2 client = cli.Client(cfg) client.run(set_cmd) self.addCleanup(svc_mgr.restart, PULP_SERVICES) if not pulp_3540_testable: self.addCleanup(time.sleep, 30) self.addCleanup(client.run, unset_cmd) svc_mgr.restart(PULP_SERVICES) procs_over_time.append(get_pulp_worker_procs(cfg)) for proc in procs_over_time[-1]: self.assertIn('--maxtasksperchild=2', proc, procs_over_time) # Step 3 repo_id = utils.uuid4() proc = client.run(('pulp-admin', 'rpm', 'repo', 'create', '--repo-id', repo_id, '--feed', RPM_UNSIGNED_FEED_URL)) self.addCleanup( client.run, ('pulp-admin', 'rpm', 'repo', 'delete', '--repo-id', repo_id)) self.assertNotIn('Task Failed', proc.stdout) proc = client.run( ('pulp-admin', 'rpm', 'repo', 'sync', 'run', '--repo-id', repo_id)) self.assertNotIn('Task Failed', proc.stdout) # Step 4 self.doCleanups() procs_over_time.append(get_pulp_worker_procs(cfg)) for proc in procs_over_time[-1]: self.assertNotIn('--maxtasksperchild=2', proc, procs_over_time)
def setUpModule(): # pylint:disable=invalid-name """Conditionally skip the tests in this module. Skip the tests in this module if: * The RPM plugin is not installed on the target Pulp server. * `Pulp #1759`_ is not implemented on the target Pulp server. * `Pulp #3313`_ is not fixed on the target Pulp server, and the target host is running Fedora 27. .. _Pulp #1759: https://pulp.plan.io/issues/1759 .. _Pulp #3313: https://pulp.plan.io/issues/3313 """ set_up_module() cfg = config.get_config() if not selectors.bug_is_fixed(1759, cfg.pulp_version): raise unittest.SkipTest('https://pulp.plan.io/issues/1759') if not selectors.bug_is_fixed(3313, cfg.pulp_version) and os_is_f27(cfg): raise unittest.SkipTest('https://pulp.plan.io/issues/3313') if cfg.pulp_selinux_enabled: set_pulp_manage_rsync(cfg, True)
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)