示例#1
0
    def test_duplicate_file_sync(self):
        """Sync a repository with remotes containing same file names.

        This test does the following.

        1. Create a repository in pulp.
        2. Create two remotes containing the same file.
        3. Check whether the created repo has only one copy of the file.

        This test targets the following issue:

        `Pulp #4738 <https://pulp.plan.io/issues/4738>`_
        """
        # Step 1
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo["_href"])

        # Step 2
        remote = self.client.post(FILE_REMOTE_PATH, gen_file_remote())
        self.addCleanup(self.client.delete, remote["_href"])
        remote2 = self.client.post(
            FILE_REMOTE_PATH, gen_file_remote(url=FILE2_FIXTURE_MANIFEST_URL))
        self.addCleanup(self.client.delete, remote2["_href"])
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo["_href"])
        self.assertDictEqual(get_content_summary(repo), FILE_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo),
                             FILE_FIXTURE_SUMMARY)

        sync(self.cfg, remote2, repo)
        repo = self.client.get(repo["_href"])
        self.assertDictEqual(get_added_content_summary(repo),
                             FILE_FIXTURE_SUMMARY)
示例#2
0
    def test_mirror_sync_with_requirements(self):
        """
        Sync multiple remotes into the same repo with mirror as `True` using requirements.

        This test targets the following issue: 5250

        * `<https://pulp.plan.io/issues/5250>`_

        This test does the following:

        1. Create a repo.
        2. Create two remotes
            a. Role remote
            b. Collection remote
        3. Sync the repo with Role remote.
        4. Sync the repo with Collection remote with ``Mirror=True``.
        5. Verify whether the content in the latest version of the repo
           has only Collection content and Role content is deleted.
        """
        # Step 1
        repo = self.client.post(ANSIBLE_REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo["pulp_href"])

        # Step 2
        role_remote = self.client.post(ANSIBLE_REMOTE_PATH,
                                       gen_ansible_remote())
        self.addCleanup(self.client.delete, role_remote["pulp_href"])

        collection_remote = self.client.post(
            ANSIBLE_COLLECTION_REMOTE_PATH,
            gen_ansible_remote(
                url=ANSIBLE_COLLECTION_TESTING_URL_V2,
                requirements_file=ANSIBLE_COLLECTION_REQUIREMENT,
            ),
        )

        self.addCleanup(self.client.delete, collection_remote["pulp_href"])

        # Step 3
        sync(self.cfg, role_remote, repo)
        repo = self.client.get(repo["pulp_href"])
        self.assertIsNotNone(repo["latest_version_href"], repo)
        self.assertDictEqual(get_added_content_summary(repo),
                             ANSIBLE_FIXTURE_CONTENT_SUMMARY)

        # Step 4
        sync(self.cfg, collection_remote, repo, mirror=True)
        repo = self.client.get(repo["pulp_href"])
        added_content_summary = get_added_content_summary(repo)
        self.assertGreaterEqual(
            added_content_summary[ANSIBLE_COLLECTION_CONTENT_NAME],
            ANSIBLE_COLLECTION_FIXTURE_COUNT)

        # Step 5
        content_summary = get_content_summary(repo)
        self.assertGreaterEqual(
            content_summary[ANSIBLE_COLLECTION_CONTENT_NAME],
            ANSIBLE_COLLECTION_FIXTURE_COUNT)
        self.assertDictEqual(get_removed_content_summary(repo),
                             ANSIBLE_FIXTURE_CONTENT_SUMMARY)
示例#3
0
    def test_rpm(self):
        """Sync repositories with the rpm plugin.

        In order to sync a repository a remote has to be associated within
        this repository. When a repository is created this version field is set
        as None. After a sync the repository version is updated.

        Do the following:

        1. Create a repository and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Assert that the correct number of units were added and are present
           in the repo.
        6. Sync the remote one more time.
        7. Assert that repository version is different from the previous one.
        8. Assert that the same number of are present and that no units were
           added.
        """
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        # Create a remote with the standard test fixture url.
        body = gen_rpm_remote()
        remote = self.client.post(RPM_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

        # Sync the repository.
        self.assertIsNone(repo['_latest_version_href'])
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['_href'])

        # Check that we have the correct content counts.
        self.assertIsNotNone(repo['_latest_version_href'])
        self.assertDictEqual(
            get_content_summary(repo),
            RPM_FIXTURE_SUMMARY
        )
        self.assertDictEqual(
            get_added_content_summary(repo),
            RPM_FIXTURE_SUMMARY
        )

        # Sync the repository again.
        latest_version_href = repo['_latest_version_href']
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['_href'])

        # Check that nothing has changed since the last sync.
        self.assertNotEqual(latest_version_href, repo['_latest_version_href'])
        self.assertDictEqual(
            get_content_summary(repo),
            RPM_FIXTURE_SUMMARY
        )
        self.assertDictEqual(get_added_content_summary(repo), {})
示例#4
0
    def test_rpm(self):
        """Sync repositories with the rpm plugin.

        In order to sync a repository a remote has to be associated within
        this repository. When a repository is created this version field is set
        as None. After a sync the repository version is updated.

        Do the following:

        1. Create a repository and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Assert that the correct number of units were added and are present
           in the repo.
        6. Sync the remote one more time.
        7. Assert that repository version is different from the previous one.
        8. Assert that the same number of are present and that no units were
           added.
        """
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        # Create a remote with the standard test fixture url.
        body = gen_rpm_remote()
        remote = self.client.post(RPM_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

        # Sync the repository.
        self.assertIsNone(repo['_latest_version_href'])
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['_href'])

        # Check that we have the correct content counts.
        self.assertIsNotNone(repo['_latest_version_href'])
        self.assertDictEqual(
            get_content_summary(repo),
            RPM_FIXTURE_SUMMARY
        )
        self.assertDictEqual(
            get_added_content_summary(repo),
            RPM_FIXTURE_SUMMARY
        )

        # Sync the repository again.
        latest_version_href = repo['_latest_version_href']
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['_href'])

        # Check that nothing has changed since the last sync.
        self.assertNotEqual(latest_version_href, repo['_latest_version_href'])
        self.assertDictEqual(
            get_content_summary(repo),
            RPM_FIXTURE_SUMMARY
        )
        self.assertDictEqual(get_added_content_summary(repo), {})
