Пример #1
0
    def test_basic_pulp_to_pulp_sync(self):
        """
        This test checks that the JSON endpoint is setup correctly to allow one Pulp instance
        to perform a basic sync from another Pulp instance
        """
        self.addCleanup(self.repo_api.delete, self.repo.pulp_href)
        body = gen_python_remote(includes=PYTHON_LG_PROJECT_SPECIFIER,
                                 policy="on_demand",
                                 prereleases=True)
        self.sync_to_remote(body, create=True)
        self.addCleanup(self.remote_api.delete, self.remote.pulp_href)
        self.assertEqual(get_content_summary(self.repo.to_dict()),
                         PYTHON_LG_FIXTURE_SUMMARY)
        distro = self.gen_pub_dist().to_dict()
        url_fragments = [
            self.cfg.get_content_host_base_url(), "pulp/content",
            distro["base_path"], ""
        ]
        unit_url = "/".join(url_fragments)

        repo2 = self.repo_api.create(gen_repo())
        self.addCleanup(self.repo_api.delete, repo2.pulp_href)
        body2 = gen_python_remote(url=unit_url,
                                  includes=PYTHON_LG_PROJECT_SPECIFIER,
                                  policy="on_demand",
                                  prereleases=True)
        self.repo = repo2
        self.sync_to_remote(body2, create=True)
        self.assertEqual(get_content_summary(self.repo.to_dict()),
                         PYTHON_LG_FIXTURE_SUMMARY)
        self.addCleanup(self.remote_api.delete, self.remote.pulp_href)
Пример #2
0
 def test_excludes_with_bad_version(self):
     """
     Test an exclude specifier with an invalid "version_specifier" field value.
     """
     body = gen_python_remote(excludes=PYTHON_INVALID_SPECIFIER_BAD_VERSION)
     with self.assertRaises(HTTPError):
         self.client.post(PYTHON_REMOTE_PATH, body)
Пример #3
0
 def test_excludes_with_no_name(self):
     """
     Test an exclude specifier without a "name" field.
     """
     body = gen_python_remote(excludes=PYTHON_INVALID_SPECIFIER_NO_NAME)
     with self.assertRaises(HTTPError):
         self.client.post(PYTHON_REMOTE_PATH, body)
Пример #4
0
    def test_file_decriptors(self):
        """Test whether file descriptors are closed properly.

        This test targets the following issue:
        `Pulp #4073 <https://pulp.plan.io/issues/4073>`_

        Do the following:
        1. Check if 'lsof' is installed. If it is not, skip this test.
        2. Create and sync a repo.
        3. Run the 'lsof' command to verify that files in the
           path ``/var/lib/pulp/`` are closed after the sync.
        4. Assert that issued command returns `0` opened files.
        """
        cli_client = cli.Client(self.cfg, cli.echo_handler)

        # check if 'lsof' is available
        if cli_client.run(('which', 'lsof')).returncode != 0:
            raise unittest.SkipTest('lsof package is not present')

        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        remote = self.client.post(PYTHON_REMOTE_PATH, gen_python_remote())
        self.addCleanup(self.client.delete, remote['_href'])

        sync(self.cfg, remote, repo)

        cmd = 'lsof -t +D {}'.format(MEDIA_PATH).split()
        response = cli_client.run(cmd).stdout
        self.assertEqual(len(response), 0, response)
Пример #5
0
    def test_on_demand(self):
        """Test whether a particular repository version can be published.

        1. Create a repository
        2. Create a remote with on_demand sync policy
        3. Sync
        4. Publish repository
        """
        client = gen_python_client()
        repo_api = RepositoriesPythonApi(client)
        remote_api = RemotesPythonApi(client)
        publications = PublicationsPypiApi(client)

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

        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.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)

        publish_data = PythonPythonPublication(repository=repo.pulp_href)
        publish_response = publications.create(publish_data)
        created_resources = monitor_task(publish_response.task).created_resources
        publication_href = created_resources[0]
        self.addCleanup(publications.delete, publication_href)
        publication = publications.read(publication_href)

        self.assertEqual(publication.repository_version, repo.latest_version_href)
