def test_all(self):
        """Create, sync and publish an OSTree repository.

        Verify that:

        * The distributor's ``last_publish`` attribute is ``None`` after the
          sync. This demonstrates that ``auto_publish`` correctly defaults to
          ``False``.
        * The distributor's ``last_publish`` attribute is not ``None`` after
          the publish.
        """
        cfg = config.get_config()
        client = api.Client(cfg, api.json_handler)

        # Create a repository.
        body = gen_repo()
        body['importer_config']['feed'] = OSTREE_FEED
        body['importer_config']['branches'] = [OSTREE_BRANCH]
        body['distributors'].append(gen_distributor())
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])

        # Sync the repository.
        utils.sync_repo(cfg, repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})
        with self.subTest(comment='verify last_publish after sync'):
            self.assertIsNone(repo['distributors'][0]['last_publish'])

        # Publish the repository.
        client.post(urljoin(repo['_href'], 'actions/publish/'), {
            'id': repo['distributors'][0]['id'],
        })
        repo = client.get(repo['_href'], params={'details': True})
        with self.subTest(comment='verify last_publish after publish'):
            self.assertIsNotNone(repo['distributors'][0]['last_publish'])
Beispiel #2
0
    def test_all(self):
        """Create, sync and publish an OSTree repository.

        Verify that:

        * The distributor's ``last_publish`` attribute is ``None`` after the
          sync. This demonstrates that ``auto_publish`` correctly defaults to
          ``False``.
        * The distributor's ``last_publish`` attribute is not ``None`` after
          the publish.
        """
        cfg = config.get_config()
        client = api.Client(cfg, api.json_handler)

        # Create a repository.
        body = gen_repo()
        body['importer_config']['feed'] = OSTREE_FEED
        body['importer_config']['branches'] = [OSTREE_BRANCH]
        body['distributors'].append(gen_distributor())
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])

        # Sync the repository.
        utils.sync_repo(cfg, repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})
        with self.subTest(comment='verify last_publish after sync'):
            self.assertIsNone(repo['distributors'][0]['last_publish'])

        # Publish the repository.
        utils.publish_repo(cfg, repo)
        repo = client.get(repo['_href'], params={'details': True})
        with self.subTest(comment='verify last_publish after publish'):
            self.assertIsNotNone(repo['distributors'][0]['last_publish'])
    def setUpClass(cls):
        """Create distributors with legal and illegal relative paths."""
        super(CreateDistributorsTestCase, cls).setUpClass()
        cls.responses = []

        relative_paths = [_gen_rel_path(), _gen_rel_path(), _gen_rel_path(3)]
        relative_paths.append(relative_paths[0])
        relative_paths.append(relative_paths[0] + '/' + utils.uuid4())
        relative_paths.append('/' + relative_paths[0])

        # Create two repositories
        client = api.Client(cls.cfg, api.json_handler)
        repos = [client.post(REPOSITORY_PATH, gen_repo()) for _ in range(2)]
        for repo in repos:
            cls.resources.add(repo['_href'])  # mark for deletion

        # Create a distributor for the first repository
        client.response_handler = api.echo_handler
        path = urljoin(repos[0]['_href'], 'distributors/')
        body = _gen_distributor(relative_paths[0])
        cls.responses.append(client.post(path, body))

        # Create distributors for the second repository
        path = urljoin(repos[1]['_href'], 'distributors/')
        for relative_path in relative_paths[1:]:
            body = _gen_distributor(relative_path)
            cls.responses.append(client.post(path, body))
