-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #216
- Loading branch information
Showing
8 changed files
with
145 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added replica definitions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from pulpcore.plugin.replica import Replicator | ||
|
||
from pulp_glue.gem.context import ( | ||
PulpGemDistributionContext, | ||
PulpGemPublicationContext, | ||
PulpGemRepositoryContext, | ||
) | ||
|
||
from pulp_gem.app.models import GemDistribution, GemRemote, GemRepository | ||
from pulp_gem.app.tasks import synchronize as gem_synchronize | ||
|
||
|
||
class GemReplicator(Replicator): | ||
repository_ctx_cls = PulpGemRepositoryContext | ||
distribution_ctx_cls = PulpGemDistributionContext | ||
publication_ctx_cls = PulpGemPublicationContext | ||
app_label = "gem" | ||
remote_model_cls = GemRemote | ||
repository_model_cls = GemRepository | ||
distribution_model_cls = GemDistribution | ||
distribution_serializer_name = "GemDistributionSerializer" | ||
repository_serializer_name = "GemRepositorySerializer" | ||
remote_serializer_name = "GemRemoteSerializer" | ||
sync_task = gem_synchronize | ||
|
||
def url(self, upstream_distribution): | ||
if upstream_distribution["publication"]: | ||
return upstream_distribution["base_url"] | ||
else: | ||
# This distribution doesn't serve any content | ||
return None | ||
|
||
def sync_params(self, repository, remote): | ||
return dict( | ||
remote_pk=str(remote.pk), | ||
repository_pk=str(repository.pk), | ||
mirror=True, | ||
) | ||
|
||
|
||
REPLICATION_ORDER = [GemReplicator] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import pytest | ||
import uuid | ||
|
||
|
||
@pytest.mark.parallel | ||
def test_replication( | ||
domain_factory, | ||
bindings_cfg, | ||
pulpcore_bindings, | ||
monitor_task_group, | ||
pulp_settings, | ||
add_to_cleanup, | ||
gen_object_with_cleanup, | ||
gem_distribution_factory, | ||
gem_publication_factory, | ||
gem_repository_factory, | ||
gem_distribution_api_client, | ||
gem_remote_api_client, | ||
gem_repository_api_client, | ||
gem_content_api_client, | ||
gem_content_artifact, | ||
): | ||
# This test assures that an Upstream Pulp can be created in a non-default domain and that this | ||
# Upstream Pulp configuration can be used to execute the replicate task. | ||
|
||
# Create a domain to replicate from | ||
source_domain = domain_factory() | ||
|
||
# Create a domain as replica | ||
replica_domain = domain_factory() | ||
|
||
# Add stuff to it | ||
repository = gem_repository_factory(pulp_domain=source_domain.name) | ||
gem_content_api_client.create( | ||
file=gem_content_artifact, repository=repository, pulp_domain=source_domain.name | ||
) | ||
publication = gem_publication_factory( | ||
pulp_domain=source_domain.name, repository=repository.pulp_href | ||
) | ||
gem_distribution_factory(pulp_domain=source_domain.name, publication=publication.pulp_href) | ||
|
||
# Create an Upstream Pulp in the non-default domain | ||
upstream_pulp_body = { | ||
"name": str(uuid.uuid4()), | ||
"base_url": bindings_cfg.host, | ||
"api_root": pulp_settings.API_ROOT, | ||
"domain": source_domain.name, | ||
"username": bindings_cfg.username, | ||
"password": bindings_cfg.password, | ||
} | ||
upstream_pulp = gen_object_with_cleanup( | ||
pulpcore_bindings.UpstreamPulpsApi, upstream_pulp_body, pulp_domain=replica_domain.name | ||
) | ||
# Run the replicate task and assert that all tasks successfully complete. | ||
response = pulpcore_bindings.UpstreamPulpsApi.replicate(upstream_pulp.pulp_href) | ||
monitor_task_group(response.task_group) | ||
|
||
for api_client in ( | ||
gem_distribution_api_client, | ||
gem_remote_api_client, | ||
gem_repository_api_client, | ||
): | ||
result = api_client.list(pulp_domain=replica_domain.name) | ||
for item in result.results: | ||
add_to_cleanup(api_client, item) | ||
|
||
for api_client in ( | ||
gem_distribution_api_client, | ||
gem_remote_api_client, | ||
gem_repository_api_client, | ||
gem_content_api_client, | ||
): | ||
result = api_client.list(pulp_domain=replica_domain.name) | ||
assert result.count == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pulpcore>=3.39.0,<3.54 | ||
pulp_cli_gem>=0.3.0,<0.4.0 | ||
rubymarshal>=1.2.7,<1.3 |