예제 #1
0
 def setUpClass(cls):
     """Create class-wide variable."""
     delete_orphans()
     rpm_client = gen_rpm_client()
     cls.tasks_api = TasksApi(core_client)
     cls.content_api = ContentPackagesApi(rpm_client)
     cls.file_to_use = os.path.join(RPM_UNSIGNED_FIXTURE_URL, RPM_PACKAGE_FILENAME)
예제 #2
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.cfg = config.get_config()
     cls.client = gen_rpm_client()
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.remote_api = RemotesRpmApi(cls.client)
     delete_orphans(cls.cfg)
예제 #3
0
    def test_all(self):
        """Test of mirror mode."""
        client = gen_rpm_client()
        repo_api = RepositoriesRpmApi(client)
        remote_api = RemotesRpmApi(client)

        # 1. create repo, remote and sync them
        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

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

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

        # 2. create another remote and re-sync
        body = gen_rpm_remote(url=RPM_SIGNED_FIXTURE_URL)
        remote = remote_api.create(body)
        self.addCleanup(remote_api.delete, remote.pulp_href)

        repository_sync_data = RpmRepositorySyncURL(remote=remote.pulp_href, mirror=True)
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)

        # 3. Check that only new content is present
        repo = repo_api.read(repo.pulp_href)
        self.assertDictEqual(
            RPM_FIXTURE_SUMMARY,
            get_content_summary(repo.to_dict())
        )
예제 #4
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.client = gen_rpm_client()
     cls.dist_tree_api = ContentDistributionTreesApi(cls.client)
     cls.packages_api = ContentPackagesApi(cls.client)
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.remote_api = RemotesRpmApi(cls.client)
     delete_orphans()
예제 #5
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.cfg = config.get_config()
     cls.client = gen_rpm_client()
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.remote_api = RemotesRpmApi(cls.client)
     cls.publications = PublicationsRpmApi(cls.client)
     cls.distributions = DistributionsRpmApi(cls.client)
예제 #6
0
 def setUpClass(cls) -> None:
     """Set up the class."""
     cls.cfg = config.get_config()
     cls.client = gen_rpm_client()
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.publications_api = PublicationsRpmApi(cls.client)
     cls.distributions_api = DistributionsRpmApi(cls.client)
     delete_orphans(cls.cfg)
예제 #7
0
 def setUpClass(cls):
     """Create class-wide variable."""
     cls.cfg = config.get_config()
     cls.client = api.Client(cls.cfg)
     delete_orphans()
     cls.rpm_client = gen_rpm_client()
     cls.tasks_api = TasksApi(core_client)
     cls.content_api = ContentAdvisoriesApi(cls.rpm_client)
     cls.bad_file_to_use = os.path.join(RPM_UNSIGNED_FIXTURE_URL, RPM_PACKAGE_FILENAME)
예제 #8
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.cfg = config.get_config()
     cls.client = gen_rpm_client()
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.remote_api = RemotesRpmApi(cls.client)
     cls.rpm_content_api = ContentPackagesApi(cls.client)
     cls.test_package = "whale"
     cls.test_package_dependencies = ["shark", "stork"]
     delete_orphans(cls.cfg)
예제 #9
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.cfg = config.get_config()
     cls.client = gen_rpm_client()
     cls.cli_client = cli.Client(cls.cfg)
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.remote_api = RemotesRpmApi(cls.client)
     delete_orphans(cls.cfg)
     cls.md5_allowed = "md5" in get_pulp_setting(
         cls.cli_client, "ALLOWED_CONTENT_CHECKSUMS")
