Exemplo n.º 1
0
 def test_partial_update(self):
     """Update a FilesystemExporter's path."""
     exporter_created, body = self._create_exporter()
     body = {"path": "/tmp/{}".format(uuid4())}
     result = self.exporter_api.partial_update(exporter_created.pulp_href,
                                               body)
     monitor_task(result.task)
     exporter_read = self.exporter_api.read(exporter_created.pulp_href)
     self.assertNotEqual(exporter_created.path, exporter_read.path)
     self.assertEqual(body["path"], exporter_read.path)
Exemplo n.º 2
0
 def test_03_fail_duplicate_content_unit(self):
     """Create content unit."""
     response = self.file_content_api.create(**self.attrs, file=__file__)
     with self.assertRaises(PulpTaskError) as cm:
         monitor_task(response.task)
     task = cm.exception.task.to_dict()
     self.assertEqual(task["state"], "failed")
     error_description = task["error"]["description"]
     for key in ("already", "relative", "path", "digest"):
         self.assertIn(key, error_description.lower(), task["error"])
Exemplo n.º 3
0
    def _delete_exporter(self, exporter):
        """
        Utility routine to delete an exporter.
        """
        cli_client = cli.Client(self.cfg)
        cmd = ("rm", "-rf", exporter.path)
        cli_client.run(cmd, sudo=True)

        result = self.exporter_api.delete(exporter.pulp_href)
        monitor_task(result.task)
Exemplo n.º 4
0
 def test_04_fully_update(self):
     """Update a repository using HTTP PUT."""
     body = {"name": utils.uuid4()}
     with self.assertRaises(ApiException):
         self.user2["repository_api"].update(self.repository.pulp_href, body)
     with self.assertRaises(ApiException):
         self.user3["repository_api"].update(self.repository.pulp_href, body)
     response = self.user1["repository_api"].update(self.repository.pulp_href, body)
     monitor_task(response.task)
     type(self).repository = self.user1["repository_api"].read(self.repository.pulp_href)
Exemplo n.º 5
0
 def test_05_delete(self):
     """Delete a repository."""
     with self.assertRaises(ApiException):
         self.user2["repository_api"].delete(self.repository.pulp_href)
     with self.assertRaises(ApiException):
         self.user3["repository_api"].delete(self.repository.pulp_href)
     response = self.user1["repository_api"].delete(self.repository.pulp_href)
     monitor_task(response.task)
     with self.assertRaises(ApiException):
         self.user1["repository_api"].read(self.repository.pulp_href)
Exemplo n.º 6
0
    def test_add_repo_labels(self):
        """Update repository with labels."""
        labels = {"maiar": "mithrandir", "valar": "varda"}
        self._create_repo()

        resp = self.repo_api.partial_update(self.repo.pulp_href,
                                            {"pulp_labels": labels})
        monitor_task(resp.task)
        self.repo = self.repo_api.read(self.repo.pulp_href)
        self.assertEqual(labels, self.repo.pulp_labels)
Exemplo n.º 7
0
 def test_02_content_guard_creation(self):
     """Checks that RBAC ContentGuard can be created and assigned to a distribution"""
     guard = self.creator_user["rbac_guard_api"].create(
         {"name": self.distro.name})
     body = PatchedfileFileDistribution(content_guard=guard.pulp_href)
     monitor_task(
         self.distro_api.partial_update(self.distro.pulp_href, body).task)
     RBACContentGuardTestCase.distro = self.distro_api.read(
         self.distro.pulp_href)
     self.assertEqual(guard.pulp_href, self.distro.content_guard)
Exemplo n.º 8
0
 def test_04_fully_update(self):
     """Update a remote using HTTP PUT."""
     body = _gen_verbose_remote()
     with self.assertRaises(ApiException):
         self.user2["remote_api"].update(self.remote.pulp_href, body)
     with self.assertRaises(ApiException):
         self.user3["remote_api"].update(self.remote.pulp_href, body)
     response = self.user1["remote_api"].update(self.remote.pulp_href, body)
     monitor_task(response.task)
     type(self).remote = self.user1["remote_api"].read(self.remote.pulp_href)