示例#5
0
    def test_mirror_sync(self):
        """Sync multiple plugin into the same repo with mirror as `True`.

        This test targets the following issue: 4448

        * `<https://pulp.plan.io/issues/4448>`_

        This test does the following:

        1. Create a repo.
        2. Create two remotes
            a. RPM remote
            b. File remote
        3. Sync the repo with RPM remote.
        4. Sync the repo with File remote with ``Mirror=True``.
        5. Verify whether the content in the latest version of the repo
           has only File content and RPM content is deleted.
        """
        # Step 1
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        # Step 2
        rpm_remote = self.client.post(RPM_REMOTE_PATH,
                                      gen_remote(url=RPM_UNSIGNED_FIXTURE_URL))
        self.addCleanup(self.client.delete, rpm_remote['_href'])

        file_remote = self.client.post(
            FILE_REMOTE_PATH, gen_remote(url=FILE_FIXTURE_MANIFEST_URL))
        self.addCleanup(self.client.delete, file_remote['_href'])

        # Step 3
        sync(self.cfg, rpm_remote, repo)
        repo = self.client.get(repo['_href'])
        self.assertIsNotNone(repo['_latest_version_href'])
        self.assertDictEqual(get_added_content_summary(repo),
                             RPM_FIXTURE_SUMMARY)

        # Step 4
        sync(self.cfg, file_remote, repo, mirror=True)
        repo = self.client.get(repo['_href'])
        self.assertIsNotNone(repo['_latest_version_href'])
        self.assertDictEqual(get_added_content_summary(repo),
                             FILE_FIXTURE_SUMMARY)

        # Step 5
        self.assertDictEqual(get_content_summary(repo), FILE_FIXTURE_SUMMARY)
        self.assertDictEqual(get_removed_content_summary(repo),
                             RPM_FIXTURE_SUMMARY)
示例#6
0
    def test_checksum_constraint(self):
        """Verify checksum constraint test case.

        Do the following:

        1. Create and sync a repo using the following
           url=RPM_REFERENCES_UPDATEINFO_URL.
        2. Create and sync a secondary repo using the following
           url=RPM_UNSIGNED_FIXTURE_URL.
           Those urls have RPM packages with the same name.
        3. Assert that the task succeed.

        This test targets the following issue:

        * `Pulp #4170 <https://pulp.plan.io/issues/4170>`_
        * `Pulp #4255 <https://pulp.plan.io/issues/4255>`_
        """
        for repository in [RPM_REFERENCES_UPDATEINFO_URL, RPM_UNSIGNED_FIXTURE_URL]:
            body = gen_rpm_remote(repository)
            remote = self.remote_api.create(body)

            repo, remote = self.do_test(remote=remote)

            self.addCleanup(self.repo_api.delete, repo.pulp_href)
            self.addCleanup(self.remote_api.delete, remote.pulp_href)

            self.assertDictEqual(get_content_summary(repo.to_dict()), RPM_FIXTURE_SUMMARY)
            self.assertDictEqual(get_added_content_summary(repo.to_dict()), RPM_FIXTURE_SUMMARY)
示例#7
0
    def test_sync(self):
        """Sync repositories with the rpm plugin.

        In order to sync a repository a remote has to be associated within
        this repository. When a repository is created this version field is set
        as version '0'. After a sync the repository version is updated.

        Do the following:

        1. Create a repository, and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Assert that the correct number of units were added and are present
           in the repo.
        6. Sync the remote one more time.
        7. Assert that repository version is different from the previous one.
        8. Assert that the same number of are present and that no units were
           added.
        """
        repo, remote = self.do_test()

        self.addCleanup(self.repo_api.delete, repo.pulp_href)
        self.addCleanup(self.remote_api.delete, remote.pulp_href)

        self.assertDictEqual(get_content_summary(repo.to_dict()), RPM_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo.to_dict()), RPM_FIXTURE_SUMMARY)

        # Sync the repository again.
        latest_version_href = repo.latest_version_href
        repo, remote = self.do_test(repo, remote)

        self.assertEqual(latest_version_href, repo.latest_version_href)
        self.assertDictEqual(get_content_summary(repo.to_dict()), RPM_FIXTURE_SUMMARY)
示例#8
0
    def _setup_repos(self,
                     remote_url=RPM_UNSIGNED_FIXTURE_URL,
                     summary=RPM_FIXTURE_SUMMARY):
        """Prepare for a copy test by creating two repos and syncing.

        Do the following:

        1. Create two repositories and a remote.
        2. Sync the remote.
        3. Assert that repository version is not None.
        4. Assert that the correct number of units were added and are present in the repo.
        """
        source_repo = self.client.post(RPM_REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, source_repo["pulp_href"])

        dest_repo = self.client.post(RPM_REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, dest_repo["pulp_href"])

        # Create a remote with the standard test fixture url.
        body = gen_rpm_remote(url=remote_url)
        remote = self.client.post(RPM_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote["pulp_href"])

        # Sync the repository.
        self.assertEqual(source_repo["latest_version_href"],
                         f"{source_repo['pulp_href']}versions/0/")
        sync(self.cfg, remote, source_repo)
        source_repo = self.client.get(source_repo["pulp_href"])

        # Check that we have the correct content counts.
        self.assertDictEqual(get_content_summary(source_repo), summary)
        self.assertDictEqual(get_added_content_summary(source_repo), summary)

        return source_repo, dest_repo
示例#9
0
    def test_sync_with_aws_requirements(self):
        """Test to sync down amazon.aws versions."""
        requirements_file = "collections:\n  - amazon.aws"

        repo = self.client.post(ANSIBLE_REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo["pulp_href"])

        collection_remote = self.client.post(
            ANSIBLE_COLLECTION_REMOTE_PATH,
            gen_ansible_remote(
                url=GALAXY_ANSIBLE_BASE_URL,
                requirements_file=requirements_file,
            ),
        )

        self.addCleanup(self.client.delete, collection_remote["pulp_href"])

        sync(self.cfg, collection_remote, repo, mirror=True)
        repo = self.client.get(repo["pulp_href"])
        added_content_summary = get_added_content_summary(repo)
        self.assertGreaterEqual(
            added_content_summary[ANSIBLE_COLLECTION_CONTENT_NAME], 67)

        content_summary = get_content_summary(repo)
        self.assertGreaterEqual(
            content_summary[ANSIBLE_COLLECTION_CONTENT_NAME], 67)
