Ejemplo n.º 1
0
 def setUpClass(cls) -> None:
     """Set up the class."""
     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()
Ejemplo n.º 2
0
    def setUpClass(cls):
        """
        Create all the client instances needed to communicate with Pulp.
        """
        configuration = Configuration(**BINDINGS_CONFIGURATION)

        rpm_client = RpmApiClient(configuration)
        migration_client = MigrationApiClient(configuration)

        # Create api clients for all resource types
        cls.rpm_repo_api = RepositoriesRpmApi(rpm_client)
        cls.rpm_repo_versions_api = RepositoriesRpmVersionsApi(rpm_client)
        cls.rpm_remote_api = RemotesRpmApi(rpm_client)
        cls.rpm_distribution_api = DistributionsRpmApi(rpm_client)
        cls.rpm_publication_api = PublicationsRpmApi(rpm_client)
        cls.rpm_content_apis = {
            "advisory": ContentAdvisoriesApi(rpm_client),
            "disttree": ContentDistributionTreesApi(rpm_client),
            "modulemd": ContentModulemdsApi(rpm_client),
            "modulemd-defaults": ContentModulemdDefaultsApi(rpm_client),
            "category": ContentPackagecategoriesApi(rpm_client),
            "environment": ContentPackageenvironmentsApi(rpm_client),
            "group": ContentPackagegroupsApi(rpm_client),
            "langpack": ContentPackagelangpacksApi(rpm_client),
            "package": ContentPackagesApi(rpm_client),
        }
        cls.migration_plans_api = MigrationPlansApi(migration_client)
        cls.pulp2content_api = Pulp2ContentApi(migration_client)
        cls.pulp2repositories_api = Pulp2RepositoriesApi(migration_client)
Ejemplo n.º 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()))
Ejemplo n.º 4
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.advisory_api = ContentAdvisoriesApi(cls.client)
        delete_orphans()

        def _sync(url=None):
            repo = cls.repo_api.create(gen_repo())
            remote = cls.remote_api.create(gen_rpm_remote(url))
            repository_sync_data = RpmRepositorySyncURL(remote=remote.pulp_href)
            sync_response = cls.repo_api.sync(repo.pulp_href, repository_sync_data)
            monitor_task(sync_response.task)
            return cls.repo_api.read(repo.pulp_href)

        # sync repos to get two conflicting advisories to use later in tests
        cls.repo_rpm_unsigned = _sync(url=RPM_UNSIGNED_FIXTURE_URL)
        cls.repo_rpm_advisory_diffpkgs = _sync(url=RPM_ADVISORY_DIFFERENT_PKGLIST_URL)
        cls.advisory_rpm_unsigned_href = (
            cls.advisory_api.list(
                repository_version=cls.repo_rpm_unsigned.latest_version_href,
                id=RPM_ADVISORY_TEST_ID,
            )
            .results[0]
            .pulp_href
        )
        cls.advisory_rpm_advisory_diffpkgs_href = (
            cls.advisory_api.list(
                repository_version=cls.repo_rpm_advisory_diffpkgs.latest_version_href,
                id=RPM_ADVISORY_TEST_ID,
            )
            .results[0]
            .pulp_href
        )
Ejemplo n.º 5
0
    def setUpClass(cls):
        """
        Create all the client instances needed to communicate with Pulp.
        """
        configuration = Configuration(**BINDINGS_CONFIGURATION)

        rpm_client = RpmApiClient(configuration)
        migration_client = MigrationApiClient(configuration)

        # Create api clients for all resource types
        cls.rpm_repo_api = RepositoriesRpmApi(rpm_client)
        cls.rpm_repo_versions_api = RepositoriesRpmVersionsApi(rpm_client)
        cls.rpm_remote_api = RemotesRpmApi(rpm_client)
        cls.rpm_distribution_api = DistributionsRpmApi(rpm_client)
        cls.rpm_publication_api = PublicationsRpmApi(rpm_client)
        cls.rpm_content_apis = {
            'advisory': ContentAdvisoriesApi(rpm_client),
            # skip until https://pulp.plan.io/issues/8050 is fixed
            # 'disttree': ContentDistributionTreesApi(rpm_client),
            'modulemd': ContentModulemdsApi(rpm_client),
            'modulemd-defaults': ContentModulemdDefaultsApi(rpm_client),
            'category': ContentPackagecategoriesApi(rpm_client),
            'environment': ContentPackageenvironmentsApi(rpm_client),
            'group': ContentPackagegroupsApi(rpm_client),
            'langpack': ContentPackagelangpacksApi(rpm_client),
            'package': ContentPackagesApi(rpm_client),
        }
        cls.migration_plans_api = MigrationPlansApi(migration_client)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
 def setUpClass(cls):
     """Create class-wide variable."""
     delete_orphans()
     cls.client = gen_rpm_client()
     cls.cfg = Configuration(cls.client)
     cls.repo_api = RepositoriesRpmApi(cls.client)
     cls.remote_api = RemotesRpmApi(cls.client)