예제 #10
0
    def setUpClass(cls):
        """Create class-wide variables."""
        cls.cfg = config.get_config()
        cls.client = gen_rpm_client()
        cls.repo_api = RepositoriesRpmApi(cls.client)
        cls.remote_api = RemotesRpmApi(gen_rpm_client())
        cls.publications = PublicationsRpmApi(cls.client)
        cls.distributions = DistributionsRpmApi(cls.client)

        if (
            os.environ.get("CDN_CLIENT_CERT", None)
            and os.environ.get("CDN_CLIENT_KEY", None)
            and os.environ.get("CDN_CA_CERT", None)
        ):
            # strings have escaped newlines from environmental variable
            cls.cdn_client_cert = os.environ["CDN_CLIENT_CERT"].replace("\\n", "\n")
            cls.cdn_client_key = os.environ["CDN_CLIENT_KEY"].replace("\\n", "\n")
            cls.cdn_ca_cert = os.environ["CDN_CA_CERT"].replace("\\n", "\n")
        else:
            cls.cdn_client_cert = None
예제 #11
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_rpm_remote()
        del body["url"]
        with self.assertRaises(ApiException):
            RemotesRpmApi(gen_rpm_client()).create(body)
예제 #12
0
    def setUpClass(cls):
        """Create class-wide variables."""
        cls.cfg = config.get_config()
        cls.client = gen_rpm_client()
        cls.repo_api = RepositoriesRpmApi(cls.client)
        cls.remote_api = RemotesRpmApi(cls.client)
        cls.rpm_package_content_api = ContentPackagesApi(cls.client)
        cls.rpm_advisory_content_api = ContentAdvisoriesApi(cls.client)

        cls.test_advisory = "RHEA-2012:0055"
        cls.test_advisory_dependencies = ["walrus", "penguin", "shark"]
        delete_orphans(cls.cfg)
예제 #13
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.cfg = config.get_config()
     cls.client = gen_rpm_client()
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.remote_api = RemotesRpmApi(cls.client)
     cls.rpm_advisory_content_api = ContentAdvisoriesApi(cls.client)
     cls.rpm_modulemd_content_api = ContentModulemdsApi(cls.client)
     cls.rpm_package_content_api = ContentPackagesApi(cls.client)
     cls.test_advisory = "FEDORA-2019-0329090518"
     # these dependencies have same name for dependent packages as dependant modules
     cls.test_advisory_dependencies = ["postgresql", "nodejs"]
     delete_orphans()
예제 #14
0
    def setUpClass(cls):
        """Create class-wide variables."""
        cls.cfg = config.get_config()
        cls.client = api.Client(cls.cfg, api.json_handler)
        cls.core_client = CoreApiClient(configuration=cls.cfg.get_bindings_config())
        cls.rpm_client = gen_rpm_client()

        cls.repo_api = RepositoriesRpmApi(cls.rpm_client)
        cls.remote_api = RemotesRpmApi(cls.rpm_client)
        cls.exporter_api = ExportersPulpApi(cls.core_client)
        cls.exports_api = ExportersCoreExportsApi(cls.core_client)

        (cls.repo, cls.remote) = cls._setup_repositories()
예제 #15
0
파일: test_comps.py 프로젝트: pulp/pulp_rpm
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.cfg = config.get_config()
     cls.client = api.Client(cls.cfg, api.json_handler)
     cls.rpm_client = gen_rpm_client()
     cls.comps_api = RpmCompsApi(cls.rpm_client)
     cls.repo_api = RepositoriesRpmApi(cls.rpm_client)
     cls.repo_version_api = RepositoriesRpmVersionsApi(cls.rpm_client)
     cls.groups_api = ContentPackagegroupsApi(cls.rpm_client)
     cls.envs_api = ContentPackageenvironmentsApi(cls.rpm_client)
     cls.groupslangpacks_api = ContentPackagelangpacksApi(cls.rpm_client)
     cls.categories_api = ContentPackagecategoriesApi(cls.rpm_client)
     cls.small_content = SMALL_GROUPS + SMALL_CATEGORY + SMALL_LANGPACK + SMALL_ENVIRONMENTS
     cls.centos8_content = BIG_GROUPS + BIG_CATEGORY + BIG_LANGPACK + BIG_ENVIRONMENTS