示例#10
0
    def test_sync_with_requirements(self):
        """
        Sync using a complex requirements.yml file.

        This test targets the following issue: 5250

        * `<https://pulp.plan.io/issues/5250>`_
        """
        # Step 1
        repo = self.client.post(ANSIBLE_REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo["pulp_href"])

        collection_remote = self.client.post(
            ANSIBLE_COLLECTION_REMOTE_PATH,
            gen_ansible_remote(
                url=GALAXY_ANSIBLE_BASE_URL,
                requirements_file=ANSIBLE_COLLECTION_REQUIREMENT,
            ),
        )

        self.addCleanup(self.client.delete, collection_remote["pulp_href"])

        sync(self.cfg, collection_remote, repo, mirror=True)
        repo = self.client.get(repo["pulp_href"])
        added_content_summary = get_added_content_summary(repo)
        self.assertGreaterEqual(
            added_content_summary[ANSIBLE_COLLECTION_CONTENT_NAME],
            ANSIBLE_COLLECTION_FIXTURE_COUNT)

        content_summary = get_content_summary(repo)
        self.assertGreaterEqual(
            content_summary[ANSIBLE_COLLECTION_CONTENT_NAME],
            ANSIBLE_COLLECTION_FIXTURE_COUNT)
示例#11
0
    def test_rpm_kickstart(self):
        """Sync repositories with the rpm plugin.

        This test targets the following issue:


        `Pulp #5202 <https://pulp.plan.io/issues/5202>`_

        In order to sync a repository a remote has to be associated within
        this repository. When a repository is created this version field is set
        as None. After a sync the repository version is updated.

        Do the following:

        1. Create a repository and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Assert that the correct number of units were added and are present
           in the repo.
        6. Sync the remote one more time.
        7. Assert that repository version is the same the previous one.
        8. Assert that the same number of packages are present.
        """
        repo = self.client.post(RPM_REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['pulp_href'])

        # Create a remote with the standard test fixture url.
        body = gen_rpm_remote(url=RPM_KICKSTART_FIXTURE_URL)
        remote = self.client.post(RPM_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['pulp_href'])

        # Sync the repository.
        self.assertEqual(repo["latest_version_href"],
                         f"{repo['pulp_href']}versions/0/")
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['pulp_href'])
        for kickstart_content in get_content(repo)[RPM_KICKSTART_CONTENT_NAME]:
            self.addCleanup(self.client.delete, kickstart_content['pulp_href'])

        # Check that we have the correct content counts.
        self.assertIsNotNone(repo['latest_version_href'])

        self.assertDictEqual(get_content_summary(repo),
                             RPM_KICKSTART_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo),
                             RPM_KICKSTART_FIXTURE_SUMMARY)

        # Sync the repository again.
        latest_version_href = repo['latest_version_href']
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['pulp_href'])

        artifacts = self.client.get(ARTIFACTS_PATH)
        self.assertEqual(artifacts['count'], 4, artifacts)

        # Check that nothing has changed since the last sync.
        self.assertEqual(latest_version_href, repo['latest_version_href'])
        self.assertDictEqual(get_content_summary(repo),
                             RPM_KICKSTART_FIXTURE_SUMMARY)
示例#12
0
    def test_04_add_content(self):
        """Add content to the repository.

        Make roughly the same assertions as :meth:`test_02_sync_content`.
        """
        repo = self.client.get(self.repo["pulp_href"])
        modify_repo(self.cfg, self.repo, add_units=[self.content])
        repo = self.client.get(self.repo["pulp_href"])

        repo_versions = get_versions(repo)
        self.assertEqual(len(repo_versions), 4, repo_versions)

        self.assertIsNotNone(repo["latest_version_href"])

        content_hrefs = get_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(len(content_hrefs), FILE_FIXTURE_COUNT, content_hrefs)

        content = get_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(len(content), FILE_FIXTURE_COUNT)

        added_content = get_added_content(repo)[FILE_CONTENT_NAME]
        self.assertListEqual(added_content, [self.content], added_content)

        removed_content = get_removed_content(repo)[FILE_CONTENT_NAME]
        self.assertListEqual(removed_content, [], removed_content)

        content_summary = get_content_summary(repo)
        self.assertDictEqual(content_summary, FILE_FIXTURE_SUMMARY)

        content_added_summary = get_added_content_summary(repo)
        self.assertDictEqual(content_added_summary, {FILE_CONTENT_NAME: 1})

        content_removed_summary = get_removed_content_summary(repo)
        self.assertDictEqual(content_removed_summary, {})
示例#13
0
    def do_sync(self, download_policy):
        """Sync repositories with the different ``download_policy``.

        Do the following:

        1. Create a repository, and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Assert that the correct number of possible units to be downloaded
           were shown.
        6. Sync the remote one more time in order to create another repository
           version.
        7. Assert that repository version is different from the previous one.
        8. Assert that the same number of units are shown, and after the
           second sync no extra units should be shown, since the same remote
           was synced again.
        """
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        remote = self.client.post(
            RPM_REMOTE_PATH,
            gen_rpm_remote(policy=download_policy)
        )
        self.addCleanup(self.client.delete, remote['_href'])

        # Sync the repository.
        self.assertIsNone(repo['_latest_version_href'])
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['_href'])

        self.assertIsNotNone(repo['_latest_version_href'])
        self.assertDictEqual(get_content_summary(repo), RPM_FIXTURE_SUMMARY)
        self.assertDictEqual(
            get_added_content_summary(repo),
            RPM_FIXTURE_SUMMARY
        )

        # Sync the repository again.
        latest_version_href = repo['_latest_version_href']
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['_href'])

        self.assertNotEqual(latest_version_href, repo['_latest_version_href'])
        self.assertDictEqual(get_content_summary(repo), RPM_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo), {})