Beispiel #4
0
    def setUpClass(cls):
        """Create distributors with legal and illegal relative paths."""
        super(CreateDistributorsTestCase, cls).setUpClass()
        cls.responses = []

        relative_paths = [_gen_rel_path(), _gen_rel_path(), _gen_rel_path(3)]
        relative_paths.append(relative_paths[0])
        relative_paths.append(relative_paths[0] + '/' + utils.uuid4())
        relative_paths.append('/' + relative_paths[0])

        # Create two repositories
        client = api.Client(cls.cfg, api.json_handler)
        repos = [client.post(REPOSITORY_PATH, gen_repo()) for _ in range(2)]
        for repo in repos:
            cls.resources.add(repo['_href'])  # mark for deletion

        # Create a distributor for the first repository
        client.response_handler = api.echo_handler
        path = urljoin(repos[0]['_href'], 'distributors/')
        body = _gen_distributor(relative_paths[0])
        cls.responses.append(client.post(path, body))

        # Create distributors for the second repository
        path = urljoin(repos[1]['_href'], 'distributors/')
        for relative_path in relative_paths[1:]:
            body = _gen_distributor(relative_path)
            cls.responses.append(client.post(path, body))
 def setUpClass(cls):
     """Create and sync an OSTree repository."""
     super(SyncMissingAttrsTestCase, cls).setUpClass()
     client = api.Client(cls.cfg)
     body = gen_repo()
     repo_href = client.post(REPOSITORY_PATH, body).json()['_href']
     cls.resources.add(repo_href)
     cls.report, cls.tasks = _sync_repo(cls.cfg, repo_href)
 def setUpClass(cls):
     """Create and sync an OSTree repository."""
     super(SyncMissingAttrsTestCase, cls).setUpClass()
     client = api.Client(cls.cfg)
     body = gen_repo()
     repo_href = client.post(REPOSITORY_PATH, body).json()['_href']
     cls.resources.add(repo_href)
     cls.report, cls.tasks = _sync_repo(cls.cfg, repo_href)
 def setUpClass(cls):
     """Create an OSTree repository with a valid feed and branch."""
     super(SyncTestCase, cls).setUpClass()
     body = gen_repo()
     body['importer_config']['feed'] = _FEED
     body['importer_config']['branches'] = [_BRANCHES[0]]
     repo_href, cls.report = create_sync_repo(cls.cfg, body)
     cls.resources.add(repo_href)
     cls.tasks = tuple(api.poll_spawned_tasks(cls.cfg, cls.report.json()))
 def setUpClass(cls):
     """Set ``cls.body``."""
     super(SyncInvalidFeedTestCase, cls).setUpClass()
     client = api.Client(cls.cfg)
     body = gen_repo()
     body['importer_config']['feed'] = utils.uuid4()
     body['importer_config']['branches'] = [OSTREE_BRANCH]
     repo_href = client.post(REPOSITORY_PATH, body).json()['_href']
     cls.resources.add(repo_href)
     cls.report, cls.tasks = _sync_repo(cls.cfg, repo_href)
 def setUpClass(cls):
     """Create and sync an OSTree repository."""
     super(SyncInvalidBranchesTestCase, cls).setUpClass()
     client = api.Client(cls.cfg)
     body = gen_repo()
     body['importer_config']['feed'] = _FEED
     body['importer_config']['branches'] = [utils.uuid4()]
     repo_href = client.post(REPOSITORY_PATH, body).json()['_href']
     cls.resources.add(repo_href)
     cls.report, cls.tasks = _sync_repo(cls.cfg, repo_href)
Beispiel #10
0
 def setUpClass(cls):
     """Set ``cls.body``."""
     super(SyncInvalidFeedTestCase, cls).setUpClass()
     client = api.Client(cls.cfg)
     body = gen_repo()
     body['importer_config']['feed'] = utils.uuid4()
     body['importer_config']['branches'] = [_BRANCHES[0]]
     repo_href = client.post(REPOSITORY_PATH, body).json()['_href']
     cls.resources.add(repo_href)
     cls.report, cls.tasks = _sync_repo(cls.cfg, repo_href)
Beispiel #11
0
 def setUpClass(cls):
     """Create and sync an OSTree repository."""
     super(SyncInvalidBranchesTestCase, cls).setUpClass()
     client = api.Client(cls.cfg)
     body = gen_repo()
     body['importer_config']['feed'] = OSTREE_FEED
     body['importer_config']['branches'] = [utils.uuid4()]
     repo_href = client.post(REPOSITORY_PATH, body).json()['_href']
     cls.resources.add(repo_href)
     cls.report, cls.tasks = _sync_repo(cls.cfg, repo_href)
Beispiel #12
0
 def setUpClass(cls):
     """Create an OSTree repository with a valid feed and branch."""
     super(SyncTestCase, cls).setUpClass()
     body = gen_repo()
     body['importer_config']['feed'] = OSTREE_FEED
     body['importer_config']['branches'] = [OSTREE_BRANCH]
     repo = api.Client(cls.cfg).post(REPOSITORY_PATH, body).json()
     cls.resources.add(repo['_href'])
     cls.report = utils.sync_repo(cls.cfg, repo['_href'])
     cls.tasks = tuple(api.poll_spawned_tasks(cls.cfg, cls.report.json()))
 def setUpClass(cls):
     """Create an OSTree repository with a valid feed and branch."""
     super(SyncTestCase, cls).setUpClass()
     if selectors.bug_is_untestable(1934, cls.cfg.version):
         raise unittest2.SkipTest('https://pulp.plan.io/issues/1934')
     body = gen_repo()
     body['importer_config']['feed'] = OSTREE_FEED
     body['importer_config']['branches'] = [OSTREE_BRANCH]
     repo = api.Client(cls.cfg).post(REPOSITORY_PATH, body).json()
     cls.resources.add(repo['_href'])
     cls.report = utils.sync_repo(cls.cfg, repo['_href'])
     cls.tasks = tuple(api.poll_spawned_tasks(cls.cfg, cls.report.json()))