Пример #6
0
    def test_workflow_02(self):
        """
        Verify workflow 2

        Do the following:

        1. Create, populate, publish, and distribute a repository.
        2. Pip install a package from the pulp repository.
        3. Check pip install was successful.

        This test targets the following issues:
        * `Pulp #4682 <https://pulp.plan.io/issues/4682>`_
        * `Pulp #4677 <https://pulp.plan.io/issues/4677>`_
        """
        repo = self.repo_api.create(gen_repo())
        self.addCleanup(self.repo_api.delete, repo.pulp_href)

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

        repository_sync_data = RepositorySyncURL(remote=remote.pulp_href)
        sync_response = self.repo_api.sync(repo.pulp_href,
                                           repository_sync_data)
        monitor_task(sync_response.task)
        repo = self.repo_api.read(repo.pulp_href)

        distribution = self.gen_pub_dist(repo)
        self.check_consume(distribution.to_dict())
Пример #7
0
    def test_all(self):
        """
        Test whether content unit used by a repo version can be deleted.

        Do the following:

        1. Sync content to a repository.
        2. Attempt to delete a content unit present in a repository version.
           Assert that a HTTP exception was raised.
        3. Assert that number of content units present on the repository
           does not change after the attempt to delete one content unit.

        """
        cfg = config.get_config()
        client = api.Client(cfg, api.json_handler)

        body = gen_python_remote(PYTHON_FIXTURES_URL)
        remote = client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(client.delete, remote['_href'])

        repo = client.post(REPO_PATH, gen_repo())
        self.addCleanup(client.delete, repo['_href'])

        sync(cfg, remote, repo)

        repo = client.get(repo['_href'])
        content = get_content(repo)
        with self.assertRaises(HTTPError):
            client.delete(choice(content)['_href'])
        self.assertEqual(len(content), len(get_content(repo)))
Пример #8
0
    def test_exclude_unavailable_projects(self):
        """
        Test that sync doesn't fail if some of the excluded projects aren't available.

        Do the following:

        1. Update the remote to exclude a specifier that is smaller than the previous one.
        2. Sync the remote again.
        3. Assert that the content counts in the repo have increased again, to the count
           of the smaller excludes specifier.

        """
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        body = gen_python_remote(includes=PYTHON_MD_PROJECT_SPECIFIER,
                                 excludes=PYTHON_UNAVAILABLE_PROJECT_SPECIFIER)
        remote = self.client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

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

        self.assertEqual(
            get_content_summary(repo)[PYTHON_CONTENT_NAME],
            PYTHON_MD_PACKAGE_COUNT - PYTHON_UNAVAILABLE_PACKAGE_COUNT)
Пример #9
0
    def test_exclude_unavailable_projects(self):
        """
        Test that sync doesn't fail if some of the excluded projects aren't available.

        Do the following:

        1. Update the remote to exclude a specifier that is smaller than the previous one.
        2. Sync the remote again.
        3. Assert that the content counts in the repo have increased again, to the count
           of the smaller excludes specifier.

        """
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        body = gen_python_remote(
            includes=PYTHON_MD_PROJECT_SPECIFIER,
            excludes=PYTHON_UNAVAILABLE_PROJECT_SPECIFIER
        )
        remote = self.client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

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

        self.assertEqual(
            get_content_summary(repo)[PYTHON_CONTENT_NAME],
            PYTHON_MD_PACKAGE_COUNT - PYTHON_UNAVAILABLE_PACKAGE_COUNT
        )
Пример #10
0
 def test_excludes_with_no_name(self):
     """
     Test an exclude specifier without a "name" field.
     """
     body = gen_python_remote(excludes=PYTHON_INVALID_SPECIFIER_NO_NAME)
     with self.assertRaises(ApiException):
         self.remote_api.create(body)
Пример #11
0
    def test_include_unavailable_projects(self):
        """
        Test that the sync doesn't fail if some included projects aren't available.

        Do the following:

        1. Create a remote.
        2. Sync the remote.
        3. Assert that the content counts in the repo match the correct count for the specifier.

        """
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        body = gen_python_remote(includes=PYTHON_UNAVAILABLE_PROJECT_SPECIFIER)
        remote = self.client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

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

        self.assertEqual(
            get_content_summary(repo)[PYTHON_CONTENT_NAME],
            PYTHON_UNAVAILABLE_PACKAGE_COUNT
        )
