本文整理汇总了Python中pulp_smash.config.get_config函数的典型用法代码示例。如果您正苦于以下问题:Python get_config函数的具体用法?Python get_config怎么用?Python get_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpModule
def setUpModule(): # pylint:disable=invalid-name
"""Possibly skip tests. Create and sync an RPM repository.
Skip tests in this module if the RPM plugin is not installed on the target
Pulp server. Then create an RPM repository with a feed and sync it. Test
cases may copy data from this repository but should **not** change it.
"""
set_up_module()
cfg = config.get_config()
client = cli.Client(config.get_config())
# log in, then create repository
utils.pulp_admin_login(cfg)
client.run(
'pulp-admin rpm repo create --repo-id {} --feed {}'
.format(_REPO_ID, constants.RPM_SIGNED_FEED_URL).split()
)
# If setUpModule() fails, tearDownModule() isn't run. In addition, we can't
# use addCleanup(), as it's an instance method. If this set-up procedure
# grows, consider implementing a stack of tear-down steps instead.
try:
client.run(
'pulp-admin rpm repo sync run --repo-id {}'
.format(_REPO_ID).split()
)
except subprocess.CalledProcessError:
client.run(
'pulp-admin rpm repo delete --repo-id {}'.format(_REPO_ID).split()
)
raise
示例2: setUpModule
def setUpModule(): # pylint:disable=invalid-name
"""Conditionally skip tests."""
if selectors.bug_is_untestable(1991, config.get_config().version):
raise unittest.SkipTest('https://pulp.plan.io/issues/1991')
if selectors.bug_is_untestable(2242, config.get_config().version):
raise unittest.SkipTest('https://pulp.plan.io/issues/2242')
set_up_module()
示例3: test_upload
def test_upload(self):
"""Create a repository and upload DRPMs into it.
Specifically, do the following:
1. Create a yum repository.
2. Download a DRPM file.
3. Upload the DRPM into it. Use ``pulp-admin`` to verify its presence
in the repository.
4. Upload the same DRPM into the same repository, and use the
``--skip-existing`` flag during the upload. Verify that Pulp skips
the upload.
"""
if selectors.bug_is_untestable(1806, config.get_config().version):
self.skipTest('https://pulp.plan.io/issues/1806')
# Create a repository
client = cli.Client(config.get_config())
repo_id = utils.uuid4()
client.run(
'pulp-admin rpm repo create --repo-id {}'.format(repo_id).split()
)
self.addCleanup(
client.run,
'pulp-admin rpm repo delete --repo-id {}'.format(repo_id).split()
)
# Create a temporary directory, and download a DRPM file into it
temp_dir = client.run('mktemp --directory'.split()).stdout.strip()
self.addCleanup(client.run, 'rm -rf {}'.format(temp_dir).split())
drpm_file = os.path.join(temp_dir, os.path.split(DRPM)[-1])
client.run(
'curl -o {} {}'.format(drpm_file, DRPM_UNSIGNED_URL).split()
)
# Upload the DRPM into the repository. Don't use subTest, as if this
# test fails, the following one is invalid anyway.
client.run(
'pulp-admin rpm repo uploads drpm --repo-id {} --file {}'
.format(repo_id, drpm_file).split()
)
proc = client.run(
'pulp-admin rpm repo content drpm --repo-id {} --fields filename'
.format(repo_id).split()
)
self.assertEqual(proc.stdout.split('Filename:')[1].strip(), DRPM)
# Upload the DRPM into the repository. Pass --skip-existing.
proc = client.run(
('pulp-admin rpm repo uploads drpm --repo-id {} --file {} '
'--skip-existing')
.format(repo_id, drpm_file).split()
)
self.assertIn('No files eligible for upload', proc.stdout)
示例4: test_all
def test_all(self):
"""Test whether the content present in a repo version is immutable.
Do the following:
1. Create a repository that has at least one repository version.
2. Attempt to update the content of a repository version.
3. Assert that an HTTP exception is raised.
4. Assert that the repository version was not updated.
"""
cfg = config.get_config()
client = api.Client(cfg, api.json_handler)
repo = client.post(REPO_PATH, gen_repo())
self.addCleanup(client.delete, repo['_href'])
body = gen_file_remote()
remote = client.post(FILE_REMOTE_PATH, body)
self.addCleanup(client.delete, remote['_href'])
sync(cfg, remote, repo)
latest_version_href = client.get(repo['_href'])['_latest_version_href']
with self.assertRaises(HTTPError):
client.post(latest_version_href)
repo = client.get(repo['_href'])
self.assertEqual(latest_version_href, repo['_latest_version_href'])
示例5: setUp
def setUp(self):
"""Provide a server config and Pulp services to stop and start."""
self.cfg = config.get_config()
self.broker = utils.get_broker(self.cfg)
self.services = tuple((
cli.Service(self.cfg, service) for service in PULP_SERVICES
))
示例6: test_all
def test_all(self):
"""Publish the rpm rsync distributor before the yum distributor."""
cfg = config.get_config()
if selectors.bug_is_untestable(2187, cfg.version):
self.skipTest('https://pulp.plan.io/issues/2187')
# Create a user and a repository.
ssh_user, priv_key = self.make_user(cfg)
ssh_identity_file = self.write_private_key(cfg, priv_key)
repo = self.make_repo(cfg, {'remote': {
'host': urlparse(cfg.base_url).netloc,
'root': '/home/' + ssh_user,
'ssh_identity_file': ssh_identity_file,
'ssh_user': ssh_user,
}})
# Publish with the rsync distributor.
distribs = _get_dists_by_type_id(cfg, repo['_href'])
self.verify_publish_is_skip(cfg, utils.publish_repo(
cfg,
repo,
{'id': distribs['rpm_rsync_distributor']['id']}
).json())
# Verify that the rsync distributor hasn't placed files
sudo = '' if utils.is_root(cfg) else 'sudo '
cmd = (sudo + 'ls -1 /home/{}'.format(ssh_user)).split()
dirs = set(cli.Client(cfg).run(cmd).stdout.strip().split('\n'))
self.assertNotIn('content', dirs)
示例7: setUpClass
def setUpClass(cls):
"""Make calls to the server and save the responses."""
client = api.Client(config.get_config(), api.echo_handler)
cls.responses = {
key: client.post(path, {key + '_criteriaa': {}})
for key, path in _PATHS.items()
}
示例8: test_sync_downloaded_content
def test_sync_downloaded_content(self):
"""Create two repositories with the same feed, and sync them serially.
More specifically, this test creates two puppet repositories with
identical feeds, syncs them serially, and verifies that both have equal
non-zero content unit counts.
"""
cfg = config.get_config()
if selectors.bug_is_untestable(1937, cfg.version):
self.skipTest('https://pulp.plan.io/issues/1937')
utils.pulp_admin_login(cfg)
# Create two repos, schedule them for deletion, and sync them.
client = cli.Client(cfg)
repo_ids = [utils.uuid4() for _ in range(2)]
for repo_id in repo_ids:
client.run((
'pulp-admin puppet repo create '
'--repo-id {} --feed {} --queries {}'
).format(repo_id, PUPPET_FEED, PUPPET_QUERY).split())
self.addCleanup(client.run, (
'pulp-admin puppet repo delete --repo-id {}'
).format(repo_id).split())
client.run((
'pulp-admin puppet repo sync run --repo-id {}'
).format(repo_id).split())
# Verify the number of puppet modules in each repository.
unit_counts = [
get_num_units_in_repo(cfg, repo_id) for repo_id in repo_ids
]
for i, unit_count in enumerate(unit_counts):
with self.subTest(i=i):
self.assertGreater(unit_count, 0)
self.assertEqual(unit_counts[0], unit_counts[1])
示例9: setUpModule
def setUpModule(): # pylint:disable=invalid-name
"""Conditionally skip tests. Create repositories with fixture data."""
cfg = config.get_config()
if selectors.bug_is_untestable(1991, cfg.version):
raise unittest.SkipTest('https://pulp.plan.io/issues/1991')
set_up_module()
# Fetch RPMs.
_SIGNED_PACKAGES['rpm'] = utils.http_get(RPM_URL)
_SIGNED_PACKAGES['srpm'] = utils.http_get(SRPM_URL)
_UNSIGNED_PACKAGES['rpm'] = utils.http_get(RPM_UNSIGNED_URL)
_UNSIGNED_PACKAGES['srpm'] = utils.http_get(SRPM_UNSIGNED_URL)
if selectors.bug_is_testable(1806, cfg.version):
_SIGNED_PACKAGES['drpm'] = utils.http_get(DRPM_URL)
_UNSIGNED_PACKAGES['drpm'] = utils.http_get(DRPM_UNSIGNED_URL)
# Create repos, and upload RPMs to them.
client = api.Client(cfg, api.json_handler)
try:
repo = client.post(REPOSITORY_PATH, gen_repo())
_REPOS['signed'] = repo
for type_id, pkg in _SIGNED_PACKAGES.items():
utils.upload_import_unit(cfg, pkg, type_id, repo['_href'])
repo = client.post(REPOSITORY_PATH, gen_repo())
_REPOS['unsigned'] = repo
for type_id, pkg in _UNSIGNED_PACKAGES.items():
utils.upload_import_unit(cfg, pkg, type_id, repo['_href'])
except:
_SIGNED_PACKAGES.clear()
_UNSIGNED_PACKAGES.clear()
for _ in range(len(_REPOS)):
client.delete(_REPOS.popitem()[1]['_href'])
raise
示例10: test_all
def test_all(self):
"""Execute the test case business logic."""
cfg = config.get_config()
self.check_issue_2363(cfg)
repo_href = self.create_repo(cfg, RPM_MIRRORLIST_BAD, _gen_rel_url())
with self.assertRaises(TaskReportError):
utils.sync_repo(cfg, repo_href)
示例11: test_file_decriptors
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.
"""
cfg = config.get_config()
client = api.Client(cfg, api.json_handler)
cli_client = cli.Client(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 = client.post(REPO_PATH, gen_repo())
self.addCleanup(client.delete, repo['_href'])
remote = client.post(RPM_REMOTE_PATH, gen_rpm_remote())
self.addCleanup(client.delete, remote['_href'])
sync(cfg, remote, repo)
cmd = 'lsof -t +D {}'.format(MEDIA_PATH).split()
response = cli_client.run(cmd).stdout
self.assertEqual(len(response), 0, response)
示例12: test_force_sync
def test_force_sync(self):
"""Test whether one can force Pulp to perform a full sync."""
cfg = config.get_config()
if selectors.bug_is_untestable(1982, cfg.version):
self.skipTest("https://pulp.plan.io/issues/1982")
# Create and sync a repository.
client = cli.Client(cfg)
repo_id = utils.uuid4()
client.run("pulp-admin rpm repo create --repo-id {} --feed {}".format(repo_id, RPM_SIGNED_FEED_URL).split())
self.addCleanup(client.run, "pulp-admin rpm repo delete --repo-id {}".format(repo_id).split())
sync_repo(cfg, repo_id)
# Delete a random RPM
rpms = self._list_rpms(cfg)
client.run("{} rm -rf {}".format("sudo" if not is_root(cfg) else "", random.choice(rpms)).split())
with self.subTest(comment="Verify the RPM was removed."):
self.assertEqual(len(self._list_rpms(cfg)), len(rpms) - 1)
# Sync the repository *without* force_sync.
sync_repo(cfg, repo_id)
with self.subTest(comment="Verify the RPM has not been restored."):
self.assertEqual(len(self._list_rpms(cfg)), len(rpms) - 1)
# Sync the repository again
sync_repo(cfg, repo_id, force_sync=True)
with self.subTest(comment="Verify the RPM has been restored."):
self.assertEqual(len(self._list_rpms(cfg)), len(rpms))
示例13: test_all
def test_all(self):
"""Recursively copy a "chimpanzee" unit from one repository to another.
"chimpanzee" depends on "walrus," and there are multiple versions of
"walrus" in the source repository. Verify that one "walrus" unit has
been copied to the target repository, and that the newer one has been
copied.
"""
cfg = config.get_config()
repo_id = self.create_repo(cfg)
cli.Client(cfg).run(
'pulp-admin rpm repo copy rpm --from-repo-id {} --to-repo-id {} '
'--str-eq name=chimpanzee --recursive'
.format(_REPO_ID, repo_id).split()
)
# Verify only one "walrus" unit has been copied
dst_rpms = _get_rpm_names_versions(cfg, repo_id)
self.assertIn('walrus', dst_rpms)
self.assertEqual(len(dst_rpms['walrus']), 1, dst_rpms)
# Verify the version of the "walrus" unit
src_rpms = _get_rpm_names_versions(cfg, _REPO_ID)
src_rpms['walrus'].sort(key=lambda ver: Version(ver)) # noqa pylint:disable=unnecessary-lambda
self.assertEqual(src_rpms['walrus'][-1], dst_rpms['walrus'][0])
示例14: test_all
def test_all(self):
"""Test whether sync/publish for content already in Pulp."""
cfg = config.get_config()
client = api.Client(cfg, api.page_handler)
# step 1. delete orphans to assure that no content is present on disk,
# or database.
delete_orphans(cfg)
remote = client.post(
FILE_REMOTE_PATH,
gen_remote(FILE_FIXTURE_MANIFEST_URL)
)
self.addCleanup(client.delete, remote['_href'])
repo = client.post(REPO_PATH, gen_repo())
self.addCleanup(client.delete, repo['_href'])
publisher = client.post(FILE_PUBLISHER_PATH, gen_publisher())
self.addCleanup(client.delete, publisher['_href'])
for _ in range(2):
sync(cfg, remote, repo)
repo = client.get(repo['_href'])
publish(cfg, publisher, repo)
示例15: setUpClass
def setUpClass(cls):
"""Create class-wide variables."""
cls.cfg = config.get_config()
delete_orphans(cls.cfg)
populate_pulp(cls.cfg, url=FILE_LARGE_FIXTURE_MANIFEST_URL)
cls.client = api.Client(cls.cfg, api.page_handler)
cls.content = cls.client.get(FILE_CONTENT_PATH)