|
1 | 1 | import pytest |
2 | 2 | import uuid |
3 | 3 | 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 | +) |
5 | 9 |
|
6 | 10 |
|
7 | 11 | @pytest.fixture |
@@ -319,3 +323,63 @@ def test_cross_domain_pulp_apis( |
319 | 323 | "future_base_path": "test", |
320 | 324 | }, |
321 | 325 | ) |
| 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