示例#14
0
    def test_sync(self):
        """Sync repositories with the ansible plugin.

        In order to sync a repository a remote has to be associated within
        this repository. When a repository is created this version field is set
        as None. After a sync the repository version is updated.

        Do the following:

        1. Create a repository, and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Assert that the correct number of units were added and are present in the repo.
        6. Sync the remote one more time.
        7. Assert that repository version is different from the previous one.
        8. Assert that the same number of are present and that no units were added.
        """
        repo = self.client.post(ANSIBLE_REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo["pulp_href"])

        body = gen_ansible_remote()
        remote = self.client.post(ANSIBLE_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote["pulp_href"])

        # Sync the repository.
        self.assertEqual(repo["latest_version_href"],
                         f"{repo['pulp_href']}versions/0/")
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo["pulp_href"])

        self.assertIsNotNone(repo["latest_version_href"])
        self.assertDictEqual(get_content_summary(repo),
                             ANSIBLE_FIXTURE_CONTENT_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo),
                             ANSIBLE_FIXTURE_CONTENT_SUMMARY)

        # Sync the repository again.
        latest_version_href = repo["latest_version_href"]
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo["pulp_href"])

        self.assertEqual(latest_version_href, repo["latest_version_href"])
        self.assertDictEqual(get_content_summary(repo),
                             ANSIBLE_FIXTURE_CONTENT_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo),
                             {"ansible.role": 5})
示例#15
0
    def test_sync_with_retention_and_modules(self):
        """Verify functionality with sync.

        Do the following:

        1. Create a repository, and a remote.
        2. Sync the remote.
        3. Assert that the correct number of units were added and are present in the repo.
        4. Change the "retain_package_versions" on the repository to 1 (retain the latest
           version only).
        5. Sync the remote one more time.
        6. Assert that repository version is the same as the previous one, because the older
           versions are part of modules, and they should be ignored by the retention policy.
        """
        delete_orphans()

        repo = self.repo_api.create(gen_repo())
        self.addCleanup(self.repo_api.delete, repo.pulp_href)

        remote = self.remote_api.create(
            gen_rpm_remote(
                url=RPM_MODULES_STATIC_CONTEXT_FIXTURE_URL,
                policy="on_demand",
            ))
        self.addCleanup(self.remote_api.delete, remote.pulp_href)

        task = self.sync(repository=repo, remote=remote, optimize=False)
        repo = self.repo_api.read(repo.pulp_href)

        self.addCleanup(delete_orphans)  # TODO: #2587

        # Test that, by default, everything is retained / nothing is tossed out.
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             RPM_MODULAR_STATIC_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo.to_dict()),
                             RPM_MODULAR_STATIC_FIXTURE_SUMMARY)
        # Test that the # of packages processed is correct
        reports = self.get_progress_reports_by_code(task)
        self.assertEqual(reports["sync.parsing.packages"].total,
                         RPM_MODULAR_PACKAGE_COUNT)
        self.assertEqual(reports["sync.skipped.packages"].total, 0)

        # Set the retention policy to retain only 1 version of each package
        repo_data = repo.to_dict()
        repo_data.update({"retain_package_versions": 1})
        self.repo_api.update(repo.pulp_href, repo_data)
        repo = self.repo_api.read(repo.pulp_href)

        task = self.sync(repository=repo, remote=remote, optimize=False)
        repo = self.repo_api.read(repo.pulp_href)

        # Test that no RPMs were removed (and no advisories etc. touched)
        # it should be the same because the older version are covered by modules)
        self.assertDictEqual(get_removed_content_summary(repo.to_dict()), {})
        # Test that the number of packages processed is correct
        reports = self.get_progress_reports_by_code(task)
        self.assertEqual(reports["sync.parsing.packages"].total,
                         RPM_MODULAR_PACKAGE_COUNT)
        self.assertEqual(reports["sync.skipped.packages"].total, 0)
示例#16
0
    def do_sync(self, download_policy):
        """Sync repositories with the different ``download_policy``.

        Do the following:

        1. Create a repository, and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Assert that the correct number of possible units to be downloaded
           were shown.
        6. Sync the remote one more time in order to create another repository
           version.
        7. Assert that repository version is different from the previous one.
        8. Assert that the same number of units are shown, and after the
           second sync no extra units should be shown, since the same remote
           was synced again.
        """
        # delete orphans to assure that no content units are present on the
        # file system
        delete_orphans(self.cfg)
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo["pulp_href"])

        body = gen_deb_remote(policy=download_policy)
        remote = self.client.post(DEB_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote["pulp_href"])

        # Sync the repository.
        self.assertIsNone(repo["latest_version_href"])
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo["pulp_href"])

        self.assertIsNotNone(repo["latest_version_href"])
        self.assertDictEqual(get_content_summary(repo), DEB_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo),
                             DEB_FIXTURE_SUMMARY)

        # Sync the repository again.
        latest_version_href = repo["latest_version_href"]
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo["pulp_href"])

        self.assertNotEqual(latest_version_href, repo["latest_version_href"])
        self.assertDictEqual(get_content_summary(repo), DEB_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo), {})
