Exemple #1
0
    def test_02_copy_manifest_lists(self):
        """Copy manifest lists from one repository to another.

        Assert the same number of manifest lists are present in both
        repositories. This test targets:

        * `Pulp #2384 <https://pulp.plan.io/issues/2384>`_
        * `Pulp #2385 <https://pulp.plan.io/issues/2385>`_
        * `Pulp #3892 <https://pulp.plan.io/issues/3892>`_
        """
        for issue_id in (2384, 2385, 3892):
            if not selectors.bug_is_fixed(issue_id, self.cfg.pulp_version):
                self.skipTest(
                    'https://pulp.plan.io/issues/{}'.format(issue_id)
                )
        repo = self.client.post(REPOSITORY_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])
        self.client.post(urljoin(repo['_href'], 'actions/associate/'), {
            'criteria': {'filters': {}, 'type_ids': ['docker_manifest_list']},
            'source_repo_id': self.repo['id'],
        })
        repo = self.client.get(repo['_href'], params={'details': True})
        self.assertEqual(
            self.repo['content_unit_counts']['docker_manifest_list'],
            repo['content_unit_counts'].get('docker_manifest_list', 0),
        )
Exemple #2
0
    def test_02_copy_tags(self):
        """Copy tags from one repository to another.

        Assert the same number of tags are present in both repositories.

        This test targets `Pulp #3892 <https://pulp.plan.io/issues/3892>`_.
        """
        if not selectors.bug_is_fixed(3892, self.cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/3892')
        client = api.Client(self.cfg, api.json_handler)
        repo = client.post(REPOSITORY_PATH, gen_repo())
        self.addCleanup(client.delete, repo['_href'])
        client.post(
            urljoin(repo['_href'], 'actions/associate/'), {
                'source_repo_id': self.repo['id'],
                'criteria': {
                    'filters': {},
                    'type_ids': ['docker_tag']
                },
            })
        repo = client.get(repo['_href'], params={'details': True})
        self.assertEqual(
            self.repo['content_unit_counts']['docker_tag'],
            repo['content_unit_counts'].get('docker_tag', 0),
        )
Exemple #3
0
    def test_01_set_up(self):
        """Create, sync and publish a Docker repository.

        Specifically, do the following:

        1. Create, sync and publish a Docker repository. Let the repository's
           upstream name reference a repository that has an image with a
           manifest list and no amd64/linux build.
        2. Make Crane immediately re-read the metadata files published by Pulp.
           (Restart Apache.)
        """
        client = api.Client(self.cfg, api.json_handler)
        body = gen_repo()
        body['importer_config'].update({
            'enable_v1': False,
            'enable_v2': True,
            'feed': DOCKER_V2_FEED_URL,
            # DOCKER_UPSTREAM_NAME (dmage/manifest-list-test) has an image
            # without any amd64/linux build. However, it has a v1 manifest.
            'upstream_name': 'dmage/busybox',
        })
        body['distributors'] = [gen_distributor()]
        type(self).repo = client.post(REPOSITORY_PATH, body)
        type(self).repo = client.get(self.repo['_href'],
                                     params={'details': True})
        sync_repo(self.cfg, self.repo)
        publish_repo(self.cfg, self.repo)

        # Make Crane read metadata. (Now!)
        cli.GlobalServiceManager(self.cfg).restart(('httpd', ))
Exemple #4
0
 def setUpClass(cls):
     """Create a Docker repository."""
     super().setUpClass()
     unit = utils.http_get(DOCKER_IMAGE_URL)
     import_params = {'unit_type_id': 'docker_image'}
     repo = api.Client(cls.cfg).post(REPOSITORY_PATH, gen_repo()).json()
     cls.upload_import_unit_args = (cls.cfg, unit, import_params, repo)
     cls.resources.add(repo['_href'])
Exemple #5
0
 def create_and_copy_test_repo(self, source_repo, copy_units):
     """Return test repo to copy units to test."""
     body = gen_repo(importer_config={
         'enable_v1': False,
         'enable_v2': True,
     })
     repo = self.client.post(REPOSITORY_PATH, body)
     self.copy_docker_units(repo, source_repo, copy_units)
     return repo
Exemple #6
0
    def test_02_copy_tags_user_metadata(self):
        """Copy tags with user_metadata from one repository to another.

        Assert the user metadata associated with a tag is present in
        both repositories.

        Steps:

        1. Add user metadata to the first tag in the source repo.
        2. Copy the tags from one repo to the other.
        3. Verify that the user_metadata is copied to the other repo.

        This test targets the following

        * `Pulp #3242 <https://pulp.plan.io/issues/3242>`_.
        * `Pulp-2-tests #72 <https://github.com/PulpQE/Pulp-2-Tests/issues/72>`_.
        """
        if not selectors.bug_is_fixed(3892, self.cfg.pulp_version):
            self.skipTest('https://pulp.plan.io/issues/3892')

        # Step 1
        tag_first_repo = search_units(
            self.cfg, self.repo,
            {'type_ids': ['docker_tag']}
        )[0]

        user_metadata = {
            'dummy_key_1': 'dummy_value_1',
            'dummy_key_2': 'dummy_value_2',
        }
        self.set_user_metadata(tag_first_repo, user_metadata)

        # Step 2
        repo = self.client.post(REPOSITORY_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])
        self.client.post(urljoin(repo['_href'], 'actions/associate/'), {
            'source_repo_id': self.repo['id'],
            'criteria': {'filters': {}, 'type_ids': ['docker_tag']},
        })

        units = search_units(
            self.cfg, repo, {
                'type_ids': ['docker_tag'],
                'filters': {
                    'unit': {
                        'name': tag_first_repo['metadata']['name'],
                        'schema_version': tag_first_repo['metadata']['schema_version']
                    }
                },
            })

        # Step 3
        self.assertEqual(units[0]['metadata']['pulp_user_metadata'], user_metadata, units)
