Пример #1
0
    def test_clean_orphan_artifact(self):
        """Test whether orphan artifacts units can be clean up."""
        repo_api = RepositoriesFileApi(self.api_client)
        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

        artifacts_api = ArtifactsApi(core_client)
        artifact = artifacts_api.create(file=__file__)

        if self.storage == "pulpcore.app.models.storage.FileSystem":
            cmd = ("ls", os.path.join(self.media_root, artifact.file))
            self.cli_client.run(cmd, sudo=True)

        orphans_response = self.orphans_cleanup_api.cleanup({"orphan_protection_time": 10})
        monitor_task(orphans_response.task)

        # assert artifact was not removed
        artifacts = artifacts_api.list().count
        self.assertEqual(artifacts, 1)

        orphans_response = self.orphans_cleanup_api.cleanup({"orphan_protection_time": 0})
        monitor_task(orphans_response.task)

        with self.assertRaises(ApiException):
            artifacts_api.read(artifact.pulp_href)

        if self.storage == "pulpcore.app.models.storage.FileSystem":
            with self.assertRaises(CalledProcessError):
                self.cli_client.run(cmd)
Пример #2
0
    def test_clean_orphan_artifact(self):
        """Test whether orphan artifacts units can be clean up."""
        repo_api = RepositoriesFileApi(self.api_client)
        repo = repo_api.create(gen_repo())
        self.addCleanup(repo_api.delete, repo.pulp_href)

        artifacts_api = ArtifactsApi(core_client)
        artifact = artifacts_api.create(file=__file__)

        if self.storage == "pulpcore.app.models.storage.FileSystem":
            cmd = ("ls", os.path.join(MEDIA_PATH, artifact.file))
            self.cli_client.run(cmd, sudo=True)

        delete_orphans()

        with self.assertRaises(ApiException):
            artifacts_api.read(artifact.pulp_href)

        if self.storage == "pulpcore.app.models.storage.FileSystem":
            with self.assertRaises(CalledProcessError):
                self.cli_client.run(cmd)
Пример #3
0
# Sync a Repository
repository_sync_data = RepositorySyncURL(repository=repository.pulp_href)
sync_response = fileremotes.sync(file_remote.pulp_href, repository_sync_data)

pprint(sync_response)

# Monitor the sync task
created_resources = monitor_task(sync_response.task)

repository_version_1 = repoversions.read(created_resources[0])
pprint(repository_version_1)

# Create an artifact from a local file
file_path = os.path.join(os.environ['TRAVIS_BUILD_DIR'], '.travis/test_bindings.py')
artifact = artifacts.create(file=file_path)
pprint(artifact)

# Create a FileContent from the artifact
filecontent_response = filecontent.create(relative_path='foo.tar.gz', artifact=artifact.pulp_href)
created_resources = monitor_task(filecontent_response.task)

# Add the new FileContent to a repository version
repo_version_data = {'add_content_units': [created_resources[0]]}
repo_version_response = repoversions.create(repository.pulp_href, repo_version_data)

# Monitor the repo version creation task
created_resources = monitor_task(repo_version_response.task)

repository_version_2 = repoversions.read(created_resources[0])
pprint(repository_version_2)