예제 #16
0
 def setUpClass(cls):
     """Verify whether dnf or yum are present."""
     cls.cfg = config.get_config()
     configuration = cls.cfg.get_bindings_config()
     core_client = CoreApiClient(configuration)
     cls.artifacts_api = ArtifactsApi(core_client)
     cls.client = gen_rpm_client()
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.remote_api = RemotesRpmApi(cls.client)
     cls.publications = PublicationsRpmApi(cls.client)
     cls.distributions = DistributionsRpmApi(cls.client)
     cls.before_consumption_artifact_count = 0
     cls.pkg_mgr = cli.PackageManager(cls.cfg)
     cls.pkg_mgr.raise_if_unsupported(unittest.SkipTest,
                                      "This test requires dnf or yum.")
예제 #17
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.client = gen_rpm_client()
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.remote_api = RemotesRpmApi(cls.client)
     cls.repometadatafiles = ContentRepoMetadataFilesApi(cls.client)
     delete_orphans()
     # Certificates processing
     cls.cdn_client_cert = False
     if (os.environ["CDN_CLIENT_CERT"] and os.environ["CDN_CLIENT_KEY"]
             and os.environ["CDN_CA_CERT"]):
         # strings have escaped newlines from environmental variable
         cls.cdn_client_cert = os.environ["CDN_CLIENT_CERT"].replace(
             "\\n", "\n")
         cls.cdn_client_key = os.environ["CDN_CLIENT_KEY"].replace(
             "\\n", "\n")
         cls.cdn_ca_cert = os.environ["CDN_CA_CERT"].replace("\\n", "\n")
예제 #18
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.cfg = config.get_config()
     cls.client = gen_rpm_client()
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.remote_api = RemotesRpmApi(cls.client)
     cls.repometadatafiles = ContentRepoMetadataFilesApi(cls.client)
     delete_orphans(cls.cfg)
     # Certificates processing
     cls.cdn_client_cert = False
     if os.environ['CDN_CLIENT_CERT'] \
             and os.environ['CDN_CLIENT_KEY'] \
             and os.environ['CDN_CA_CERT']:
         # strings have escaped newlines from environmental variable
         cls.cdn_client_cert = os.environ['CDN_CLIENT_CERT'].replace(
             '\\n', '\n')
         cls.cdn_client_key = os.environ['CDN_CLIENT_KEY'].replace(
             '\\n', '\n')
         cls.cdn_ca_cert = os.environ['CDN_CA_CERT'].replace('\\n', '\n')
예제 #19
0
    def test_06_second_unit_raises_error(self):
        """
        Create a duplicate content unit with different ``artifacts`` and same ``repo_key_fields``.
        """
        delete_orphans()
        client = gen_rpm_client()
        repo_api = RepositoriesRpmApi(client)

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

        artifact = gen_artifact()

        # create first content unit.
        content_attrs = {
            "artifact": artifact["pulp_href"],
            "relative_path": "test_package"
        }
        response = self.rpm_content_api.create(**content_attrs)
        monitor_task(response.task)

        artifact = gen_artifact(url=RPM_SIGNED_URL2)

        # create second content unit.
        second_content_attrs = {"artifact": artifact["pulp_href"]}
        second_content_attrs["relative_path"] = content_attrs["relative_path"]
        response = self.rpm_content_api.create(**second_content_attrs)
        monitor_task(response.task)

        data = {
            "add_content_units":
            [c.pulp_href for c in self.rpm_content_api.list().results]
        }
        response = repo_api.modify(repo.pulp_href, data)
        with self.assertRaises(PulpTaskError) as cm:
            monitor_task(response.task)
        task = cm.exception.task.to_dict()

        error_message = "Cannot create repository version. Path is duplicated: {}.".format(
            content_attrs["relative_path"])

        self.assertEqual(task["error"]["description"], error_message)