Пример #12
0
 def test_excludes_with_bad_version(self):
     """
     Test an exclude specifier with an invalid "version_specifier" field value.
     """
     body = gen_python_remote(excludes=PYTHON_INVALID_SPECIFIER_BAD_VERSION)
     with self.assertRaises(ApiException):
         self.remote_api.create(body)
Пример #13
0
 def setUpClass(cls):
     """
     Create class-wide variables.
     """
     cls.remote_api = RemotesPythonApi(gen_python_client())
     cls.remote = cls.remote_api.create(gen_python_remote())
     cls._original_remote = cls.remote
Пример #14
0
 def test_pypi_json(self):
     """Checks the basics 'pypi/{package_name}/json' endpoint
     Steps:
         1. Create Repo and Remote to only sync shelf-reader
         2. Sync with immediate policy
         3. Publish and Distribute new Repo
         4. Access JSON endpoint and verify received JSON matches source
     """
     self.addCleanup(self.repo_api.delete, self.repo.pulp_href)
     body = gen_python_remote(includes=["shelf-reader"], policy="immediate")
     self.sync_to_remote(body, create=True)
     self.addCleanup(self.remote_api.delete, self.remote.pulp_href)
     distro = self.gen_pub_dist()
     rel_url = "pypi/shelf-reader/json"
     package_json = download_content_unit(self.cfg, distro.to_dict(),
                                          rel_url)
     package = json.loads(package_json)
     self.assertEqual(SHELF_PYTHON_JSON["last_serial"],
                      package["last_serial"])
     self.assertTrue(
         SHELF_PYTHON_JSON["info"].items() <= package["info"].items())
     self.assertEqual(len(SHELF_PYTHON_JSON["urls"]), len(package["urls"]))
     self.assert_download_info(SHELF_PYTHON_JSON["urls"], package["urls"],
                               "Failed to match URLS")
     self.assertTrue(
         SHELF_PYTHON_JSON["releases"].keys() <= package["releases"].keys())
     for version in SHELF_PYTHON_JSON["releases"].keys():
         self.assert_download_info(SHELF_PYTHON_JSON["releases"][version],
                                   package["releases"][version],
                                   "Failed to match version")
Пример #15
0
    def test_workflow_02(self):
        """
        Verify workflow 2

        Do the following:

        1. Create, populate, publish, and distribute a repository.
        2. Pip install a package from the pulp repository.
        3. Check pip install was successful.

        This test targets the following issues:
        * `Pulp #4682 <https://pulp.plan.io/issues/4682>`_
        * `Pulp #4677 <https://pulp.plan.io/issues/4677>`_
        """
        repo = self.client.post(PYTHON_REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo["pulp_href"])

        body = gen_python_remote(PYTHON_FIXTURES_URL,
                                 includes=PYTHON_LIST_PROJECT_SPECIFIER)
        remote = self.client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote["pulp_href"])

        sync(self.cfg, remote, repo)
        repo = self.client.get(repo["pulp_href"])
        distribution = self.gen_pub_dist(repo)
        self.check_consume(distribution)
Пример #16
0
    def test_on_demand_pypi_full_sync(self):
        """This test syncs all of PyPi"""
        repo_api = RepositoriesPythonApi(self.client)
        remote_api = RemotesPythonApi(self.client)
        tasks_api = TasksApi(self.core_client)

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

        body = gen_python_remote("https://pypi.org", includes=[], policy="on_demand")
        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)

        sync_task = tasks_api.read(sync_response.task)
        time_diff = sync_task.finished_at - sync_task.started_at
        print("Delete time: {} seconds".format(time_diff.seconds))

        self.assertIsNotNone(repo.latest_version_href)
        # As of August 11 2020, all_packages() returns 253,587 packages,
        # only 248,677 of them were downloadable
        self.assertTrue(get_content_summary(repo.to_dict())[PYTHON_CONTENT_NAME] > 245000)
