Example #1
0
    def test_all(self):
        """Copy content between OSTree repositories with a filter.

        Do the following:

        1. Create a pair of repositories, and populate the first.
        2. Randomly select a unit from the first repository, and copy
           it to the second repository.
        3. Verify that the selected unit is the only one in the second
           repository.
        """
        repos = []
        cfg = config.get_config()
        client = api.Client(cfg, api.json_handler)

        # Create and populate a source repository.
        body = gen_repo()
        body['importer_config']['feed'] = OSTREE_FEED
        body['importer_config']['branches'] = OSTREE_BRANCHES
        body['distributors'] = [gen_distributor()]
        repos.append(client.post(REPOSITORY_PATH, body))
        self.addCleanup(client.delete, repos[0]['_href'])
        utils.sync_repo(cfg, repos[0])

        # Create a destination repository.
        repos.append(client.post(REPOSITORY_PATH, gen_repo()))
        self.addCleanup(client.delete, repos[1]['_href'])

        # Copy a random unit between the repos, and verify the result.
        src_unit_id = random.choice(utils.search_units(
            cfg, repos[0]))['metadata']['_id']
        client.post(
            urljoin(repos[1]['_href'], 'actions/associate/'), {
                'source_repo_id': repos[0]['id'],
                'criteria': {
                    'filters': {
                        'unit': {
                            '_id': src_unit_id
                        }
                    },
                    'type_ids': ['ostree'],
                },
            })
        dst_unit_ids = [
            unit['metadata']['_id'] for unit in utils.search_units(
                cfg, repos[1], {'type_ids': ['ostree']})
        ]
        self.assertEqual([src_unit_id], dst_unit_ids)
Example #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_BRANCHES
        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)
        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'])
Example #3
0
    def setUpClass(cls):
        """Create a pair of repositories.

        Ensure the first repo has a distributor with a relative path.
        Succeeding tests will give the second repository distributors with
        relative paths, where those paths may or may not conflict with the
        first repository's distributor's relative path. This test splits the
        distributors across two repositories to ensure that Pulp correctly
        checks new relative paths against the existing relative paths in all
        repositories.
        """
        super().setUpClass()
        client = api.Client(cls.cfg, api.json_handler)
        bodies = tuple(gen_repo() for _ in range(2))
        bodies[0]['distributors'] = [_gen_distributor(_gen_rel_path())]
        cls.repos = []
        try:
            for body in bodies:
                repo = client.post(REPOSITORY_PATH, body)
                cls.resources.add(repo['_href'])
                cls.repos.append(
                    client.get(repo['_href'], params={'details': True}))
        except:  # noqa:E722
            cls.tearDownClass()
            raise
Example #4
0
 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)
Example #5
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)
Example #6
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'] = OSTREE_BRANCHES
     repo_href = client.post(REPOSITORY_PATH, body).json()['_href']
     cls.resources.add(repo_href)
     cls.report, cls.tasks = _sync_repo(cls.cfg, repo_href)
Example #7
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.pulp_version):
         raise unittest.SkipTest('https://pulp.plan.io/issues/1934')
     body = gen_repo()
     body['importer_config']['feed'] = OSTREE_FEED
     body['importer_config']['branches'] = OSTREE_BRANCHES
     repo = api.Client(cls.cfg).post(REPOSITORY_PATH, body).json()
     cls.resources.add(repo['_href'])
     cls.report = utils.sync_repo(cls.cfg, repo)
     cls.tasks = tuple(api.poll_spawned_tasks(cls.cfg, cls.report.json()))
Example #8
0
 def create_body():
     """Return a dict for creating a repository."""
     return gen_repo()