예제 #20
0
    def test_all(self):
        """Sync/publish a repo that ``updateinfo.xml`` contains references.

        This test targets the following issue:

        `Pulp #3998 <https://pulp.plan.io/issues/3998>`_.
        """
        client = gen_rpm_client()
        repo_api = RepositoriesRpmApi(client)
        remote_api = RemotesRpmApi(client)
        publications = PublicationsRpmApi(client)

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

        body = gen_rpm_remote(RPM_REFERENCES_UPDATEINFO_URL)
        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 = RpmRepositorySyncURL(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)

        content_summary = get_content_summary(repo.to_dict())
        self.assertDictEqual(content_summary, RPM_FIXTURE_SUMMARY,
                             content_summary)

        publish_data = RpmRpmPublication(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.assertIsNotNone(publication_href)

        self.addCleanup(publications.delete, publication_href)
예제 #21
0
    def setUpClass(cls):
        """Create class-wide variables."""
        cls.cfg = config.get_config()
        cls.client = api.Client(cls.cfg, api.json_handler)
        cls.core_client = CoreApiClient(configuration=cls.cfg.get_bindings_config())
        cls.rpm_client = gen_rpm_client()

        cls.repo_api = RepositoriesRpmApi(cls.rpm_client)
        cls.remote_api = RemotesRpmApi(cls.rpm_client)
        cls.exporter_api = ExportersPulpApi(cls.core_client)
        cls.exports_api = ExportersPulpExportsApi(cls.core_client)
        cls.importer_api = ImportersPulpApi(cls.core_client)
        cls.imports_api = ImportersPulpImportsApi(cls.core_client)
        cls.dist_tree_api = ContentDistributionTreesApi(cls.rpm_client)

        cls.import_repos, cls.export_repos, cls.remotes = cls._setup_repositories(
            RPM_UNSIGNED_FIXTURE_URL
        )
        cls.exporter = cls._create_exporter()
        cls.export = cls._create_export()
예제 #22
0
    def test_all(self):
        """Test of addtive mode."""
        client = gen_rpm_client()
        repo_api = RepositoriesRpmApi(client)
        remote_api = RemotesRpmApi(client)

        # 1. create repo, remote and sync them
        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

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

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

        # 2. create another remote and re-sync
        body = gen_rpm_remote(url=SRPM_UNSIGNED_FIXTURE_URL)
        remote = remote_api.create(body)
        self.addCleanup(remote_api.delete, remote.pulp_href)

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

        # 3. Check content counts
        repo = repo_api.read(repo.pulp_href)
        present_package_count = len(
            get_content(repo.to_dict())[PULP_TYPE_PACKAGE])
        present_advisory_count = len(
            get_content(repo.to_dict())[PULP_TYPE_ADVISORY])
        self.assertEqual(
            RPM_PACKAGE_COUNT + SRPM_UNSIGNED_FIXTURE_PACKAGE_COUNT,
            present_package_count)
        self.assertEqual(
            RPM_ADVISORY_COUNT + SRPM_UNSIGNED_FIXTURE_ADVISORY_COUNT,
            present_advisory_count)
예제 #23
0
 def setUpClass(cls):
     """Create class-wide variable."""
     delete_orphans()
     cls.content_unit = {}
     cls.rpm_content_api = ContentPackagesApi(gen_rpm_client())
     cls.artifact = gen_artifact(RPM_SIGNED_URL)
예제 #24
0
    def do_test(self, url, policy="on_demand"):
        """Verify whether content served by pulp can be synced.

        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/foo/`` and
           ``http://example.com/content/bar/``.

        Do the following:

        1. Create, populate, publish, and distribute a repository.
        2. Sync other repository using as remote url,
        the distribution base_url from the previous repository.

        """
        client = gen_rpm_client()
        repo_api = RepositoriesRpmApi(client)
        remote_api = RemotesRpmApi(client)
        publications = PublicationsRpmApi(client)
        distributions = DistributionsRpmApi(client)

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

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

        # Sync a Repository
        repository_sync_data = RpmRepositorySyncURL(remote=remote.pulp_href)
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        sync_task = tasks.read(sync_response.task)
        task_duration = sync_task.finished_at - sync_task.started_at
        waiting_time = sync_task.started_at - sync_task.pulp_created
        print(
            "\n->     Sync => Waiting time (s): {wait} | Service time (s): {service}".format(
                wait=waiting_time.total_seconds(), service=task_duration.total_seconds()
            )
        )
        repo = repo_api.read(repo.pulp_href)

        # Create a publication.
        publish_data = RpmRpmPublication(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)

        # Create a distribution.
        body = gen_distribution()
        body["publication"] = publication_href
        distribution_response = distributions.create(body)
        created_resources = monitor_task(distribution_response.task).created_resources
        distribution = distributions.read(created_resources[0])
        self.addCleanup(distributions.delete, distribution.pulp_href)

        # Create another repo pointing to distribution base_url
        repo2 = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo2.pulp_href)

        body = gen_rpm_remote(url=distribution.base_url, policy=policy)
        remote2 = remote_api.create(body)
        self.addCleanup(remote_api.delete, remote2.pulp_href)

        # Sync a Repository
        repository_sync_data = RpmRepositorySyncURL(remote=remote2.pulp_href)
        sync_response = repo_api.sync(repo2.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        sync_task = tasks.read(sync_response.task)
        task_duration = sync_task.finished_at - sync_task.started_at
        waiting_time = sync_task.started_at - sync_task.pulp_created
        print(
            "\n->     Sync => Waiting time (s): {wait} | Service time (s): {service}".format(
                wait=waiting_time.total_seconds(), service=task_duration.total_seconds()
            )
        )
        repo2 = repo_api.read(repo2.pulp_href)

        summary = get_content_summary(repo.to_dict())
        summary2 = get_content_summary(repo2.to_dict())
        self.assertDictEqual(summary, summary2)

        added = get_added_content_summary(repo.to_dict())
        added2 = get_added_content_summary(repo2.to_dict())
        self.assertDictEqual(added, added2)
예제 #25
0
    def do_test(self, policy):
        """Verify whether content served by pulp can be synced.

        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/foo/`` and
           ``http://example.com/content/bar/``.

        Do the following:

        1. Create, populate, publish, and distribute a repository.
        2. Sync other repository using as remote url,
        the distribution base_url from the previous repository.

        """
        client = gen_rpm_client()
        repo_api = RepositoriesRpmApi(client)
        remote_api = RemotesRpmApi(client)
        publications = PublicationsRpmApi(client)
        distributions = DistributionsRpmApi(client)

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

        body = gen_rpm_remote(url=RPM_KICKSTART_FIXTURE_URL, policy=policy)
        remote = remote_api.create(body)
        self.addCleanup(remote_api.delete, remote.pulp_href)

        # Sync a Repository
        repository_sync_data = RpmRepositorySyncURL(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)

        # Create a publication.
        publish_data = RpmRpmPublication(
            repository=repo.pulp_href,
            metadata_checksum_type="sha1",
            package_checksum_type="sha224",
        )
        publish_response = publications.create(publish_data)
        created_resources = monitor_task(publish_response.task)
        publication_href = created_resources[0]
        self.addCleanup(publications.delete, publication_href)

        # Create a distribution.
        body = gen_distribution()
        body["publication"] = publication_href
        distribution_response = distributions.create(body)
        created_resources = monitor_task(distribution_response.task)
        distribution = distributions.read(created_resources[0])
        self.addCleanup(distributions.delete, distribution.pulp_href)

        # Create another repo pointing to distribution base_url
        repo2 = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo2.pulp_href)

        body = gen_rpm_remote(url=distribution.base_url, policy=policy)
        remote2 = remote_api.create(body)
        self.addCleanup(remote_api.delete, remote2.pulp_href)

        # Sync a Repository
        repository_sync_data = RpmRepositorySyncURL(remote=remote2.pulp_href)
        sync_response = repo_api.sync(repo2.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)
        repo2 = repo_api.read(repo2.pulp_href)

        summary = get_content_summary(repo.to_dict())
        summary2 = get_content_summary(repo2.to_dict())
        self.assertDictEqual(summary, summary2)

        added = get_added_content_summary(repo.to_dict())
        added2 = get_added_content_summary(repo2.to_dict())
        self.assertDictEqual(added, added2)