Пример #17
0
 def test_excludes_with_bad_version(self):
     """
     Test an exclude specifier with an invalid "version_specifier" field value.
     """
     body = gen_python_remote(excludes=PYTHON_INVALID_SPECIFIER_BAD_VERSION)
     with self.assertRaises(HTTPError):
         self.client.post(PYTHON_REMOTE_PATH, body)
Пример #18
0
 def test_excludes_with_no_name(self):
     """
     Test an exclude specifier without a "name" field.
     """
     body = gen_python_remote(excludes=PYTHON_INVALID_SPECIFIER_NO_NAME)
     with self.assertRaises(HTTPError):
         self.client.post(PYTHON_REMOTE_PATH, body)
Пример #19
0
    def test_file_decriptors(self):
        """Test whether file descriptors are closed properly.

        This test targets the following issue:
        `Pulp #4073 <https://pulp.plan.io/issues/4073>`_

        Do the following:
        1. Check if 'lsof' is installed. If it is not, skip this test.
        2. Create and sync a repo.
        3. Run the 'lsof' command to verify that files in the
           path ``/var/lib/pulp/`` are closed after the sync.
        4. Assert that issued command returns `0` opened files.
        """
        cli_client = cli.Client(self.cfg, cli.echo_handler)

        # check if 'lsof' is available
        if cli_client.run(('which', 'lsof')).returncode != 0:
            raise unittest.SkipTest('lsof package is not present')

        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        remote = self.client.post(PYTHON_REMOTE_PATH, gen_python_remote())
        self.addCleanup(self.client.delete, remote['_href'])

        sync(self.cfg, remote, repo)

        cmd = 'lsof -t +D {}'.format(MEDIA_PATH).split()
        response = cli_client.run(cmd).stdout
        self.assertEqual(len(response), 0, response)
Пример #20
0
    def test_all(self):
        """
        Test whether a particular repository version can be published.

        1. Create a repository with at least 2 repository versions.
        2. Create a publication by supplying the latest ``repository_version``.
        3. Assert that the publication ``repository_version`` attribute points
           to the latest repository version.
        4. Create a publication by supplying the non-latest
           ``repository_version``.
        5. Assert that the publication ``repository_version`` attribute points
           to the supplied repository version.
        6. Assert that an exception is raised when providing two different
           repository versions to be published at same time.

        """
        body = gen_python_remote(PYTHON_FIXTURES_URL)
        remote = self.client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        sync(self.cfg, remote, repo)

        publisher = self.client.post(PYTHON_PUBLISHER_PATH,
                                     gen_python_publisher())
        self.addCleanup(self.client.delete, publisher['_href'])

        # Step 1
        repo = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])
        for python_content in self.client.get(PYTHON_CONTENT_PATH)['results']:
            self.client.post(repo['_versions_href'],
                             {'add_content_units': [python_content['_href']]})
        versions = get_versions(repo)
        non_latest = choice(versions[:-1])['_href']

        # Step 2
        publication = publish(self.cfg, publisher, repo)

        # Step 3
        self.assertEqual(publication['repository_version'],
                         versions[-1]['_href'])

        # Step 4
        publication = publish(self.cfg, publisher, repo, non_latest)

        # Step 5
        self.assertEqual(publication['repository_version'], non_latest)

        # Step 6
        with self.assertRaises(HTTPError):
            body = {
                'repository': repo['_href'],
                'repository_version': non_latest
            }
            self.client.post(urljoin(publisher['_href'], 'publish/'), body)
Пример #21
0
    def test_excludes_with_no_version(self):
        """
        Test an exclude specifier without a "version_specifier" field.
        """
        body = gen_python_remote(excludes=PYTHON_VALID_SPECIFIER_NO_VERSION)
        remote = self.client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

        self.assertEqual(remote['includes'][0]['version_specifier'], "")
Пример #22
0
    def test_excludes_with_no_version(self):
        """
        Test an exclude specifier without a "version_specifier" field.
        """
        body = gen_python_remote(excludes=PYTHON_VALID_SPECIFIER_NO_VERSION)
        remote = self.client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(self.client.delete, remote['_href'])

        self.assertEqual(remote['includes'][0]['version_specifier'], "")