Exemplo n.º 9
0
    def test_model_partial_update(self):
        """Test that labels aren't unset accidentially with PATCH calls."""
        labels = {"maiar": "mithrandir", "valar": "varda"}
        self._create_repo(labels)

        resp = self.repo_api.partial_update(self.repo.pulp_href,
                                            {"name": str(uuid4())})
        monitor_task(resp.task)
        self.repo = self.repo_api.read(self.repo.pulp_href)
        self.assertEqual(labels, self.repo.pulp_labels)
Exemplo n.º 10
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. Create distribution.
        6. Assert that the publication ``repository_version`` attribute points
           to the supplied repository version.
        7. Assert that an exception is raised when providing two different
           repository versions to be published at same time.
        """
        # Step 1
        for file_content in get_content(self.repo.to_dict())[FILE_CONTENT_NAME]:
            repository_modify_data = RepositoryAddRemoveContent(
                remove_content_units=[file_content["pulp_href"]]
            )
            modify_response = self.repo_api.modify(self.repo.pulp_href, repository_modify_data)
            monitor_task(modify_response.task)
        version_hrefs = tuple(ver["pulp_href"] for ver in get_versions(self.repo.to_dict()))
        non_latest = choice(version_hrefs[:-1])

        # Step 2
        publish_data = FileFilePublication(repository=self.repo.pulp_href)
        publication = self.create_publication(publish_data)

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

        # Step 4
        publish_data = FileFilePublication(repository_version=non_latest)
        publication = self.create_publication(publish_data)

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

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

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

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

        # Step 8
        url = self.cfg.get_content_host_base_url() + "/pulp/content/pulp_post_upgrade_test/"
        self.assertEqual(url, distribution.base_url, url)
Exemplo n.º 11
0
    def setUpClass(cls):
        """Set up two distros for the sync tests."""
        super().setUpClass()
        collections = []
        cls.signing_service = create_signing_service()
        col_api = AnsibleCollectionsApi(cls.client)
        for i in range(4):
            collection = build_collection("skeleton", config=TEST_COLLECTION_CONFIGS[i])
            response = col_api.upload_collection(collection.filename)
            task = monitor_task(response.task)
            collections.append(task.created_resources[0])

        cls.repo = cls.repo_api.create(gen_repo())
        body = {"add_content_units": collections}
        monitor_task(cls.repo_api.modify(cls.repo.pulp_href, body).task)

        body = {"content_units": collections[:2], "signing_service": cls.signing_service.pulp_href}
        monitor_task(cls.repo_api.sign(cls.repo.pulp_href, body).task)
        body = {"content_units": collections[2:], "signing_service": cls.signing_service.pulp_href}
        monitor_task(cls.repo_api.sign(cls.repo.pulp_href, body).task)

        body = gen_distribution(repository=cls.repo.pulp_href)
        distro_href = monitor_task(cls.distributions_api.create(body).task).created_resources[0]
        cls.distro1 = cls.distributions_api.read(distro_href)
        body = gen_distribution(repository_version=f"{cls.repo.versions_href}2/")
        distro_href = monitor_task(cls.distributions_api.create(body).task).created_resources[0]
        cls.distro2 = cls.distributions_api.read(distro_href)
Exemplo n.º 12
0
    def test_private_repository(self):
        """
        Test that you can create a private distribution and push to it.
        Test that the same user can pull, but another cannot.
        Test that the other user can pull after marking it non-private.
        """
        # cleanup, namespace removal also removes related distributions
        try:
            namespace = self.namespace_api.list(name="test").results[0]
            namespace_response = self.namespace_api.delete(namespace.pulp_href)
            monitor_task(namespace_response.task)
        except Exception:
            pass

        repo_name = "test/private"
        local_url = "/".join([self.registry_name, f"{repo_name}:2.0"])
        image_path = f"{DOCKERHUB_PULP_FIXTURE_1}:manifest_a"

        distribution = {
            "name": "test/private",
            "base_path": "test/private",
            "private": True
        }
        distribution_response = self.user_creator["distribution_api"].create(
            distribution)
        created_resources = monitor_task(
            distribution_response.task).created_resources
        distribution = self.user_creator["distribution_api"].read(
            created_resources[0])

        self._push(image_path, local_url, self.user_creator)

        self._pull(local_url, self.user_creator)

        add_user_to_distribution_group(self.user_dist_consumer, distribution,
                                       "consumers", self.user_creator)

        self._pull(local_url, self.user_dist_consumer)
        with self.assertRaises(exceptions.CalledProcessError):
            self._pull(local_url, self.user_reader)
        with self.assertRaises(exceptions.CalledProcessError):
            self._pull(local_url, self.user_helpless)

        distribution.private = False
        distribution_response = self.user_creator[
            "distribution_api"].partial_update(distribution.pulp_href,
                                               {"private": False})
        monitor_task(distribution_response.task)

        self._pull(local_url, self.user_reader)
        self._pull(local_url, self.user_helpless)

        # cleanup, namespace removal also removes related distributions
        namespace = self.namespace_api.list(name="test").results[0]
        self.addCleanup(self.namespace_api.delete, namespace.pulp_href)
Exemplo n.º 13
0
 def _gen_export(self, exporter, body={}):
     """Create and read back an export for the specified PulpExporter."""
     export_response = self.exports_api.create(exporter.pulp_href, body)
     monitor_task(export_response.task)
     task = self.client.get(export_response.task)
     resources = task["created_resources"]
     self.assertEqual(1, len(resources))
     export_href = resources[0]
     export = self.exports_api.read(export_href)
     self.assertIsNotNone(export)
     return export
Exemplo n.º 14
0
    def test_run_only_one_reset(self):
        """Test that only one reset can be run at a time."""
        mp = self.migration_plans_api.create({'plan': FILE_SIMPLE_PLAN})

        # run twice
        mp_run_response = self.migration_plans_api.reset(mp.pulp_href)
        with self.assertRaises(ApiException):
            self.migration_plans_api.reset(mp.pulp_href)

        # make sure the first task is completed not to interfere with further tests
        monitor_task(mp_run_response.task)
Exemplo n.º 15
0
    def _gen_export(self, exporter, publication):
        """Create and read back an export for the specified FilesystemExporter."""
        body = {"publication": publication.pulp_href}
        export_response = self.exports_api.create(exporter.pulp_href, body)
        monitor_task(export_response.task)

        task = self.client.get(export_response.task)
        resources = task["created_resources"]
        self.assertEqual(1, len(resources))

        return self.exports_api.read(resources[0])
Exemplo n.º 16
0
 def test_04_fully_update(self):
     """Update a repository using HTTP PUT."""
     body = {"name": self.repository.name, "description": "old_busted"}
     with self.assertRaises(ApiException):
         self.user_helpless["pushrepository_api"].update(self.repository.pulp_href, body)
     with self.assertRaises(ApiException):
         self.user_reader["pushrepository_api"].update(self.repository.pulp_href, body)
     response = self.user_creator["pushrepository_api"].update(self.repository.pulp_href, body)
     monitor_task(response.task)
     repository = self.user_creator["pushrepository_api"].read(self.repository.pulp_href)
     self.assertEqual(repository.description, body["description"])
Exemplo n.º 17
0
    def test_all(self):
        """Sync two repositories and check view filter."""
        # Test content doesn't exists.
        non_existant_content_href = (
            "/pulp/api/v3/content/file/files/c4ed74cf-a806-490d-a25f-94c3c3dd2dd7/"
        )

        with self.assertRaises(ApiException) as ctx:
            self.repo_ver_api.list(content=non_existant_content_href)

        self.assertEqual(ctx.exception.status, 400)

        # No repository version exists.
        self.assertEqual(self.repo_ver_api.list().count, 0)

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

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

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

        body = gen_file_remote(url=FILE2_FIXTURE_MANIFEST_URL)
        remote_second = self.remote_api.create(body)
        self.addCleanup(self.remote_api.delete, remote_second.pulp_href)

        repo_sync_data = RepositorySyncURL(remote=remote.pulp_href)
        repo_sync_data_second = RepositorySyncURL(
            remote=remote_second.pulp_href)

        sync_response = self.repo_api.sync(repo.pulp_href, repo_sync_data)
        monitor_task(sync_response.task)

        sync_response_second = self.repo_api.sync(repo_second.pulp_href,
                                                  repo_sync_data_second)
        monitor_task(sync_response_second.task)

        # Update repository data and get one content unit from first repository.
        repo = self.repo_api.read(repo.pulp_href)
        content_href = get_content(
            repo.to_dict())[FILE_CONTENT_NAME][0]["pulp_href"]

        rv_total = len(self.repo_ver_api.list().to_dict()["results"])
        rv_search = self.repo_ver_api.list(
            content=content_href).to_dict()["results"]

        # Test only one repostiory version has selected content.
        self.assertEqual(len(rv_search), 1)
        # Test if repositories version with content matches.
        self.assertEqual(rv_search[0]["pulp_href"], repo.latest_version_href)
        # Test total number of repository version. Two for each repository.
        self.assertEqual(rv_total, 4)
Exemplo n.º 18
0
 def test_03_fail_duplicate_content_unit(self):
     """Create content unit."""
     with NamedTemporaryFile() as temp_file:
         temp_file.write(self.file)
         temp_file.flush()
         response = self.content_api.create(**self.attrs, file=temp_file.name)
     with self.assertRaises(PulpTaskError) as exc:
         monitor_task(response.task)
     error = exc.exception.task.error
     for key in ("already", "relative", "path", "sha256"):
         self.assertIn(key, error["description"].lower(), error)
Exemplo n.º 19
0
 def test_04_fully_update(self):
     """Update a remote using HTTP PUT."""
     body = _gen_verbose_remote()
     response = self.remote_api.update(self.remote.pulp_href, body)
     monitor_task(response.task)
     for key in ("username", "password"):
         del body[key]
     type(self).remote = self.remote_api.read(self.remote.pulp_href)
     for key, val in body.items():
         with self.subTest(key=key):
             self.assertEqual(self.remote.to_dict()[key], val, key)
Exemplo n.º 20
0
    def do_test(self, with_sqlite):
        """Sync and publish an RPM repository."""
        # 1. create repo and remote
        repo = self.repo_api.create(gen_repo())
        self.addCleanup(self.repo_api.delete, repo.pulp_href)

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

        # 2. Sync it
        repository_sync_data = RpmRepositorySyncURL(remote=remote.pulp_href)
        sync_response = self.repo_api.sync(repo.pulp_href,
                                           repository_sync_data)
        monitor_task(sync_response.task)

        # 3. Publish and distribute
        publish_data = RpmRpmPublication(repository=repo.pulp_href,
                                         sqlite_metadata=with_sqlite)
        publish_response = self.publications.create(publish_data)
        created_resources = monitor_task(
            publish_response.task).created_resources
        publication_href = created_resources[0]
        self.addCleanup(self.publications.delete, publication_href)

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

        repomd = ElementTree.fromstring(
            http_get(os.path.join(distribution.base_url,
                                  "repodata/repomd.xml")))

        data_xpath = "{{{}}}data".format(RPM_NAMESPACES["metadata/repo"])
        data_elems = [elem for elem in repomd.findall(data_xpath)]

        sqlite_files = [
            elem for elem in data_elems if elem.get("type").endswith("_db")
        ]

        if with_sqlite:
            self.assertEqual(3, len(sqlite_files))

            for db_elem in sqlite_files:
                location_xpath = "{{{}}}location".format(
                    RPM_NAMESPACES["metadata/repo"])
                db_href = db_elem.find(location_xpath).get("href")
                http_get(os.path.join(distribution.base_url, db_href))
        else:
            self.assertEqual(0, len(sqlite_files))
Exemplo n.º 21
0
    def do_sync(self, download_policy):
        """Sync repositories with the different ``download_policy``.

        Do the following:

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

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

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

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

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

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

        self.assertEqual(latest_version_href, repo.latest_version_href)
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             DEB_FIXTURE_SUMMARY)
Exemplo n.º 22
0
    def setUpClass(cls):
        """Create class-wide variables."""
        cls.cfg = config.get_config()
        cls.api_client = ApiClient(configuration)
        cls.cli_client = cli.Client(cls.cfg)
        cls.orphans_cleanup_api = OrphansCleanupApi(core_client)
        cls.storage = utils.get_pulp_setting(cls.cli_client, "DEFAULT_FILE_STORAGE")
        cls.media_root = utils.get_pulp_setting(cls.cli_client, "MEDIA_ROOT")

        orphans_response = cls.orphans_cleanup_api.cleanup({"orphan_protection_time": 0})
        monitor_task(orphans_response.task)