Ejemplo n.º 9
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()
Ejemplo n.º 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(cls.client)
     cls.rpm_content_api = ContentPackagesApi(cls.client)
     cls.test_package = "whale"
     cls.test_package_dependencies = ["shark", "stork"]
     delete_orphans(cls.cfg)
Ejemplo n.º 11
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")
Ejemplo n.º 12
0
    def setUpClass(cls):
        """Create class-wide variables."""
        cls.cfg = config.get_config()
        cls.client = gen_rpm_client()

        cls.content_api = ContentPackagesApi(cls.client)
        cls.repo_api = RepositoriesRpmApi(cls.client)
        cls.remote_api = RemotesRpmApi(cls.client)
        cls.publications_api = PublicationsRpmApi(cls.client)
        cls.distributions_api = DistributionsRpmApi(cls.client)
Ejemplo n.º 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_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)
Ejemplo n.º 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()
Ejemplo n.º 15
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()
Ejemplo n.º 16
0
 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
Ejemplo n.º 17
0
    def do_test(self, url):
        """Sync a repository given ``url`` on the remote."""
        repo_api = RepositoriesRpmApi(self.client)
        remote_api = RemotesRpmApi(self.client)

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

        body = gen_rpm_remote(url=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)
        return monitor_task(sync_response.task)
Ejemplo n.º 18
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.")
Ejemplo n.º 19
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")
Ejemplo n.º 20
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')
Ejemplo n.º 21
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)
Ejemplo n.º 22
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)
Ejemplo n.º 23
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
Ejemplo n.º 24
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()
    def setUpClass(cls):
        """
        Create all the client instances needed to communicate with Pulp.
        """
        configuration = Configuration(**BINDINGS_CONFIGURATION)

        file_client = FileApiClient(configuration)
        rpm_client = RpmApiClient(configuration)
        migration_client = MigrationApiClient(configuration)

        # Create api clients for File
        cls.file_repo_api = RepositoriesFileApi(file_client)
        cls.file_repo_versions_api = RepositoriesFileVersionsApi(file_client)
        cls.file_remote_api = RemotesFileApi(file_client)
        cls.file_distribution_api = DistributionsFileApi(file_client)
        cls.file_publication_api = PublicationsFileApi(file_client)
        cls.file_content_api = ContentFilesApi(file_client)

        # Create api clients for RPM
        cls.rpm_repo_api = RepositoriesRpmApi(rpm_client)
        cls.rpm_repo_versions_api = RepositoriesRpmVersionsApi(rpm_client)
        cls.rpm_remote_api = RemotesRpmApi(rpm_client)
        cls.rpm_distribution_api = DistributionsRpmApi(rpm_client)
        cls.rpm_publication_api = PublicationsRpmApi(rpm_client)
        cls.rpm_content_apis = {
            'advisory': ContentAdvisoriesApi(rpm_client),
            'disttree': ContentDistributionTreesApi(rpm_client),
            'modulemd': ContentModulemdsApi(rpm_client),
            'modulemd-defaults': ContentModulemdDefaultsApi(rpm_client),
            'category': ContentPackagecategoriesApi(rpm_client),
            'environment': ContentPackageenvironmentsApi(rpm_client),
            'group': ContentPackagegroupsApi(rpm_client),
            'langpack': ContentPackagelangpacksApi(rpm_client),
            'package': ContentPackagesApi(rpm_client),
        }

        # Create api clients for Migration
        cls.migration_plans_api = MigrationPlansApi(migration_client)
        cls.pulp2content_api = Pulp2ContentApi(migration_client)
        cls.pulp2repositories_api = Pulp2RepositoriesApi(migration_client)
Ejemplo n.º 26
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)
Ejemplo n.º 27
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_api = RepositoriesRpmApi(self.client)
        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

        remote_api = RemotesRpmApi(self.client)
        remote = remote_api.create(gen_rpm_remote())
        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)

        cmd = "lsof -t +D {}".format(MEDIA_PATH).split()
        response = cli_client.run(cmd).stdout
        self.assertEqual(len(response), 0, response)
Ejemplo n.º 28
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)
Ejemplo n.º 29
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)
Ejemplo n.º 30
0
def rpm_repository_api(rpm_client):
    """Fixture for RPM repositories API."""
    return RepositoriesRpmApi(rpm_client)