Skip to content

Commit ab85534

Browse files
gerrod3ggainey
authored andcommitted
Fix replicate not creating distributions
(cherry picked from commit 2d6e19d)
1 parent ae785ba commit ab85534

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a replicate issue failing to create the distributions when using pulpcore>=3.70

pulp_container/app/replica.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def remote_extra_fields(self, upstream_distribution):
3838
upstream_name = upstream_distribution["registry_path"].split("/", 1)[1]
3939
return {"upstream_name": upstream_name}
4040

41-
def distribution_data(self, repository, upstream_distribution):
41+
def distribution_extra_fields(self, repository, upstream_distribution):
4242
"""
4343
Return the fields that need to be updated/cleared on distributions for idempotence.
4444
"""

pulp_container/tests/functional/api/test_domains.py

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import pytest
22
import uuid
33
from subprocess import CalledProcessError
4-
from pulp_container.tests.functional.constants import REGISTRY_V2_REPO_PULP
4+
from pulp_container.tests.functional.constants import (
5+
REGISTRY_V2_REPO_PULP,
6+
PULP_FIXTURE_1,
7+
PULP_HELLO_WORLD_REPO,
8+
)
59

610

711
@pytest.fixture
@@ -319,3 +323,63 @@ def test_cross_domain_pulp_apis(
319323
"future_base_path": "test",
320324
},
321325
)
326+
327+
328+
@pytest.mark.parallel
329+
def test_domain_content_replication(
330+
cdomain_factory,
331+
bindings_cfg,
332+
pulp_settings,
333+
pulpcore_bindings,
334+
container_bindings,
335+
container_sync,
336+
container_repository_factory,
337+
container_remote_factory,
338+
container_distribution_factory,
339+
monitor_task_group,
340+
gen_object_with_cleanup,
341+
add_to_cleanup,
342+
):
343+
"""Test replication feature through the usage of domains."""
344+
# Set up source domain to replicate from
345+
source_domain = cdomain_factory()
346+
for name in [PULP_FIXTURE_1, PULP_HELLO_WORLD_REPO]:
347+
repo = container_repository_factory(pulp_domain=source_domain.name)
348+
remote = container_remote_factory(pulp_domain=source_domain.name, upstream_name=name)
349+
container_sync(repo, remote)
350+
container_distribution_factory(repository=repo.pulp_href, pulp_domain=source_domain.name)
351+
352+
# Create the replica domain
353+
replica_domain = cdomain_factory()
354+
upstream_pulp_body = {
355+
"name": str(uuid.uuid4()),
356+
"base_url": bindings_cfg.host,
357+
"api_root": pulp_settings.API_ROOT,
358+
"domain": source_domain.name,
359+
"username": bindings_cfg.username,
360+
"password": bindings_cfg.password,
361+
"tls_validation": False,
362+
}
363+
upstream_pulp = gen_object_with_cleanup(
364+
pulpcore_bindings.UpstreamPulpsApi, upstream_pulp_body, pulp_domain=replica_domain.name
365+
)
366+
# Run the replicate task and assert that all tasks successfully complete.
367+
response = pulpcore_bindings.UpstreamPulpsApi.replicate(upstream_pulp.pulp_href)
368+
monitor_task_group(response.task_group)
369+
370+
counts = {}
371+
for api_client in (
372+
container_bindings.ContentManifestsApi,
373+
container_bindings.ContentBlobsApi,
374+
container_bindings.ContentTagsApi,
375+
container_bindings.RepositoriesContainerApi,
376+
container_bindings.RemotesContainerApi,
377+
container_bindings.DistributionsContainerApi,
378+
):
379+
source_result = api_client.list(pulp_domain=source_domain.name)
380+
replica_result = api_client.list(pulp_domain=replica_domain.name)
381+
counts[api_client] = (source_result.count, replica_result.count)
382+
for item in replica_result.results:
383+
add_to_cleanup(api_client, item.pulp_href)
384+
385+
assert all(x[0] == x[1] for x in counts.values()), f"Replica had differing counts {counts}"

0 commit comments

Comments
 (0)