示例#17
0
    def test_sync_with_retention(self):
        """Verify functionality with sync.

        Do the following:

        1. Create a repository, and a remote.
        2. Sync the remote.
        3. Assert that the correct number of units were added and are present
           in the repo.
        4. Change the "retain_package_versions" on the repository to 1 (retain the latest
           version only).
        5. Sync the remote one more time.
        6. Assert that repository version is different from the previous one.
        7. Assert the repository version we end with has only one version of each package.
        """
        repo = self.repo_api.create(gen_repo())
        self.addCleanup(self.repo_api.delete, repo.pulp_href)

        remote = self.remote_api.create(gen_rpm_remote())
        self.addCleanup(self.remote_api.delete, remote.pulp_href)

        self.sync(repository=repo, remote=remote, optimize=False)
        repo = self.repo_api.read(repo.pulp_href)

        # Test that, by default, everything is retained / nothing is tossed out.
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             RPM_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo.to_dict()),
                             RPM_FIXTURE_SUMMARY)

        # Set the retention policy to retain only 1 version of each package
        repo_data = repo.to_dict()
        repo_data.update({"retain_package_versions": 1})
        self.repo_api.update(repo.pulp_href, repo_data)
        repo = self.repo_api.read(repo.pulp_href)

        self.sync(repository=repo, remote=remote, optimize=False)
        repo = self.repo_api.read(repo.pulp_href)

        # Test that only one version of each package is present
        self.assertTrue(
            self.check_retention_policy(
                get_content(repo.to_dict())[PULP_TYPE_PACKAGE], 1))
        # Test that (only) 4 RPMs were removed (no advisories etc. touched)
        self.assertDictEqual(get_removed_content_summary(repo.to_dict()),
                             {PULP_TYPE_PACKAGE: 4})
        # Test that the versions that were removed are the versions we expect.
        versions_for_packages = self.versions_for_packages(
            get_removed_content(repo.to_dict())[PULP_TYPE_PACKAGE])
        self.assertDictEqual(
            versions_for_packages,
            {
                "duck": ["0.6", "0.7"],
                "kangaroo": ["0.2"],
                "walrus": ["0.71"]
            },
            versions_for_packages,
        )
示例#18
0
    def _do_test(self, criteria, expected_results):
        """Test copying content units with the RPM plugin.

        Do the following:

        1. Create two repositories and a remote.
        2. Sync the remote.
        3. Assert that repository version is not None.
        4. Assert that the correct number of units were added and are present in the repo.
        5. Use the RPM copy API to units from the repo to the empty repo.
        7. Assert that the correct number of units were added and are present in the dest repo.
        """
        source_repo = self.client.post(RPM_REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, source_repo['pulp_href'])

        dest_repo = self.client.post(RPM_REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, dest_repo['pulp_href'])

        # Create a remote with the standard test fixture url.
        body = gen_rpm_remote()
        remote = self.client.post(RPM_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['pulp_href'])

        # Sync the repository.
        self.assertEqual(source_repo["latest_version_href"],
                         f"{source_repo['pulp_href']}versions/0/")
        sync(self.cfg, remote, source_repo)
        source_repo = self.client.get(source_repo['pulp_href'])

        # Check that we have the correct content counts.
        self.assertDictEqual(get_content_summary(source_repo),
                             RPM_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(source_repo),
                             RPM_FIXTURE_SUMMARY)

        rpm_copy(self.cfg, source_repo, dest_repo, criteria, recursive=True)
        dest_repo = self.client.get(dest_repo['pulp_href'])

        # Check that we have the correct content counts.
        self.assertDictEqual(get_content_summary(dest_repo), expected_results)
        self.assertDictEqual(
            get_added_content_summary(dest_repo),
            expected_results,
        )
示例#19
0
    def test_sync(self):
        """Sync repositories with the python plugin.

        In order to sync a repository a remote has to be associated within
        this repository. When a repository is created this version field is set
        as None. After a sync the repository version is updated.

        Do the following:

        1. Create a repository, and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Assert that the correct number of units were added and are present
           in the repo.
        6. Sync the remote one more time.
        7. Assert that repository version is different from the previous one.
        8. Assert that the same number of are present and that no units were
           added.
        """
        repo_api = RepositoriesPythonApi(self.client)
        remote_api = RemotesPythonApi(self.client)

        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

        body = gen_python_remote()
        remote = remote_api.create(body)
        self.addCleanup(remote_api.delete, remote.pulp_href)

        # Sync the repository.
        self.assertEqual(repo.latest_version_href, f"{repo.pulp_href}versions/0/")
        repository_sync_data = RepositorySyncURL(remote=remote.pulp_href)
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        repo = repo_api.read(repo.pulp_href)

        self.assertIsNotNone(repo.latest_version_href)
        self.assertDictEqual(
            get_content_summary(repo.to_dict()), PYTHON_XS_FIXTURE_SUMMARY
        )
        self.assertDictEqual(
            get_added_content_summary(repo.to_dict()), PYTHON_XS_FIXTURE_SUMMARY
        )

        # Sync the repository again.
        latest_version_href = repo.latest_version_href
        repository_sync_data = RepositorySyncURL(remote=remote.pulp_href)
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        repo = repo_api.read(repo.pulp_href)

        self.assertEqual(latest_version_href, repo.latest_version_href)
        self.assertDictEqual(
            get_content_summary(repo.to_dict()), PYTHON_XS_FIXTURE_SUMMARY
        )
示例#20
0
    def test_sync_from_valid_mirror_list_feed(self):
        """Sync RPM content from a mirror list feed which contains a valid remote URL."""
        remote = self.remote_api.create(gen_rpm_remote(RPM_MIRROR_LIST_GOOD_FIXTURE_URL))
        repo, remote = self.do_test(remote=remote)

        self.addCleanup(self.repo_api.delete, repo.pulp_href)
        self.addCleanup(self.remote_api.delete, remote.pulp_href)

        self.assertDictEqual(get_content_summary(repo.to_dict()), RPM_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo.to_dict()), RPM_FIXTURE_SUMMARY)
示例#21
0
    def test_sync(self):
        """Sync repositories with the plugin_template plugin.

        In order to sync a repository a remote has to be associated within
        this repository. When a repository is created this version field is set
        as None. After a sync the repository version is updated.

        Do the following:

        1. Create a repository, and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Sync the remote one more time.
        6. Assert that repository version is different from the previous one.
        """
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        body = gen_plugin_template_remote()
        remote = self.client.post(PLUGIN_TEMPLATE_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

        # Sync the repository.
        self.assertIsNone(repo['_latest_version_href'])
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['_href'])

        self.assertIsNotNone(repo['_latest_version_href'])
        self.assertDictEqual(get_content_summary(repo),
                             PLUGIN_TEMPLATE_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo),
                             PLUGIN_TEMPLATE_FIXTURE_SUMMARY)

        # Sync the repository again.
        latest_version_href = repo['_latest_version_href']
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['_href'])

        self.assertNotEqual(latest_version_href, repo['_latest_version_href'])
        self.assertDictEqual(get_content_summary(repo),
                             PLUGIN_TEMPLATE_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo), {})