예제 #26
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.client = gen_rpm_client()
     cls.DP_ON_DEMAND = "on_demand" in DOWNLOAD_POLICIES
     cls.DP_STREAMED = "streamed" in DOWNLOAD_POLICIES
예제 #27
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.
        """
        cfg = config.get_config()
        client = gen_rpm_client()
        repo_api = RepositoriesRpmApi(client)
        remote_api = RemotesRpmApi(client)
        publications = PublicationsRpmApi(client)

        body = gen_rpm_remote()
        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 = RpmRepositorySyncURL(remote=remote.pulp_href)
        sync_response = repo_api.sync(repo.pulp_href, repository_sync_data)
        monitor_task(sync_response.task)

        # Step 1
        repo = repo_api.read(repo.pulp_href)
        for rpm_content in get_content(
                repo.to_dict())[RPM_PACKAGE_CONTENT_NAME]:
            modify_repo(cfg, repo.to_dict(), add_units=[rpm_content])
        version_hrefs = tuple(ver["pulp_href"]
                              for ver in get_versions(repo.to_dict()))
        non_latest = choice(version_hrefs[:-1])

        # Step 2
        publish_data = RpmRpmPublication(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)

        # Step 3
        self.assertEqual(publication.repository_version, version_hrefs[-1])

        # Step 4
        publish_data.repository_version = non_latest
        publish_data.repository = None
        publish_response = publications.create(publish_data)
        created_resources = monitor_task(
            publish_response.task).created_resources
        publication_href = created_resources[0]
        publication = publications.read(publication_href)

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

        # Step 6
        with self.assertRaises(ApiException):
            body = {
                "repository": repo.pulp_href,
                "repository_version": non_latest
            }
            publications.create(body)
예제 #28
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.remote_api = RemotesRpmApi(gen_rpm_client())
예제 #29
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.
        """
        cfg = config.get_config()
        client = gen_rpm_client()
        repo_api = RepositoriesRpmApi(client)
        remote_api = RemotesRpmApi(client)
        publications = PublicationsRpmApi(client)
        distributions = DistributionsRpmApi(client)

        body = gen_rpm_remote()
        remote = remote_api.create(body)

        repo = repo_api.create(gen_repo())

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

        # Step 1
        repo = repo_api.read(repo.pulp_href)
        repo_content = get_content(
            repo.to_dict())[RPM_PACKAGE_CONTENT_NAME][:-1]
        for rpm_content in repo_content:
            modify_repo(cfg, repo.to_dict(), remove_units=[rpm_content])
        version_hrefs = tuple(ver["pulp_href"]
                              for ver in get_versions(repo.to_dict()))
        non_latest = choice(version_hrefs[1:-1])

        # Step 2
        publish_data = RpmRpmPublication(repository=repo.pulp_href)
        publish_response = publications.create(publish_data)
        created_resources = monitor_task(
            publish_response.task).created_resources
        publication_href = created_resources[0]
        publication = publications.read(publication_href)

        # Step 3
        self.assertEqual(publication.repository_version, version_hrefs[-1])

        # Step 4
        publish_data.repository_version = non_latest
        publish_data.repository = None
        publish_response = publications.create(publish_data)
        created_resources = monitor_task(
            publish_response.task).created_resources
        publication_href = created_resources[0]
        publication = publications.read(publication_href)

        # Step 5
        body = gen_distribution()
        body["base_path"] = "pulp_pre_upgrade_test"
        body["publication"] = publication.pulp_href

        distribution_response = distributions.create(body)
        created_resources = monitor_task(
            distribution_response.task).created_resources
        distribution = distributions.read(created_resources[0])

        # Step 6
        self.assertEqual(publication.repository_version, non_latest)

        # Step 7
        with self.assertRaises(ApiException):
            body = {
                "repository": repo.pulp_href,
                "repository_version": non_latest
            }
            publications.create(body)

        # Step 8
        url = cfg.get_content_host_base_url(
        ) + "/pulp/content/pulp_pre_upgrade_test/"
        self.assertEqual(url, distribution.base_url, url)
예제 #30
0
 def setUpClass(cls):
     """Create class-wide variables."""
     cls.client = gen_rpm_client()