Esempio n. 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'])
        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(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 search_units(cfg, repos[1], {'type_ids': ['ostree']})
        ]
        self.assertEqual([src_unit_id], dst_unit_ids)
Esempio n. 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.
        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.
        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'])
Esempio n. 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
Esempio n. 4
0
    def test_all(self):
        """Test the update of ostree importers.

        Do the following:

        1. Create a repository.
        2. Update the ``importer`` associated with the repository.
        3. Perform assertions about the just updated ``importer``.
        """
        cfg = config.get_config()
        if not selectors.bug_is_fixed(3210, cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/3210')
        client = api.Client(cfg, api.json_handler)
        body = gen_repo()
        body['importer_config']['feed'] = OSTREE_FEED
        body['importer_config']['branches'] = OSTREE_BRANCHES
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})
        importer_config = {
            'basic_auth_username': None,
            'depth': randrange(-1, 10),
            'feed': utils.uuid4(),
            'ssl_validation': choice((False, True)),
        }
        client.put(repo['importers'][0]['_href'],
                   {'importer_config': importer_config})
        repo = client.get(repo['_href'], params={'details': True})
        for key, val in importer_config.items():
            with self.subTest(key=key):
                if val is None:
                    self.assertNotIn(key, repo['importers'][0]['config'])
                else:
                    self.assertEqual(val, repo['importers'][0]['config'][key])
Esempio n. 5
0
 def setUpClass(cls):
     """Create and sync an OSTree repository."""
     super().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)
Esempio n. 6
0
 def setUpClass(cls):
     """Create and sync an OSTree repository."""
     super().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)
Esempio n. 7
0
 def setUpClass(cls):
     """Set ``cls.body``."""
     super().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)
Esempio n. 8
0
 def setUpClass(cls):
     """Create an OSTree repository with a valid feed and branch."""
     super().setUpClass()
     if not selectors.bug_is_fixed(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 = sync_repo(cls.cfg, repo)
     cls.tasks = tuple(api.poll_spawned_tasks(cls.cfg, cls.report.json()))
Esempio n. 9
0
 def create_body():
     """Return a dict for creating a repository."""
     return gen_repo()