示例#22
0
    def test_duplicate_file_sync(self):
        """Sync a repository with remotes containing same file names.

        This test does the following.

        1. Create a repository in pulp.
        2. Create two remotes containing the same file.
        3. Check whether the created repo has only one copy of the file.

        This test targets the following issue:

        `Pulp #4738 <https://pulp.plan.io/issues/4738>`_
        """
        repo_api = RepositoriesFileApi(self.client)
        remote_api = RemotesFileApi(self.client)

        # Step 1
        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

        # Step 2
        remote = remote_api.create(gen_file_remote())
        self.addCleanup(remote_api.delete, remote.pulp_href)
        remote2 = remote_api.create(
            gen_file_remote(url=FILE2_FIXTURE_MANIFEST_URL))

        self.addCleanup(remote_api.delete, remote2.pulp_href)
        repository_sync_data = RepositorySyncURL(remote=remote.pulp_href)
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        repo = repo_api.read(repo.pulp_href)
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             FILE_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo.to_dict()),
                             FILE_FIXTURE_SUMMARY)

        repository_sync_data = RepositorySyncURL(remote=remote2.pulp_href)
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        repo = repo_api.read(repo.pulp_href)
        self.assertDictEqual(get_added_content_summary(repo.to_dict()),
                             FILE_FIXTURE_SUMMARY)
示例#23
0
    def do_sync(self, download_policy):
        """Sync repositories with the different ``download_policy``.

        Do the following:

        1. Create a repository, and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Assert that the correct number of possible units to be downloaded
           were shown.
        6. Sync the remote one more time in order to create another repository
           version.
        7. Assert that repository version is the same as the previous one.
        8. Assert that the same number of units are shown, and after the
           second sync no extra units should be shown, since the same remote
           was synced again.
        """
        # delete orphans to assure that no content units are present on the
        # file system
        delete_orphans()
        repo_api = deb_repository_api
        remote_api = deb_remote_api

        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

        body = gen_deb_remote(policy=download_policy)
        remote = remote_api.create(body)
        self.addCleanup(remote_api.delete, remote.pulp_href)

        # Sync the repository.
        self.assertEqual(repo.latest_version_href,
                         f"{repo.pulp_href}versions/0/")
        repository_sync_data = RepositorySyncURL(remote=remote.pulp_href)
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        repo = repo_api.read(repo.pulp_href)

        self.assertIsNotNone(repo.latest_version_href)
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             DEB_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo.to_dict()),
                             DEB_FIXTURE_SUMMARY)

        # Sync the repository again.
        latest_version_href = repo.latest_version_href
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        repo = repo_api.read(repo.pulp_href)

        self.assertEqual(latest_version_href, repo.latest_version_href)
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             DEB_FIXTURE_SUMMARY)
示例#24
0
    def do_sync(self, sync_udebs, fixture_summary):
        """Sync repositories with the deb plugin.

        In order to sync a repository a remote has to be associated within
        this repository. When a repository is created this version field is set
        as None. After a sync the repository version is updated.

        Do the following:

        1. Create a repository, and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Assert that the correct number of units were added and are present
           in the repo.
        6. Sync the remote one more time.
        7. Assert that repository version is the same as the previous one.
        8. Assert that the same number of content units are present and that no
           units were added.
        """
        repo_api = deb_repository_api
        remote_api = deb_remote_api

        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

        body = gen_deb_remote(sync_udebs=sync_udebs, gpgkey=DEB_SIGNING_KEY)
        remote = remote_api.create(body)
        self.addCleanup(remote_api.delete, remote.pulp_href)

        # Sync the repository.
        self.assertEqual(repo.latest_version_href,
                         f"{repo.pulp_href}versions/0/")
        repository_sync_data = RepositorySyncURL(remote=remote.pulp_href)
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        repo = repo_api.read(repo.pulp_href)

        self.assertIsNotNone(repo.latest_version_href)
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             fixture_summary)
        self.assertDictEqual(get_added_content_summary(repo.to_dict()),
                             fixture_summary)

        # Sync the repository again.
        latest_version_href = repo.latest_version_href
        repository_sync_data = RepositorySyncURL(remote=remote.pulp_href)
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        repo = repo_api.read(repo.pulp_href)

        self.assertEqual(latest_version_href, repo.latest_version_href)
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             fixture_summary)
示例#25
0
    def test_sync(self):
        """Sync repositories with the deb plugin.

        In order to sync a repository a remote has to be associated within
        this repository. When a repository is created this version field is set
        as None. After a sync the repository version is updated.

        Do the following:

        1. Create a repository, and a remote.
        2. Assert that repository version is None.
        3. Sync the remote.
        4. Assert that repository version is not None.
        5. Sync the remote one more time.
        6. Assert that repository version is different from the previous one.
        """
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        body = gen_deb_remote()
        remote = self.client.post(DEB_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

        # Sync the repository.
        self.assertIsNone(repo['_latest_version_href'])
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['_href'])

        self.assertIsNotNone(repo['_latest_version_href'])
        self.assertDictEqual(get_content_summary(repo), DEB_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo), DEB_FIXTURE_SUMMARY)

        # Sync the repository again.
        latest_version_href = repo['_latest_version_href']
        sync(self.cfg, remote, repo)
        repo = self.client.get(repo['_href'])

        self.assertNotEqual(latest_version_href, repo['_latest_version_href'])
        self.assertDictEqual(get_content_summary(repo), DEB_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo), {})
示例#26
0
 def test_package_upload_simple(self):
     """Tests that the package upload endpoint exposed at `/simple/` works."""
     repo, distro = self._create_empty_repo_and_distribution()
     url = urljoin(PYPI_HOST, distro.base_path + "/simple/")
     response = requests.post(
         url,
         data={"sha256_digest": PYTHON_EGG_SHA256},
         files={"content": open(self.egg, "rb")},
     )
     self.assertEqual(response.status_code, 200)
     task = response.json()["task"]
     monitor_task(task)
     content = get_added_content_summary(repo, f"{repo.versions_href}1/")
     self.assertDictEqual({PYTHON_CONTENT_NAME: 1}, content)