Beispiel #14
0
 def setUpClass(cls):
     """Create an OSTree repository with a valid feed and branch."""
     super(SyncTestCase, cls).setUpClass()
     if selectors.bug_is_untestable(1934, cls.cfg.version):
         raise unittest.SkipTest('https://pulp.plan.io/issues/1934')
     body = gen_repo()
     body['importer_config']['feed'] = OSTREE_FEED
     body['importer_config']['branches'] = [OSTREE_BRANCH]
     repo = api.Client(cls.cfg).post(REPOSITORY_PATH, body).json()
     cls.resources.add(repo['_href'])
     cls.report = utils.sync_repo(cls.cfg, repo['_href'])
     cls.tasks = tuple(api.poll_spawned_tasks(cls.cfg, cls.report.json()))
Beispiel #15
0
 def setUpClass(cls):
     """Create two repositories."""
     super(CreateTestCase, cls).setUpClass()
     client = api.Client(cls.cfg, api.json_handler)
     cls.bodies = tuple((gen_repo() for _ in range(2)))
     cls.bodies[1]['importer_config'] = {'feed': utils.uuid4()}
     cls.repos = [client.post(REPOSITORY_PATH, body) for body in cls.bodies]
     cls.importers_iter = [
         client.get(urljoin(repo['_href'], 'importers/'))
         for repo in cls.repos
     ]
     for repo in cls.repos:
         cls.resources.add(repo['_href'])  # mark for deletion
Beispiel #16
0
 def setUpClass(cls):
     """Create two repositories."""
     super(CreateTestCase, cls).setUpClass()
     client = api.Client(cls.cfg, api.json_handler)
     cls.bodies = tuple((gen_repo() for _ in range(2)))
     cls.bodies[1]['importer_config'] = {'feed': utils.uuid4()}
     cls.repos = [client.post(REPOSITORY_PATH, body) for body in cls.bodies]
     cls.importers_iter = [
         client.get(urljoin(repo['_href'], 'importers/'))
         for repo in cls.repos
     ]
     for repo in cls.repos:
         cls.resources.add(repo['_href'])  # mark for deletion
Beispiel #17
0
    def setUpClass(cls):
        """Create distributors and update with conflicting relative_paths."""
        super(UpdateDistributorsTestCase, cls).setUpClass()

        # Create two repository + distributor pairs.
        client = api.Client(cls.cfg, api.json_handler)
        distributors = []
        for _ in range(2):
            repo = client.post(REPOSITORY_PATH, gen_repo())
            cls.resources.add(repo['_href'])  # mark for deletion
            distributors.append(client.post(
                urljoin(repo['_href'], 'distributors/'),
                _gen_distributor(_gen_rel_path()),
            ))

        # Update the second distributor several times. After each update, we
        # read the distributor. This extra read is necessary b/c the initial
        # response is a call report.
        cls.written_paths = (
            _gen_rel_path(),  # successes
            _gen_rel_path(3),
            distributors[0]['config']['relative_path'],  # failures
            distributors[0]['config']['relative_path'] + '/' + utils.uuid4(),
            '/' + distributors[0]['config']['relative_path'],
        )
        cls.responses = []
        cls.read_paths = []
        for relative_path in cls.written_paths:
            client.response_handler = api.echo_handler
            cls.responses.append(client.put(
                distributors[1]['_href'],
                {'distributor_config': {'relative_path': relative_path}},
            ))
            tuple(api.poll_spawned_tasks(cls.cfg, cls.responses[-1].json()))
            client.response_handler = api.json_handler
            cls.read_paths.append(
                client.get(distributors[1]['_href'])['config']['relative_path']
            )
    def setUpClass(cls):
        """Create distributors and update with conflicting relative_paths."""
        super(UpdateDistributorsTestCase, cls).setUpClass()

        # Create two repository + distributor pairs.
        client = api.Client(cls.cfg, api.json_handler)
        distributors = []
        for _ in range(2):
            repo = client.post(REPOSITORY_PATH, gen_repo())
            cls.resources.add(repo['_href'])  # mark for deletion
            distributors.append(client.post(
                urljoin(repo['_href'], 'distributors/'),
                _gen_distributor(_gen_rel_path()),
            ))

        # Update the second distributor several times. After each update, we
        # read the distributor. This extra read is necessary b/c the initial
        # response is a call report.
        cls.written_paths = (
            _gen_rel_path(),  # successes
            _gen_rel_path(3),
            distributors[0]['config']['relative_path'],  # failures
            distributors[0]['config']['relative_path'] + '/' + utils.uuid4(),
            '/' + distributors[0]['config']['relative_path'],
        )
        cls.responses = []
        cls.read_paths = []
        for relative_path in cls.written_paths:
            client.response_handler = api.echo_handler
            cls.responses.append(client.put(
                distributors[1]['_href'],
                {'distributor_config': {'relative_path': relative_path}},
            ))
            tuple(api.poll_spawned_tasks(cls.cfg, cls.responses[-1].json()))
            client.response_handler = api.json_handler
            cls.read_paths.append(
                client.get(distributors[1]['_href'])['config']['relative_path']
            )
 def create_body():
     """Return a dict for creating a repository."""
     return gen_repo()
Beispiel #20
0
 def create_body():
     """Return a dict for creating a repository."""
     return gen_repo()