Exemplo n.º 23
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)
Exemplo n.º 24
0
    def do_sync(self, sync_udebs, fixture_summary):
        """Sync repositories with the deb plugin.

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

        Do the following:

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

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

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

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

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

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

        self.assertEqual(latest_version_href, repo.latest_version_href)
        self.assertDictEqual(get_content_summary(repo.to_dict()),
                             fixture_summary)
Exemplo n.º 25
0
 def test_delete(self):
     """Delete a pulpExporter."""
     exporter = self.exporter_api.create({
         "name": "test",
         "path": "/tmp/abc"
     })
     result = self.exporter_api.delete(exporter.pulp_href)
     monitor_task(result.task)
     with self.assertRaises(ApiException) as ae:
         self.exporter_api.read(exporter.pulp_href)
     self.assertEqual(404, ae.exception.status)
Exemplo n.º 26
0
    def test_remove_all_repo_labels(self):
        """Test removing all labels."""
        labels = {"maiar": "mithrandir", "valar": "varda"}
        self._create_repo(labels)

        resp = self.repo_api.partial_update(self.repo.pulp_href,
                                            {"pulp_labels": {}})
        monitor_task(resp.task)
        self.repo = self.repo_api.read(self.repo.pulp_href)
        self.assertEqual(0, len(self.repo.pulp_labels))
        self.assertEqual({}, self.repo.pulp_labels)
Exemplo n.º 27
0
    def test_purge_only_failed(self):
        """Purge all failed tasks only."""
        dta = Purge(finished_before=TOMORROW_STR, states=["failed"])
        response = self.task_api.purge(dta)
        monitor_task(response.task)
        # completed sync-task should exist
        self.task_api.read(self.completed_sync_task.pulp_href)

        # failed should not exist
        with self.assertRaises(ApiException):
            self.task_api.read(self.failed_sync_task.pulp_href)
Exemplo n.º 28
0
    def setUp(self):
        """Create a new repository before each test."""
        body = gen_file_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)
Exemplo n.º 29
0
 def test_timeout_attributes_reset_to_empty(self):
     # Test reset to empty
     data = {
         "total_timeout": False,
         "connect_timeout": None,
         "sock_connect_timeout": False,
         "sock_read_timeout": None,
     }
     response = self.remotes_api.partial_update(self.remote.pulp_href, data)
     monitor_task(response.task)
     new_remote = self.remotes_api.read(self.remote.pulp_href)
     self._compare_results(data, new_remote)
Exemplo n.º 30
0
    def test_purge_defaults(self):
        """Purge using defaults (finished_before=30-days-ago, state=completed)"""
        dta = Purge()
        response = self.task_api.purge(dta)
        monitor_task(response.task)

        # default is "completed before 30 days ago" - so both sync tasks should still exist
        # Make sure good sync-task still exists
        self.task_api.read(self.completed_sync_task.pulp_href)

        # Make sure the failed sync still exists
        self.task_api.read(self.failed_sync_task.pulp_href)