Пример #23
0
    def setUpClass(cls):
        """
        Create class-wide variables.
        """
        cls.cfg = config.get_config()
        cls.client = api.Client(cls.cfg, api.json_handler)

        cls.remote = cls.client.post(PYTHON_REMOTE_PATH, gen_python_remote())
        cls._original_remote = cls.remote
Пример #24
0
    def setUpClass(cls):
        """
        Create class-wide variables.
        """
        cls.cfg = config.get_config()
        cls.client = api.Client(cls.cfg, api.json_handler)

        cls.remote = cls.client.post(PYTHON_REMOTE_PATH, gen_python_remote())
        cls._original_remote = cls.remote
Пример #25
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
        )
Пример #26
0
    def test_02_create_same_name(self):
        """Try to create a second remote with an identical name.

        See: `Pulp Smash #1055
        <https://github.com/pulp/pulp-smash/issues/1055>`_.
        """
        body = gen_python_remote()
        body["name"] = self.remote.name
        with self.assertRaises(ApiException):
            self.remote_api.create(body)
Пример #27
0
    def test_includes_with_no_version(self):
        """
        Test an include specifier without a "version_specifier" field.
        """
        body = gen_python_remote(includes=PYTHON_VALID_SPECIFIER_NO_VERSION)
        remote = self.remote_api.create(body).to_dict()
        self.addCleanup(self.remote_api.delete, remote["pulp_href"])

        self.assertEqual(remote["includes"][0],
                         PYTHON_VALID_SPECIFIER_NO_VERSION[0])
Пример #28
0
    def test_both_together_sync(self):
        """Checks that specifying sdist and bdist_wheel gets all packages"""
        body = gen_python_remote(
            includes=PYTHON_LG_PROJECT_SPECIFIER,
            package_types=["bdist_wheel", "sdist"],
            prereleases=True,
        )
        sync_to_remote(self, body, create=True)

        self.assertEqual(get_content_summary(self.repo.to_dict()),
                         PYTHON_LG_FIXTURE_SUMMARY)
Пример #29
0
    def test_all(self):
        """Verify whether is possible to create a remote without a URL.

        This test targets the following issues:

        * `Pulp #3395 <https://pulp.plan.io/issues/3395>`_
        * `Pulp Smash #984 <https://github.com/pulp/pulp-smash/issues/984>`_
        """
        body = gen_python_remote()
        del body["url"]
        with self.assertRaises(ApiException):
            RemotesPythonApi(gen_python_client()).create(body)
Пример #30
0
    def test_no_platform_sync(self):
        """Tests that no package specified for a platform is synced"""
        body = gen_python_remote(
            includes=["scipy"],
            exclude_platforms=["linux", "windows", "macos", "freebsd"],
            prereleases=True,
        )
        sync_to_remote(self, body, create=True)

        self.assertEqual(
            get_content_summary(self.repo.to_dict())[PYTHON_CONTENT_NAME],
            SCIPY_COUNTS["no_os"])
Пример #31
0
    def test_no_linux_sync(self):
        """Tests that no linux packages are synced"""
        body = gen_python_remote(
            includes=["scipy"],
            exclude_platforms=["linux"],
            prereleases=True,
        )
        sync_to_remote(self, body, create=True)

        self.assertEqual(
            get_content_summary(self.repo.to_dict())[PYTHON_CONTENT_NAME],
            SCIPY_COUNTS["total"] - SCIPY_COUNTS["linux"])
Пример #32
0
    def test_bdist_wheel_sync_only(self):
        """Checks that only bdist_wheel content is synced"""
        body = gen_python_remote(
            includes=PYTHON_LG_PROJECT_SPECIFIER,
            package_types=["bdist_wheel"],
            prereleases=True,
        )
        sync_to_remote(self, body, create=True)

        self.assertEqual(
            get_content_summary(self.repo.to_dict())[PYTHON_CONTENT_NAME],
            PYTHON_LG_FIXTURE_COUNTS["bdist_wheel"])