Exemple #7
0
    def _do_create_v2_repo(self):
        """Create a v2 Docker repository, and schedule it for deletion.

        The repository's importer has no ``upstream_name`` set. One must be
        passed via an ``override_config`` when a sync is requested.
        """
        repo = self.client.post(
            REPOSITORY_PATH,
            gen_repo(importer_config={'feed': DOCKER_V2_FEED_URL}),
        )
        self.addCleanup(self.client.delete, repo['_href'])
        return repo
Exemple #8
0
 def setUpClass(cls):
     """Set cfg and api for each test."""
     cls.cfg = config.get_config()
     cls.client = api.Client(cls.cfg, api.json_handler)
     body = gen_repo(
         importer_config={
             'enable_v1': False,
             'enable_v2': True,
             'feed': DOCKER_V2_FEED_URL,
             'upstream_name': DOCKER_REMOVE_UPSTREAM_NAME,
         })
     cls.repo = cls.client.post(REPOSITORY_PATH, body)
     sync_repo(cls.cfg, cls.repo)
Exemple #9
0
 def test_01_set_up(self):
     """Create a repository and populate with with schema v2 content."""
     body = gen_repo()
     body['importer_config'].update({
         'enable_v1': False,
         'enable_v2': True,
         'feed': DOCKER_V2_FEED_URL,
         'upstream_name': get_upstream_name(self.cfg),
     })
     type(self).repo = self.client.post(REPOSITORY_PATH, body)
     sync_repo(self.cfg, self.repo)
     type(self).repo = self.client.get(
         self.repo['_href'],
         params={'details': True}
     )
Exemple #10
0
    def test_02_copy_manifests(self):
        """Copy manifests from one repository to another.

        Assert the same number of manifests are present in both repositories.
        """
        repo = self.client.post(REPOSITORY_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])
        self.client.post(urljoin(repo['_href'], 'actions/associate/'), {
            'criteria': {'filters': {}, 'type_ids': ['docker_manifest']},
            'source_repo_id': self.repo['id'],
        })
        repo = self.client.get(repo['_href'], params={'details': True})
        self.assertEqual(
            self.repo['content_unit_counts']['docker_manifest'],
            repo['content_unit_counts'].get('docker_manifest', 0),
        )
Exemple #11
0
def create_docker_repo(cfg, upstream_name):
    """Create a docker repository.

    :param cfg: Information about a Pulp
        host.
    :param upstream_name: The Docker container upstream name.
    :param use_v1: If ``True`` use Docker V1 feed URL else use Docker V2 feed
        URL.
    :return: Detailed information about the created repository.
    """
    body = gen_repo()
    body['importer_config'].update({
        'feed': DOCKER_V2_FEED_URL,
    })
    body['importer_config']['upstream_name'] = upstream_name
    client = api.Client(cfg, api.json_handler)
    return client.post(REPOSITORY_PATH, body)
Exemple #12
0
    def test_02_copy_images(self):
        """Copy tags from one repository to another.

        Assert the same number of images are present in both repositories.
        """
        client = api.Client(self.cfg, api.json_handler)
        repo = client.post(REPOSITORY_PATH, gen_repo())
        self.addCleanup(client.delete, repo['_href'])
        client.post(
            urljoin(repo['_href'], 'actions/associate/'), {
                'source_repo_id': self.repo['id'],
                'criteria': {
                    'filters': {},
                    'type_ids': ['docker_image']
                },
            })
        repo = client.get(repo['_href'], params={'details': True})
        self.assertEqual(
            self.repo['content_unit_counts']['docker_image'],
            repo['content_unit_counts'].get('docker_image', 0),
        )
Exemple #13
0
    def setUpClass(cls):
        """Create a docker repo with a distributor, and update the distributor.

        Do the following:

        1. Create a docker repository and add a distributor.
        2. Update the distributor. Use the distributor's href in the request.
        3. Update the distributor. Use the repository's href in the request,
           and ensure the distributor is updated by packing certain data in the
           request body.
        """
        super().setUpClass()
        cls.sent_ids = tuple(('test/' + utils.uuid4() for _ in range(2)))
        cls.responses = {}

        # Create a repository and a distributor
        client = api.Client(cls.cfg)
        repo = client.post(REPOSITORY_PATH, gen_repo()).json()
        cls.resources.add(repo['_href'])
        cls.responses['add distributor'] = client.post(
            urljoin(repo['_href'], 'distributors/'),
            _gen_distributor(),
        )
        distributor = cls.responses['add distributor'].json()

        # Update the distributor
        cls.responses['first update'] = client.put(
            distributor['_href'],
            {'distributor_config': {'repo_registry_id': cls.sent_ids[0]}},
        )
        cls.responses['first read'] = client.get(distributor['_href'])

        # Update the distributor again, from repo this time
        cls.responses['second update'] = client.put(
            repo['_href'],
            {'distributor_configs': {distributor['id']: {
                'repo_registry_id': cls.sent_ids[1],
            }}},
        )
        cls.responses['second read'] = client.get(distributor['_href'])
Exemple #14
0
 def create_body():
     """Return a dict for creating a repository."""
     return gen_repo()