示例#1
0
 def test_positive_copy_output(self):
     """Assert that the list of image_ids in the copy output are correct."""
     # We pass --fields to work around pulp-admin's weird line breaking
     # behaviour. See: https://pulp.plan.io/issues/1696
     units_in_src = docker_utils.repo_search(
         self.cfg,
         fields='image_id',
         repo_id=self.repo_ids[0],
         unit_type='image',
     ).stdout
     image_ids_search = set(re.findall(_IMAGE_ID_RE, units_in_src))
     image_ids_copy = set(re.findall(r'(?: {2})(\w*)', self.copy.stdout))
     self.assertEqual(image_ids_search, image_ids_copy)
示例#2
0
    def test_positive_copy_output(self):
        """Assert that the list of manifests in the copy output are correct."""
        units_search = docker_utils.repo_search(
            self.cfg,
            fields='digest',
            repo_id=self.repo_ids[0],
            unit_type='manifest',
        ).stdout
        unit_ids_search = set(re.findall(_DIGEST_RE, units_search))

        # The manifest digests are printed after "docker_manifest:".
        unit_ids_copy = self.copy.stdout.split('docker_manifest:')[1]
        unit_ids_copy = re.findall(r'(?: {2})(\w*:\w*)', unit_ids_copy)
        unit_ids_copy = _truncate_ids(unit_ids_copy)

        self.assertEqual(unit_ids_search, unit_ids_copy)
示例#3
0
    def test_positive_copy_output(self):
        """Assert that the list of tags in the copy output are correct."""
        units_search = docker_utils.repo_search(
            self.cfg,
            fields='name',
            repo_id=self.repo_ids[0],
            unit_type='tag',
        ).stdout
        unit_ids_search = set(re.findall(_DIGEST_RE, units_search))

        # The tag digests are printed after "docker_tag:".
        unit_ids_copy = self.copy.stdout.split('docker_tag:')[1]
        unit_ids_copy = re.findall(r'(?: {2})(\w*:\w*)', unit_ids_copy)
        unit_ids_copy = _truncate_ids(unit_ids_copy)

        self.assertEqual(unit_ids_search, unit_ids_copy)
示例#4
0
def _get_unit_ids(server_config, repo_id, unit_type, regex):
    """Search for content units in a docker repository and return their IDs.

    This method is highly specific to the tests in this module, and the best
    way to understand it is to read its source code.

    :param pulp_smash.config.ServerConfig server_config: Information about the
        Pulp server being targeted.
    :param repo_id: A docker repository ID.
    :param unit_type: A type of docker content unit, like "image" or "tag."
    :param regex: A regex for searching stdout for unit IDs.
    :returns: A set of unit IDs.
    """
    # We omit `--fields unit_ids` due to https://pulp.plan.io/issues/1693
    units = docker_utils.repo_search(
        server_config,
        repo_id=repo_id,
        unit_type=unit_type,
    ).stdout
    return set(re.findall(regex, units))
示例#5
0
def _get_unit_ids(server_config, repo_id, unit_type, regex):
    """Search for content units in a docker repository and return their IDs.

    This method is highly specific to the tests in this module, and the best
    way to understand it is to read its source code.

    :param pulp_smash.config.ServerConfig server_config: Information about the
        Pulp server being targeted.
    :param repo_id: A docker repository ID.
    :param unit_type: A type of docker content unit, like "image" or "tag."
    :param regex: A regex for searching stdout for unit IDs.
    :returns: A set of unit IDs.
    """
    # We omit `--fields unit_ids` due to https://pulp.plan.io/issues/1693
    units = docker_utils.repo_search(
        server_config,
        repo_id=repo_id,
        unit_type=unit_type,
    ).stdout
    return set(re.findall(regex, units))
示例#6
0
    def test_positive_copy_output(self):
        """Assert that the list of tags in the copy output are correct."""
        # Sample output:
        #
        #     Copied:
        #       docker_blob: 20
        #       docker_tag: 43
        #       docker_manifest: 43
        #
        copy_count = self.copy.stdout.splitlines()
        copy_count = [line for line in copy_count if 'docker_tag:' in line]
        self.assertEqual(len(copy_count), 1, self.copy.stdout)
        copy_count = int(copy_count[0].split('docker_tag:')[1].strip())

        # Sample output: (Notice "Manifest Digest," not "Digest.")
        #
        #     Created:      2016-10-10T20:45:06Z
        #     Metadata:
        #       Manifest Digest:    sha256:98a0bd48d22ff96ca23bfda2fe1cf72034e…
        #                           274aca0f9c51c
        #       Name:               latest
        #       Pulp User Metadata:
        #       Repo Id:            6d49614e-621a-4a7c-ae0b-ae3885463227
        #     Repo Id:      6d49614e-621a-4a7c-ae0b-ae3885463227
        #     Unit Id:      f0e4abc1-e63f-4e24-a249-8e5b91446787
        #     Unit Type Id: docker_tag
        #     Updated:      2016-10-10T20:45:06Z
        #
        search_count = docker_utils.repo_search(
            self.cfg,
            repo_id=self.repo_ids[0],
            unit_type='tag',
        ).stdout
        search_count = len(re.findall(_UNIT_ID_RE, search_count))

        self.assertEqual(copy_count, search_count)
示例#7
0
    def test_positive_copy_output(self):
        """Assert that the list of tags in the copy output are correct."""
        # Sample output:
        #
        #     Copied:
        #       docker_blob: 20
        #       docker_tag: 43
        #       docker_manifest: 43
        #
        copy_count = self.copy.stdout.splitlines()
        copy_count = [line for line in copy_count if 'docker_tag:' in line]
        self.assertEqual(len(copy_count), 1, self.copy.stdout)
        copy_count = int(copy_count[0].split('docker_tag:')[1].strip())

        # Sample output: (Notice "Manifest Digest," not "Digest.")
        #
        #     Created:      2016-10-10T20:45:06Z
        #     Metadata:
        #       Manifest Digest:    sha256:98a0bd48d22ff96ca23bfda2fe1cf72034e…
        #                           274aca0f9c51c
        #       Name:               latest
        #       Pulp User Metadata:
        #       Repo Id:            6d49614e-621a-4a7c-ae0b-ae3885463227
        #     Repo Id:      6d49614e-621a-4a7c-ae0b-ae3885463227
        #     Unit Id:      f0e4abc1-e63f-4e24-a249-8e5b91446787
        #     Unit Type Id: docker_tag
        #     Updated:      2016-10-10T20:45:06Z
        #
        search_count = docker_utils.repo_search(
            self.cfg,
            repo_id=self.repo_ids[0],
            unit_type='tag',
        ).stdout
        search_count = len(re.findall(_UNIT_ID_RE, search_count))

        self.assertEqual(copy_count, search_count)