Пример #33
0
    def setUp(self):
        """Create a new repository before each test."""
        body = gen_python_remote()
        remote = self.remote_api.create(body)

        repo = self.repo_api.create(gen_repo())

        repository_sync_data = RepositorySyncURL(remote=remote.pulp_href)
        sync_response = self.repo_api.sync(repo.pulp_href,
                                           repository_sync_data)
        monitor_task(sync_response.task)

        self.repo = self.repo_api.read(repo.pulp_href)
Пример #34
0
    def test_01_basic_include(self):
        """
        Test updating the remote and performing normal sync.
        Really just a setup for the next test.
        Do the following:
        1. Create a remote.
        2. Sync the remote.
        3. Assert that the content counts in the repo match the correct count for the specifier.
        """
        body = gen_python_remote(includes=PYTHON_XS_PROJECT_SPECIFIER)
        sync_to_remote(self, body, create=True)

        self.assertDictEqual(get_content_summary(self.repo.to_dict()),
                             PYTHON_XS_FIXTURE_SUMMARY)
Пример #35
0
    def test_all(self):
        """
        Verify whether is possible to create a remote without a URL.

        This test targets the following issues:

        * `Pulp #3395 <https://pulp.plan.io/issues/3395>`_
        * `Pulp Smash #984 <https://github.com/PulpQE/pulp-smash/issues/984>`_

        """
        body = gen_python_remote(utils.uuid4())
        del body['url']
        with self.assertRaises(HTTPError):
            api.Client(config.get_config()).post(PYTHON_REMOTE_PATH, body)
Пример #36
0
    def test_latest_kept_sync_all(self):
        """
        Tests latest_kept on syncing multiple packages w/ prereleases
        """
        body = gen_python_remote(
            includes=PYTHON_LG_PROJECT_SPECIFIER,
            keep_latest_packages=3,
            prereleases=True,
        )
        sync_to_remote(self, body, create=True)

        self.assertEqual(
            get_content_summary(self.repo.to_dict())[PYTHON_CONTENT_NAME],
            PYTHON_LG_FIXTURE_COUNTS["latest_3"])
Пример #37
0
    def test_all(self):
        """
        Verify whether is possible to create a remote without a URL.

        This test targets the following issues:

        * `Pulp #3395 <https://pulp.plan.io/issues/3395>`_
        * `Pulp Smash #984 <https://github.com/PulpQE/pulp-smash/issues/984>`_

        """
        body = gen_python_remote(utils.uuid4())
        del body['url']
        with self.assertRaises(HTTPError):
            api.Client(config.get_config()).post(PYTHON_REMOTE_PATH, body)
Пример #38
0
    def test_include_unavailable_projects(self):
        """
        Test that the sync doesn't fail if some included projects aren't available.
        Do the following:
        1. Create a remote.
        2. Sync the remote.
        3. Assert that the content counts in the repo match the correct count for the specifier.
        """
        body = gen_python_remote(includes=PYTHON_UNAVAILABLE_PROJECT_SPECIFIER)
        sync_to_remote(self, body, create=True)

        self.assertEqual(
            get_content_summary(self.repo.to_dict())[PYTHON_CONTENT_NAME],
            PYTHON_UNAVAILABLE_PACKAGE_COUNT,
        )
Пример #39
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 = self.client.post(REPO_PATH, gen_repo())
        self.addCleanup(self.client.delete, repo['_href'])

        body = gen_python_remote()
        remote = self.client.post(PYTHON_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), PYTHON_XS_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo), PYTHON_XS_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), PYTHON_XS_FIXTURE_SUMMARY)
        self.assertDictEqual(get_added_content_summary(repo), {})
Пример #40
0
    def test_all(self):
        """
        Sync a repository using a Remote url that does not exist.

        Test that we get a task failure.

        """
        cfg = config.get_config()
        client = api.Client(cfg, api.json_handler)

        repo = client.post(REPO_PATH, gen_repo())
        self.addCleanup(client.delete, repo['_href'])

        body = gen_python_remote(url="http://i-am-an-invalid-url.com/invalid/")
        remote = client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(client.delete, remote['_href'])

        with self.assertRaises(exceptions.TaskReportError):
            sync(cfg, remote, repo)
