def setUpClass(cls): """Create and sync two puppet repositories.""" super(SyncValidFeedTestCase, cls).setUpClass() utils.reset_pulp(cls.cfg) # See: https://pulp.plan.io/issues/1406 bodies = tuple((_gen_repo() for _ in range(2))) for i, query in enumerate(( _PUPPET_QUERY, _PUPPET_QUERY.replace('-', '_'))): bodies[i]['importer_config'] = { 'feed': _PUPPET_FEED, 'queries': [query], } client = api.Client(cls.cfg, api.json_handler) repos = [client.post(REPOSITORY_PATH, body) for body in bodies] cls.resources.update({repo['_href'] for repo in repos}) # Trigger repository sync and collect completed tasks. cls.reports = [] # raw responses to "start syncing" commands cls.tasks = [] # completed tasks client.response_handler = api.echo_handler for repo in repos: report = client.post(urljoin(repo['_href'], 'actions/sync/')) report.raise_for_status() cls.reports.append(report) for task in utils.poll_spawned_tasks(cls.cfg, report.json()): cls.tasks.append(task)
def _create_sync_repo(server_config, body): # Create repository. client = api.Client(server_config, api.json_handler) repo = client.post(REPOSITORY_PATH, body) # Sync repository and collect task statuses. client.response_handler = api.echo_handler response = client.post(urljoin(repo["_href"], "actions/sync/"), {"override_config": {}}) response.raise_for_status() tasks = tuple(utils.poll_spawned_tasks(server_config, response.json())) return repo["_href"], response, tasks
def setUpClass(cls): """Create an RPM repository with an invalid feed and sync it.""" super(SyncInvalidFeedTestCase, cls).setUpClass() client = api.Client(cls.cfg, api.json_handler) body = _gen_repo() body['importer_config']['feed'] = utils.uuid4() repo = client.post(REPOSITORY_PATH, body) client.response_handler = api.echo_handler path = urljoin(repo['_href'], 'actions/sync/') cls.report = client.post(path, {'override_config': {}}) cls.report.raise_for_status() cls.tasks = tuple(utils.poll_spawned_tasks(cls.cfg, cls.report.json())) cls.resources.add(repo['_href'])
def setUpClass(cls): """Create a puppet repository with an invalid feed and sync it.""" super(SyncInvalidFeedTestCase, cls).setUpClass() client = api.Client(cls.cfg, api.json_handler) body = _gen_repo() body['importer_config'] = {'feed': 'http://' + utils.uuid4()} repo = client.post(REPOSITORY_PATH, body) cls.resources.add(repo['_href']) # Trigger a repository sync and collect completed tasks. client.response_handler = api.echo_handler cls.report = client.post(urljoin(repo['_href'], 'actions/sync/')) cls.report.raise_for_status() cls.tasks = list(utils.poll_spawned_tasks(cls.cfg, cls.report.json()))
def _create_sync_repo(server_config, body): # Create repository. client = api.Client(server_config, api.json_handler) repo = client.post(REPOSITORY_PATH, body) # Sync repository and collect task statuses. client.response_handler = api.echo_handler response = client.post( urljoin(repo['_href'], 'actions/sync/'), {'override_config': {}}, ) response.raise_for_status() tasks = tuple(utils.poll_spawned_tasks(server_config, response.json())) return repo['_href'], response, tasks
def _handle_202(server_config, response): """Check for an HTTP 202 response and handle it appropriately.""" if response.status_code == 202: # "Accepted" _check_http_202_content_type(response) tuple(utils.poll_spawned_tasks(server_config, response.json()))