コード例 #1
0
    def do_test(self, cfg, repo_registry_id):
        """Execute the test with the given ``repo_registry_id``."""
        # Create, sync and publish.
        client = api.Client(cfg, api.json_handler)
        body = gen_repo()
        body['importer_config'].update({
            'enable_v1': False,
            'enable_v2': True,
            'feed': DOCKER_V2_FEED_URL,
            'upstream_name': get_upstream_name(cfg),
        })
        body['distributors'] = [gen_distributor()]
        body['distributors'][0]['distributor_config']['repo-registry-id'] = (
            repo_registry_id)
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})
        utils.sync_repo(cfg, repo)
        utils.publish_repo(cfg, repo)
        cli.GlobalServiceManager(cfg).restart(('httpd', ))  # restart Crane

        # Get and inspect /crane/repositories/v2.
        client = self.make_crane_client(cfg)
        repos = client.get('/crane/repositories/v2')
        self.assertIn(repo_registry_id, repos.keys())
        self.assertFalse(repos[repo_registry_id]['protected'])
コード例 #2
0
    def test_all(self):
        """Work with an image whose name has no namespace.

        Create, sync and publish a Docker repository whose ``UPSTREAM_NAME``
        doesn't include a namespace. A typical Docker image has a name like
        "library/busybox." When a non-namespaced image name like "busybox" is
        given, a prefix of "library" is assumed.
        """
        cfg = config.get_config()
        client = api.Client(cfg, api.json_handler)
        body = gen_repo()
        body['importer_config'].update({
            'enable_v1': False,
            'enable_v2': True,
            'feed': DOCKER_V2_FEED_URL,
            'upstream_name': 'busybox',
        })
        body['distributors'] = [gen_distributor()]
        repo = client.post(REPOSITORY_PATH, body)
        self.addCleanup(client.delete, repo['_href'])
        repo = client.get(repo['_href'], params={'details': True})
        utils.sync_repo(cfg, repo)
        utils.publish_repo(cfg, repo)

        # Make Crane read the metadata. (Now!)
        cli.GlobalServiceManager(cfg).restart(('httpd', ))

        # Get and inspect /crane/repositories/v2.
        if (cfg.pulp_version >= Version('2.14')
                and selectors.bug_is_testable(2723, cfg.pulp_version)):
            client = self.make_crane_client(cfg)
            repo_id = repo['id']
            repos = client.get('/crane/repositories/v2')
            self.assertIn(repo_id, repos.keys())
            self.assertFalse(repos[repo_id]['protected'])
コード例 #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})
        utils.sync_repo(self.cfg, self.repo)
        utils.publish_repo(self.cfg, self.repo)

        # Make Crane read metadata. (Now!)
        cli.GlobalServiceManager(self.cfg).restart(('httpd', ))
コード例 #4
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>`_
        """
        for issue_id in (2384, 2385):
            if selectors.bug_is_untestable(issue_id, self.cfg.pulp_version):
                self.skipTest(
                    'https://pulp.plan.io/issues/{}'.format(issue_id))
        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/'), {
                'criteria': {
                    'filters': {},
                    'type_ids': ['docker_manifest_list']
                },
                'source_repo_id': self.repo['id'],
            })
        repo = 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),
        )
コード例 #5
0
    def test_01_set_up(self):
        """Create, sync and publish a repository.

        Specifically, do the following:

        1. Create, sync and publish a Docker repository. Let the repository's
           feed reference a v1 Docker registry.
        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':
            True,
            'enable_v2':
            False,
            'feed':
            DOCKER_V1_FEED_URL,
            'upstream_name':
            get_upstream_name(self.cfg),
        })
        body['distributors'] = [gen_distributor()]
        type(self).repo = client.post(REPOSITORY_PATH, body)
        type(self).repo = client.get(self.repo['_href'],
                                     params={'details': True})
        utils.sync_repo(self.cfg, self.repo)
        utils.publish_repo(self.cfg, self.repo)

        # Make Crane re-read metadata. (Now!)
        cli.GlobalServiceManager(self.cfg).restart(('httpd', ))
コード例 #6
0
 def setUpClass(cls):
     """Create a Docker repository."""
     super(DuplicateUploadsTestCase, cls).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'])
コード例 #7
0
ファイル: test_sync.py プロジェクト: Telekom-PD/pulp-smash
    def setUpClass(cls):
        """Create a docker repository with an importer.

        The importer has no ``upstream_name`` set. it must be passed via
        ``override_config`` when a sync is requested.
        """
        super(UpstreamNameV2TestCase, cls).setUpClass()
        body = gen_repo()
        body['importer_config'] = {'feed': DOCKER_V2_FEED_URL}
        cls.repo_href = (api.Client(cls.cfg).post(REPOSITORY_PATH,
                                                  body).json()['_href'])
        cls.resources.add(cls.repo_href)
コード例 #8
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(UpdateTestCase, cls).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'])
コード例 #9
0
 def test_01_set_up(self):
     """Create a repository and populate with with schema v2 content."""
     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,
         'upstream_name':
         get_upstream_name(self.cfg),
     })
     type(self).repo = client.post(REPOSITORY_PATH, body)
     utils.sync_repo(self.cfg, self.repo)
     type(self).repo = client.get(self.repo['_href'],
                                  params={'details': True})
コード例 #10
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),
        )
コード例 #11
0
ファイル: test_tags.py プロジェクト: Telekom-PD/pulp-smash
def create_docker_repo(cfg, upstream_name, use_v1=False):
    """Create a docker repository.

    :param pulp_smash.config.PulpSmashConfig 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()
    if use_v1:
        body['importer_config'].update({
            'enable_v1': True,
            'feed': DOCKER_V1_FEED_URL,
        })
    else:
        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)
コード例 #12
0
 def create_body():
     """Return a dict for creating a repository."""
     return gen_repo()