本文整理汇总了Python中atomic_reactor.plugin.ExitPluginsRunner类的典型用法代码示例。如果您正苦于以下问题:Python ExitPluginsRunner类的具体用法?Python ExitPluginsRunner怎么用?Python ExitPluginsRunner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExitPluginsRunner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_labels_metadata_plugin
def test_labels_metadata_plugin(tmpdir, koji_plugin, reactor_config_map):
koji_build_id = 1234
workflow = prepare(reactor_config_map=reactor_config_map)
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
workflow.builder.df_path = df.dockerfile_path
workflow.builder.df_dir = str(tmpdir)
workflow.exit_results = {
koji_plugin: koji_build_id,
}
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
output = runner.run()
assert StoreMetadataInOSv3Plugin.key in output
labels = output[StoreMetadataInOSv3Plugin.key]["labels"]
assert "koji-build-id" in labels
assert is_string_type(labels["koji-build-id"])
assert int(labels["koji-build-id"]) == koji_build_id
示例2: test_missing_koji_build_id
def test_missing_koji_build_id(tmpdir, reactor_config_map): # noqa
workflow = prepare(reactor_config_map=reactor_config_map)
workflow.exit_results = {}
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
workflow.builder.df_path = df.dockerfile_path
workflow.builder.df_dir = str(tmpdir)
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
output = runner.run()
assert StoreMetadataInOSv3Plugin.key in output
labels = output[StoreMetadataInOSv3Plugin.key]["labels"]
assert "koji-build-id" not in labels
示例3: test_filter_nonpulp_repositories
def test_filter_nonpulp_repositories(tmpdir, pulp_registries, docker_registries,
is_orchestrator, expected, reactor_config_map):
workflow = prepare(pulp_registries=pulp_registries,
docker_registries=docker_registries,
reactor_config_map=reactor_config_map)
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
workflow.builder.df_path = df.dockerfile_path
workflow.builder.df_dir = str(tmpdir)
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
if is_orchestrator:
workflow.buildstep_result[OrchestrateBuildPlugin.key] = 'foo'
output = runner.run()
assert StoreMetadataInOSv3Plugin.key in output
annotations = output[StoreMetadataInOSv3Plugin.key]["annotations"]
repositories = json.loads(annotations['repositories'])
assert repositories == expected
示例4: test_metadata_plugin_rpmqa_failure
def test_metadata_plugin_rpmqa_failure(tmpdir, reactor_config_map): # noqa
initial_timestamp = datetime.now()
workflow = prepare(reactor_config_map=reactor_config_map)
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
workflow.builder.df_path = df.dockerfile_path
workflow.builder.df_dir = str(tmpdir)
workflow.prebuild_results = {}
workflow.postbuild_results = {
PostBuildRPMqaPlugin.key: RuntimeError(),
PLUGIN_KOJI_UPLOAD_PLUGIN_KEY: {'metadata_fragment_key': 'metadata.json',
'metadata_fragment': 'configmap/build-1-md'}
}
workflow.plugins_timestamps = {
PostBuildRPMqaPlugin.key: (initial_timestamp + timedelta(seconds=3)).isoformat(),
PLUGIN_KOJI_UPLOAD_PLUGIN_KEY: (initial_timestamp + timedelta(seconds=3)).isoformat(),
}
workflow.plugins_durations = {
PostBuildRPMqaPlugin.key: 3.03,
PLUGIN_KOJI_UPLOAD_PLUGIN_KEY: 3.03,
}
workflow.plugins_errors = {
PostBuildRPMqaPlugin.key: 'foo',
PLUGIN_KOJI_UPLOAD_PLUGIN_KEY: 'bar',
}
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
output = runner.run()
assert StoreMetadataInOSv3Plugin.key in output
annotations = output[StoreMetadataInOSv3Plugin.key]["annotations"]
assert "dockerfile" in annotations
assert "repositories" in annotations
assert "commit_id" in annotations
assert "base-image-id" in annotations
assert "base-image-name" in annotations
assert "image-id" in annotations
assert "metadata_fragment" in annotations
assert "metadata_fragment_key" in annotations
assert "plugins-metadata" in annotations
assert "errors" in annotations["plugins-metadata"]
assert "durations" in annotations["plugins-metadata"]
assert "timestamps" in annotations["plugins-metadata"]
plugins_metadata = json.loads(annotations["plugins-metadata"])
assert "all_rpm_packages" in plugins_metadata["errors"]
assert "all_rpm_packages" in plugins_metadata["durations"]
示例5: test_delete_from_registry_plugin
def test_delete_from_registry_plugin(saved_digests, req_registries, tmpdir):
if MOCK:
mock_docker()
tasker = DockerTasker()
workflow = DockerBuildWorkflow({"provider": "git", "uri": "asd"}, TEST_IMAGE)
setattr(workflow, 'builder', X)
args_registries = {}
for reg, use_secret in req_registries.items():
if use_secret:
temp_dir = mkdtemp(dir=str(tmpdir))
with open(os.path.join(temp_dir, ".dockercfg"), "w+") as dockerconfig:
dockerconfig_contents = {
reg: {
"username": "user", "password": reg
}
}
dockerconfig.write(json.dumps(dockerconfig_contents))
dockerconfig.flush()
args_registries[reg] = { 'secret': temp_dir }
else:
args_registries[reg] = {}
for reg, digests in saved_digests.items():
r = DockerRegistry(reg)
for tag, dig in digests.items():
r.digests[tag] = ManifestDigest(v1='not-used', v2=dig)
workflow.push_conf._registries['docker'].append(r)
runner = ExitPluginsRunner(
tasker,
workflow,
[{
'name': DeleteFromRegistryPlugin.key,
'args': {
'registries': args_registries
},
}]
)
deleted_digests = set()
for reg, digests in saved_digests.items():
if reg not in req_registries:
continue
for tag, dig in digests.items():
if dig in deleted_digests:
continue
url = "https://" + reg + "/v2/" + tag.split(":")[0] + "/manifests/" + dig
auth_type = requests.auth.HTTPBasicAuth if req_registries[reg] else None
(flexmock(requests)
.should_receive('delete')
.with_args(url, verify=bool, auth=auth_type)
.once()
.and_return(flexmock(status_code=202)))
deleted_digests.add(dig)
result = runner.run()
assert result[DeleteFromRegistryPlugin.key] == deleted_digests
示例6: test_labels_metadata_plugin
def test_labels_metadata_plugin(tmpdir):
koji_build_id = 1234
workflow = prepare()
workflow.exit_results = {
KojiPromotePlugin.key: koji_build_id,
}
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
output = runner.run()
assert StoreMetadataInOSv3Plugin.key in output
labels = output[StoreMetadataInOSv3Plugin.key]["labels"]
assert "koji-build-id" in labels
assert is_string_type(labels["koji-build-id"])
assert int(labels["koji-build-id"]) == koji_build_id
示例7: test_metadata_plugin
def test_metadata_plugin(tmpdir):
workflow = prepare()
workflow.prebuild_results = {
CpDockerfilePlugin.key: "dockerfile-content",
DistgitFetchArtefactsPlugin.key: "artefact1\nartefact2",
}
workflow.postbuild_results = {
PostBuildRPMqaPlugin.key: "rpm1\nrpm2",
}
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
output = runner.run()
assert StoreMetadataInOSv3Plugin.key in output
labels = output[StoreMetadataInOSv3Plugin.key]
assert "dockerfile" in labels
assert "artefacts" in labels
assert "logs" in labels
assert "rpm-packages" in labels
assert "repositories" in labels
assert "commit_id" in labels
示例8: test_remove_worker_plugin
def test_remove_worker_plugin(tmpdir, caplog, names, fragment_key):
workflow = mock_workflow(tmpdir)
koji_metadata = {
'foo': 'bar',
'spam': 'bacon',
}
metadata = {'metadata.json': koji_metadata}
for name in names:
osbs = MockOSBS({name: metadata})
defer_removal(workflow, name, osbs)
(flexmock(osbs)
.should_call("delete_config_map")
.with_args(name)
.once()
.and_return(True))
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': PLUGIN_REMOVE_WORKER_METADATA_KEY,
"args": {}
}]
)
runner.run()
for name in names:
if name:
assert "ConfigMap {} deleted".format(name) in caplog.text
else:
assert "Failed to delete ConfigMap None" in caplog.text
示例9: test_store_metadata_fail_update_annotations
def test_store_metadata_fail_update_annotations(tmpdir, caplog, reactor_config_map): # noqa
workflow = prepare(reactor_config_map=reactor_config_map)
workflow.exit_results = {}
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
workflow.builder.df_path = df.dockerfile_path
workflow.builder.df_dir = str(tmpdir)
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
(flexmock(OSBS)
.should_receive('update_annotations_on_build')
.and_raise(OsbsResponseException('/', 'failed', 0)))
with pytest.raises(PluginFailedException):
runner.run()
assert 'annotations:' in caplog.text
示例10: build_docker_image
def build_docker_image(self):
"""
build docker image
:return: BuildResults
"""
self.builder = InsideBuilder(self.source, self.image)
try:
# time to run pre-build plugins, so they can access cloned repo
logger.info("running pre-build plugins")
prebuild_runner = PreBuildPluginsRunner(self.builder.tasker, self, self.prebuild_plugins_conf,
plugin_files=self.plugin_files)
try:
prebuild_runner.run()
except PluginFailedException as ex:
logger.error("one or more prebuild plugins failed: %s", ex)
raise
build_result = self.builder.build()
self.build_logs = build_result.logs
self.build_failed = build_result.is_failed()
if not build_result.is_failed():
self.built_image_inspect = self.builder.inspect_built_image()
# run prepublish plugins
prepublish_runner = PrePublishPluginsRunner(self.builder.tasker, self, self.prepublish_plugins_conf,
plugin_files=self.plugin_files)
try:
prepublish_runner.run()
except PluginFailedException as ex:
logger.error("one or more prepublish plugins failed: %s", ex)
raise
if not build_result.is_failed():
for registry in self.push_conf.docker_registries:
self.builder.push_built_image(registry.uri,
insecure=registry.insecure)
postbuild_runner = PostBuildPluginsRunner(self.builder.tasker, self, self.postbuild_plugins_conf,
plugin_files=self.plugin_files)
try:
postbuild_runner.run()
except PluginFailedException as ex:
logger.error("one or more postbuild plugins failed: %s", ex)
raise
return build_result
finally:
self.source.remove_tmpdir()
exit_runner = ExitPluginsRunner(self.builder.tasker, self,
self.exit_plugins_conf,
plugin_files=self.plugin_files)
try:
exit_runner.run()
except PluginFailedException as ex:
logger.error("one or more exit plugins failed: %s", ex)
示例11: test_metadata_plugin
def test_metadata_plugin(tmpdir):
workflow = prepare()
workflow.prebuild_results = {
CpDockerfilePlugin.key: "dockerfile-content",
DistgitFetchArtefactsPlugin.key: "artefact1\nartefact2",
}
workflow.postbuild_results = {
PostBuildRPMqaPlugin.key: "rpm1\nrpm2",
}
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
output = runner.run()
assert StoreMetadataInOSv3Plugin.key in output
labels = output[StoreMetadataInOSv3Plugin.key]
assert "dockerfile" in labels
assert is_string_type(labels['dockerfile'])
assert "artefacts" in labels
assert is_string_type(labels['artefacts'])
assert "logs" in labels
assert is_string_type(labels['logs'])
assert "rpm-packages" in labels
assert is_string_type(labels['rpm-packages'])
assert "repositories" in labels
assert is_string_type(labels['repositories'])
assert "commit_id" in labels
assert is_string_type(labels['commit_id'])
assert "base-image-id" in labels
assert is_string_type(labels['base-image-id'])
assert "base-image-name" in labels
assert is_string_type(labels['base-image-name'])
assert "image-id" in labels
assert is_string_type(labels['image-id'])
assert "digests" in labels
assert is_string_type(labels['digests'])
digests = json.loads(labels['digests'])
expected = [{
"registry": DOCKER0_REGISTRY,
"repository": TEST_IMAGE,
"tag": 'latest',
"digest": DIGEST1,
},{
"registry": DOCKER0_REGISTRY,
"repository": "namespace/image",
"tag": 'asd123',
"digest": DIGEST2,
}]
assert digests == expected or digests == reversed(expected)
示例12: test_filter_repositories
def test_filter_repositories(tmpdir, pulp_registries, docker_registries,
prefixes, reactor_config_map):
workflow = prepare(pulp_registries=pulp_registries,
docker_registries=docker_registries,
reactor_config_map=reactor_config_map)
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
workflow.builder.df_path = df.dockerfile_path
workflow.builder.df_dir = str(tmpdir)
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
output = runner.run()
assert StoreMetadataInOSv3Plugin.key in output
annotations = output[StoreMetadataInOSv3Plugin.key]["annotations"]
repositories = json.loads(annotations['repositories'])
unique_repositories = repositories['unique']
primary_repositories = repositories['primary']
matched = set()
for prefix in prefixes:
for repo in unique_repositories:
if repo.startswith(prefix):
matched.add(repo)
assert matched == set(unique_repositories)
matched = set()
for prefix in prefixes:
for repo in primary_repositories:
if repo.startswith(prefix):
matched.add(repo)
assert matched == set(primary_repositories)
示例13: test_missing_koji_build_id
def test_missing_koji_build_id(tmpdir):
workflow = prepare()
workflow.exit_results = {}
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
output = runner.run()
assert StoreMetadataInOSv3Plugin.key in output
labels = output[StoreMetadataInOSv3Plugin.key]["labels"]
assert "koji-build-id" not in labels
示例14: test_store_metadata_fail_update_annotations
def test_store_metadata_fail_update_annotations(tmpdir, caplog):
workflow = prepare()
workflow.exit_results = {}
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
(flexmock(OSBS)
.should_receive('set_annotations_on_build')
.and_raise(OsbsResponseException('/', 'failed', 0)))
output = runner.run()
assert 'annotations:' in caplog.text()
示例15: test_arrangementv4_repositories
def test_arrangementv4_repositories(tmpdir, group_manifests, restore):
workflow = prepare()
df_content = """
FROM fedora
RUN yum install -y python-django
CMD blabla"""
df = df_parser(str(tmpdir))
df.content = df_content
workflow.builder = X
workflow.builder.df_path = df.dockerfile_path
workflow.builder.df_dir = str(tmpdir)
runner = ExitPluginsRunner(
None,
workflow,
[{
'name': StoreMetadataInOSv3Plugin.key,
"args": {
"url": "http://example.com/"
}
}]
)
worker_data = {
'repositories': {
'primary': ['worker:1'],
'unique': ['worker:unique'],
},
}
workflow.buildstep_result[OrchestrateBuildPlugin.key] = worker_data
workflow.build_result = BuildResult.make_remote_image_result(annotations=worker_data)
if group_manifests is not None:
workflow.postbuild_results[PLUGIN_GROUP_MANIFESTS_KEY] = group_manifests
output = runner.run()
assert StoreMetadataInOSv3Plugin.key in output
annotations = output[StoreMetadataInOSv3Plugin.key]["annotations"]
repositories = json.loads(annotations['repositories'])
if restore:
assert repositories != worker_data['repositories']
else:
assert repositories == worker_data['repositories']