|
3 | 3 | import pytest
|
4 | 4 | import subprocess
|
5 | 5 |
|
6 |
| -from django.conf import settings |
7 |
| - |
8 | 6 | from pulp_container.tests.functional.constants import REGISTRY_V2
|
9 | 7 |
|
10 | 8 |
|
11 |
| -def test_flatpak_install( |
12 |
| - add_to_cleanup, |
13 |
| - registry_client, |
14 |
| - local_registry, |
15 |
| - container_namespace_api, |
16 |
| - container_push_repository_api, |
17 |
| - container_tag_api, |
18 |
| - container_manifest_api, |
19 |
| -): |
20 |
| - if not settings.FLATPAK_INDEX: |
21 |
| - pytest.skip("This test requires FLATPAK_INDEX to be enabled") |
22 |
| - |
23 |
| - image_path1 = f"{REGISTRY_V2}/pulp/oci-net.fishsoup.busyboxplatform:latest" |
24 |
| - registry_client.pull(image_path1) |
25 |
| - local_registry.tag_and_push(image_path1, "pulptest/oci-net.fishsoup.busyboxplatform:latest") |
26 |
| - image_path2 = f"{REGISTRY_V2}/pulp/oci-net.fishsoup.hello:latest" |
27 |
| - registry_client.pull(image_path2) |
28 |
| - local_registry.tag_and_push(image_path2, "pulptest/oci-net.fishsoup.hello:latest") |
29 |
| - namespace = container_namespace_api.list(name="pulptest").results[0] |
30 |
| - add_to_cleanup(container_namespace_api, namespace.pulp_href) |
31 |
| - |
32 |
| - repo = container_push_repository_api.list(name="pulptest/oci-net.fishsoup.hello").results[0] |
33 |
| - tag = container_tag_api.list(repository_version=repo.latest_version_href).results[0] |
34 |
| - manifest = container_manifest_api.read(tag.tagged_manifest) |
35 |
| - |
36 |
| - assert manifest.is_flatpak |
37 |
| - assert not manifest.is_bootable |
38 |
| - |
| 9 | +def run_flatpak_commands(pulp_settings): |
39 | 10 | # Install flatpak:
|
40 | 11 | subprocess.check_call(
|
41 | 12 | [
|
42 | 13 | "flatpak",
|
43 | 14 | "--user",
|
44 | 15 | "remote-add",
|
45 | 16 | "pulptest",
|
46 |
| - "oci+" + settings.CONTENT_ORIGIN, |
| 17 | + "oci+" + pulp_settings.CONTENT_ORIGIN, |
47 | 18 | ]
|
48 | 19 | )
|
49 | 20 | # See <https://pagure.io/fedora-lorax-templates/c/cc1155372046baa58f9d2cc27a9e5473bf05a3fb>
|
@@ -81,3 +52,86 @@ def test_flatpak_install(
|
81 | 52 | ]
|
82 | 53 | )
|
83 | 54 | subprocess.run(["flatpak", "--user", "remote-delete", "pulptest"])
|
| 55 | + |
| 56 | + |
| 57 | +def test_flatpak_install( |
| 58 | + add_to_cleanup, |
| 59 | + registry_client, |
| 60 | + local_registry, |
| 61 | + container_namespace_api, |
| 62 | + container_push_repository_api, |
| 63 | + container_tag_api, |
| 64 | + container_manifest_api, |
| 65 | + pulp_settings, |
| 66 | +): |
| 67 | + if not pulp_settings.FLATPAK_INDEX: |
| 68 | + pytest.skip("This test requires FLATPAK_INDEX to be enabled") |
| 69 | + |
| 70 | + image_path1 = f"{REGISTRY_V2}/pulp/oci-net.fishsoup.busyboxplatform:latest" |
| 71 | + registry_client.pull(image_path1) |
| 72 | + local_registry.tag_and_push(image_path1, "pulptest/oci-net.fishsoup.busyboxplatform:latest") |
| 73 | + image_path2 = f"{REGISTRY_V2}/pulp/oci-net.fishsoup.hello:latest" |
| 74 | + registry_client.pull(image_path2) |
| 75 | + local_registry.tag_and_push(image_path2, "pulptest/oci-net.fishsoup.hello:latest") |
| 76 | + namespace = container_namespace_api.list(name="pulptest").results[0] |
| 77 | + add_to_cleanup(container_namespace_api, namespace.pulp_href) |
| 78 | + |
| 79 | + repo = container_push_repository_api.list(name="pulptest/oci-net.fishsoup.hello").results[0] |
| 80 | + tag = container_tag_api.list(repository_version=repo.latest_version_href).results[0] |
| 81 | + manifest = container_manifest_api.read(tag.tagged_manifest) |
| 82 | + |
| 83 | + assert manifest.is_flatpak |
| 84 | + assert not manifest.is_bootable |
| 85 | + |
| 86 | + run_flatpak_commands(pulp_settings) |
| 87 | + |
| 88 | + |
| 89 | +def test_flatpak_on_demand( |
| 90 | + container_tag_api, |
| 91 | + container_manifest_api, |
| 92 | + container_repository_factory, |
| 93 | + container_remote_factory, |
| 94 | + container_sync, |
| 95 | + container_distribution_factory, |
| 96 | + container_namespace_api, |
| 97 | + pulpcore_bindings, |
| 98 | + monitor_task, |
| 99 | + add_to_cleanup, |
| 100 | + pulp_settings, |
| 101 | +): |
| 102 | + if not pulp_settings.FLATPAK_INDEX: |
| 103 | + pytest.skip("This test requires FLATPAK_INDEX to be enabled") |
| 104 | + |
| 105 | + # Set up repositories with immediate sync |
| 106 | + remote1 = container_remote_factory( |
| 107 | + upstream_name="pulp/oci-net.fishsoup.busyboxplatform", include_tags=["latest"] |
| 108 | + ) |
| 109 | + remote2 = container_remote_factory( |
| 110 | + upstream_name="pulp/oci-net.fishsoup.hello", include_tags=["latest"] |
| 111 | + ) |
| 112 | + repo1 = container_repository_factory(remote=remote1.pulp_href) |
| 113 | + repo2 = container_repository_factory(remote=remote2.pulp_href) |
| 114 | + container_sync(repo1) |
| 115 | + container_sync(repo2) |
| 116 | + container_distribution_factory( |
| 117 | + base_path="pulptest/oci-net.fishsoup.busyboxplatform", repository=repo1.pulp_href |
| 118 | + ) |
| 119 | + container_distribution_factory( |
| 120 | + base_path="pulptest/oci-net.fishsoup.hello", repository=repo2.pulp_href |
| 121 | + ) |
| 122 | + namespace = container_namespace_api.list(name="pulptest").results[0] |
| 123 | + add_to_cleanup(container_namespace_api, namespace.pulp_href) |
| 124 | + |
| 125 | + # Assert the repos were set up correctly |
| 126 | + tag = container_tag_api.list(repository_version=repo2.latest_version_href).results[0] |
| 127 | + manifest = container_manifest_api.read(tag.tagged_manifest) |
| 128 | + assert manifest.is_flatpak |
| 129 | + assert not manifest.is_bootable |
| 130 | + |
| 131 | + # reclaim disk space to turn the manifests + config-blogs into on-demand |
| 132 | + reclaim_response = pulpcore_bindings.RepositoriesReclaimSpaceApi.reclaim( |
| 133 | + {"repo_hrefs": [repo1.pulp_href, repo2.pulp_href]} |
| 134 | + ) |
| 135 | + monitor_task(reclaim_response.task) |
| 136 | + |
| 137 | + run_flatpak_commands(pulp_settings) |
0 commit comments