示例#27
0
    def test_kickstarter(self):
        """Sync repositories with the rpm plugin.

        This test targets the following issue:

        `Pulp #5202 <https://pulp.plan.io/issues/5202>`_

        In order to sync a repository a remote has to be associated within
        this repository.

        Do the following:

        1. Create a remote.
        2. Sync the remote. (repo will be created automatically)
        3. Assert that the correct number of units were added and are present
           in the repo.
        4. Sync the remote one more time.
        5. Assert that repository version is the same the previous one.
        6. Assert that the same number of packages are present.
        """
        body = gen_rpm_remote(RPM_KICKSTART_FIXTURE_URL)
        remote = self.remote_api.create(body)

        # sync
        repo, remote = self.do_test(remote=remote)

        # add resources to clean up
        self.addCleanup(self.repo_api.delete, repo.pulp_href)
        self.addCleanup(self.remote_api.delete, remote.pulp_href)

        # Check that we have the correct content counts.
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             RPM_KICKSTART_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo.to_dict()),
                             RPM_KICKSTART_FIXTURE_SUMMARY)

        latest_version_href = repo.latest_version_href

        # sync again
        repo, remote = self.do_test(repository=repo, remote=remote)

        # Test distribution tree API
        dist_tree_api = ContentDistributionTreesApi(self.client)
        self.assertEqual(dist_tree_api.list().results[0].release_short, "RHEL")

        # Check that nothing has changed since the last sync.
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             RPM_KICKSTART_FIXTURE_SUMMARY)
        self.assertEqual(latest_version_href, repo.latest_version_href)
示例#28
0
    def test_02_sync_content(self):
        """Sync content into the repository.

        Assert that:

        * The ``_versions_href`` API call is correct.
        * The ``_latest_version_href`` API call is correct.
        * The ``content_hrefs`` attribute is correct.
        * The ``content_added_hrefs`` attribute is correct.
        * The ``content_removed_hrefs`` attribute is correct.
        * The ``content_summary`` attribute is correct.
        * The ``content_added_summary`` attribute is correct.
        * The ``content_removed_summary`` attribute is correct.
        """
        body = gen_file_remote()
        self.remote.update(self.client.post(FILE_REMOTE_PATH, body))
        sync(self.cfg, self.remote, self.repo)
        repo = self.client.get(self.repo['_href'])

        repo_versions = get_versions(repo)
        self.assertEqual(len(repo_versions), 1, repo_versions)

        self.assertIsNotNone(repo['_latest_version_href'])

        content_hrefs = get_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(
            len(content_hrefs), FILE_FIXTURE_COUNT, content_hrefs
        )

        content = get_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(len(content), FILE_FIXTURE_COUNT)

        content_added = get_added_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(len(content_added), FILE_FIXTURE_COUNT)

        content_removed = get_removed_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(len(content_removed), 0)

        content_summary = get_content_summary(repo)
        self.assertDictEqual(content_summary, FILE_FIXTURE_SUMMARY)

        content_added_summary = get_added_content_summary(repo)
        self.assertDictEqual(content_added_summary, FILE_FIXTURE_SUMMARY)

        content_removed_summary = get_removed_content_summary(repo)
        self.assertDictEqual(content_removed_summary, {})
示例#29
0
    def test_copy_all(self):
        """Test copying all the content from one repo to another."""
        source_repo, dest_repo = self._setup_repos()
        results = RPM_FIXTURE_SUMMARY
        config = [{
            'source_repo_version': source_repo['latest_version_href'],
            'dest_repo': dest_repo['pulp_href'],
        }]

        rpm_copy(self.cfg, config)
        dest_repo = self.client.get(dest_repo['pulp_href'])

        # Check that we have the correct content counts.
        self.assertDictEqual(get_content_summary(dest_repo), results)
        self.assertDictEqual(
            get_added_content_summary(dest_repo), results,
        )
示例#30
0
    def test_simple_copy_distribution_tree(self):
        """Sync repository with a distribution tree."""
        source_repo = self.do_sync(RPM_KICKSTART_FIXTURE_URL)
        dest_repo = self.repo_api.create(gen_repo()).to_dict()
        self.addCleanup(self.repo_api.delete, dest_repo["pulp_href"])

        config = [{
            "source_repo_version": source_repo["latest_version_href"],
            "dest_repo": dest_repo["pulp_href"],
        }]

        rpm_copy(self.cfg, config, recursive=True)
        dest_repo = self.repo_api.read(dest_repo["pulp_href"]).to_dict()

        self.assertEqual(
            get_added_content_summary(dest_repo)[PULP_TYPE_DISTRIBUTION_TREE],
            1)
示例#31
0
    def test_sync_modular(self):
        """Sync RPM modular content.

        This test targets the following issue:

        * `Pulp #5408 <https://pulp.plan.io/issues/5408>`_
        """
        body = gen_rpm_remote(RPM_MODULAR_FIXTURE_URL)
        remote = self.remote_api.create(body)

        repo, remote = self.do_test(remote=remote)

        self.addCleanup(self.repo_api.delete, repo.pulp_href)
        self.addCleanup(self.remote_api.delete, remote.pulp_href)

        self.assertDictEqual(get_content_summary(repo.to_dict()), RPM_MODULAR_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo.to_dict()), RPM_MODULAR_FIXTURE_SUMMARY)
示例#32
0
    def test_02_sync_content(self):
        """Sync content into the repository.

        Assert that:

        * The ``versions_href`` API call is correct.
        * The ``latest_version_href`` API call is correct.
        * The ``content_hrefs`` attribute is correct.
        * The ``content_added_hrefs`` attribute is correct.
        * The ``content_removed_hrefs`` attribute is correct.
        * The ``content_summary`` attribute is correct.
        * The ``content_added_summary`` attribute is correct.
        * The ``content_removed_summary`` attribute is correct.
        """
        body = gen_file_remote()
        self.remote.update(self.client.post(FILE_REMOTE_PATH, body))
        sync(self.cfg, self.remote, self.repo)
        repo = self.client.get(self.repo['pulp_href'])

        repo_versions = get_versions(repo)
        self.assertEqual(len(repo_versions), 2, repo_versions)

        self.assertIsNotNone(repo['latest_version_href'])

        content_hrefs = get_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(
            len(content_hrefs), FILE_FIXTURE_COUNT, content_hrefs
        )

        content = get_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(len(content), FILE_FIXTURE_COUNT)

        content_added = get_added_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(len(content_added), FILE_FIXTURE_COUNT)

        content_removed = get_removed_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(len(content_removed), 0)

        content_summary = get_content_summary(repo)
        self.assertDictEqual(content_summary, FILE_FIXTURE_SUMMARY)

        content_added_summary = get_added_content_summary(repo)
        self.assertDictEqual(content_added_summary, FILE_FIXTURE_SUMMARY)

        content_removed_summary = get_removed_content_summary(repo)
        self.assertDictEqual(content_removed_summary, {})