Пример #41
0
def _gen_verbose_remote():
    """
    Return a semi-random dict for use in defining a remote.

    For most tests, it's desirable to create remotes with as few attributes
    as possible, so that the tests can specifically target and attempt to break
    specific features. This module specifically targets remotes, so it makes
    sense to provide as many attributes as possible.

    Note that 'username' and 'password' are write-only attributes.

    """
    attrs = gen_python_remote()
    attrs.update({
        'password': utils.uuid4(),
        'username': utils.uuid4(),
        'validate': random.choice((False, True)),
    })
    return attrs
Пример #42
0
    def test_01_basic_include(self):
        """
        Test updating the remote and performing normal sync.

        Really just a setup for the next test.

        Do the following:

        1. Create a remote.
        2. Sync the remote.
        3. Assert that the content counts in the repo match the correct count for the specifier.

        """
        body = gen_python_remote(includes=PYTHON_XS_PROJECT_SPECIFIER)
        type(self).remote = self.client.post(PYTHON_REMOTE_PATH, body)

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

        self.assertDictEqual(get_content_summary(self.repo), PYTHON_XS_FIXTURE_SUMMARY)
Пример #43
0
    def test_01_excluding_prereleases(self):
        """
        Sync a Remote, excluding prereleases.

        Do the following:

        1. Create a remote with prereleases=False.
        2. Sync the remote.
        3. Assert that the content counts in the repo match the non-prerelease packages matched
           by the specifiers.

        """
        body = gen_python_remote(includes=PYTHON_PRERELEASE_TEST_SPECIFIER, prereleases=False)
        type(self).remote = self.client.post(PYTHON_REMOTE_PATH, body)

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

        self.assertDictEqual(
            get_content_summary(self.repo),
            PYTHON_WITHOUT_PRERELEASE_FIXTURE_SUMMARY
        )
Пример #44
0
    def test_all(self):
        """
        Verify whether content served by pulp can be downloaded.

        The process of publishing content is more involved in Pulp 3 than it
        was under Pulp 2. Given a repository, the process is as follows:

        1. Create a publication from the repository. (The latest repository
           version is selected if no version is specified.) A publication is a
           repository version plus metadata.
        2. Create a distribution from the publication. The distribution defines
           at which URLs a publication is available, e.g.
           ``http://example.com/content/pub-name/`` and
           ``https://example.com/content/pub-name/``.

        Do the following:

        1. Create, populate, publish, and distribute a repository.
        2. Select a random content unit in the distribution. Download that
           content unit from Pulp, and verify that the content unit has the
           same checksum when fetched directly from Pulp-Fixtures.

        This test targets the following issues:

        * `Pulp #2895 <https://pulp.plan.io/issues/2895>`_
        * `Pulp Smash #872 <https://github.com/PulpQE/pulp-smash/issues/872>`_
        """
        cfg = config.get_config()
        client = api.Client(cfg, api.json_handler)

        repo = client.post(REPO_PATH, gen_repo())
        self.addCleanup(client.delete, repo['_href'])

        body = gen_python_remote(PYTHON_FIXTURES_URL)
        remote = client.post(PYTHON_REMOTE_PATH, body)
        self.addCleanup(client.delete, remote['_href'])

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

        # Create a publication
        publication = gen_python_publication(cfg, repository=repo)
        self.addCleanup(client.delete, publication['_href'])

        # Create a distribution.
        body = gen_distribution()
        body['publication'] = publication['_href']
        distribution = client.using_handler(api.task_handler).post(
            DISTRIBUTION_PATH,
            body
        )
        self.addCleanup(client.delete, distribution['_href'])

        # Pick a file, and download it from both Pulp Fixtures…
        unit_path = choice(get_python_content_paths(repo))
        fixtures_hash = hashlib.sha256(
            utils.http_get(urljoin(urljoin(PYTHON_FIXTURES_URL, 'packages/'), unit_path))
        ).hexdigest()

        # …and Pulp.
        content = download_content_unit(cfg, distribution, unit_path)
        pulp_hash = hashlib.sha256(content).hexdigest()

        self.assertEqual(fixtures_hash, pulp_hash)