示例#33
0
    def _do_test(self, criteria, expected_results):
        """Test copying content units with the RPM plugin.

        Do the following:
        1. start with standard repo-setup
        2. Use the RPM copy API to units from the repo to the empty repo.
        3. Assert that the correct number of units were added and are present in the dest repo.
        """
        source_repo, dest_repo = self._setup_repos()
        rpm_copy(self.cfg, source_repo, dest_repo, criteria, recursive=True)
        dest_repo = self.client.get(dest_repo["pulp_href"])

        # Check that we have the correct content counts.
        self.assertDictEqual(get_content_summary(dest_repo), expected_results)
        self.assertDictEqual(
            get_added_content_summary(dest_repo),
            expected_results,
        )
示例#34
0
    def test_sync_modular_repo(self):
        """Test RPM modular content can be synced."""
        cfg = config.get_config()
        client = api.Client(cfg)

        remote = client.post(RPM_REMOTE_PATH,
                             gen_rpm_remote(url=RPM_MODULAR_FIXTURE_URL))
        self.addCleanup(client.delete, remote['pulp_href'])

        repo = client.post(RPM_REPO_PATH, gen_repo())
        self.addCleanup(client.delete, repo['pulp_href'])

        sync(cfg, remote, repo)
        repo = client.get(repo['pulp_href'])

        added_content_summary = get_added_content_summary(repo)

        self.assertEqual(added_content_summary, RPM_MODULAR_FIXTURE_SUMMARY,
                         added_content_summary)
示例#35
0
    def test_03_remove_content(self):
        """Remove content from the repository.

        Make roughly the same assertions as :meth:`test_02_sync_content`.
        """
        repo = self.client.get(self.repo['_href'])
        self.content.update(choice(get_content(repo)[FILE_CONTENT_NAME]))
        self.client.post(
            repo['_versions_href'],
            {'remove_content_units': [self.content['_href']]}
        )
        repo = self.client.get(self.repo['_href'])

        repo_versions = get_versions(repo)
        self.assertEqual(len(repo_versions), 2, repo_versions)

        self.assertIsNotNone(repo['_latest_version_href'])

        content_hrefs = get_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(
            len(content_hrefs), FILE_FIXTURE_COUNT - 1, content_hrefs
        )

        content = get_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(len(content), FILE_FIXTURE_COUNT - 1)

        added_content = get_added_content(repo)[FILE_CONTENT_NAME]
        self.assertListEqual(added_content, [], added_content)

        removed_content = get_removed_content(repo)[FILE_CONTENT_NAME]
        self.assertListEqual(removed_content, [self.content], removed_content)

        content_summary = get_content_summary(repo)
        self.assertDictEqual(
            content_summary, {FILE_CONTENT_NAME: FILE_FIXTURE_COUNT - 1}
        )

        content_added_summary = get_added_content_summary(repo)
        self.assertDictEqual(content_added_summary, {})

        content_removed_summary = get_removed_content_summary(repo)
        self.assertDictEqual(content_removed_summary, {FILE_CONTENT_NAME: 1})
示例#36
0
    def test_04_add_content(self):
        """Add content to the repository.

        Make roughly the same assertions as :meth:`test_02_sync_content`.
        """
        repo = self.client.get(self.repo['_href'])
        self.client.post(
            repo['_versions_href'],
            {'add_content_units': [self.content['_href']]}
        )
        repo = self.client.get(self.repo['_href'])

        repo_versions = get_versions(repo)
        self.assertEqual(len(repo_versions), 3, repo_versions)

        self.assertIsNotNone(repo['_latest_version_href'])

        content_hrefs = get_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(
            len(content_hrefs), FILE_FIXTURE_COUNT, content_hrefs
        )

        content = get_content(repo)[FILE_CONTENT_NAME]
        self.assertEqual(len(content), FILE_FIXTURE_COUNT)

        added_content = get_added_content(repo)[FILE_CONTENT_NAME]
        self.assertListEqual(added_content, [self.content], added_content)

        removed_content = get_removed_content(repo)[FILE_CONTENT_NAME]
        self.assertListEqual(removed_content, [], removed_content)

        content_summary = get_content_summary(repo)
        self.assertDictEqual(content_summary, FILE_FIXTURE_SUMMARY)

        content_added_summary = get_added_content_summary(repo)
        self.assertDictEqual(content_added_summary, {FILE_CONTENT_NAME: 1})

        content_removed_summary = get_removed_content_summary(repo)
        self.assertDictEqual(content_removed_summary, {})
示例#37
0
    def test_02_including_prereleases(self):
        """
        Sync a Remote, including prereleases.

        Do the following:

        1. Update the remote to include pre-releases.
        2. Sync the remote again.
        3. Assert that the content counts in the repo match *all* the packages matched by the
           specifier, including prereleases.

        """
        body = {'prereleases': True}
        self.client.patch(self.remote['_href'], body)
        type(self).remote = self.client.get(self.remote['_href'])

        sync(self.cfg, self.remote, self.repo)
        type(self).repo = self.client.get(self.repo['_href'])

        self.assertEqual(get_content_summary(self.repo), PYTHON_WITH_PRERELEASE_FIXTURE_SUMMARY)
        self.assertEqual(
            get_added_content_summary(self.repo)[PYTHON_CONTENT_NAME],
            PYTHON_WITH_PRERELEASE_COUNT - PYTHON_WITHOUT_PRERELEASE_COUNT
        )