|
| 1 | +--- |
| 2 | +- name: Test pulp_distribution python |
| 3 | + gather_facts: false |
| 4 | + hosts: localhost |
| 5 | + vars: |
| 6 | + pulp_url: http://localhost:8080 |
| 7 | + pulp_username: admin |
| 8 | + pulp_password: password |
| 9 | + pulp_validate_certs: true |
| 10 | + tasks: |
| 11 | + - include_role: |
| 12 | + name: pulp_repository |
| 13 | + vars: |
| 14 | + pulp_repository_python_repos: |
| 15 | + - name: test_python_repo |
| 16 | + url: "https://fixtures.pulpproject.org/python-pypi/" |
| 17 | + policy: immediate |
| 18 | + state: present |
| 19 | + sync: false |
| 20 | + |
| 21 | + - include_role: |
| 22 | + name: pulp_distribution |
| 23 | + vars: |
| 24 | + pulp_distribution_python: |
| 25 | + - name: test_python_distribution |
| 26 | + base_path: test_python_distribution |
| 27 | + repository: test_python_repo |
| 28 | + remote: test_python_repo-remote |
| 29 | + state: present |
| 30 | + |
| 31 | + - name: Query repository |
| 32 | + pulp.squeezer.python_repository: |
| 33 | + pulp_url: "{{ pulp_url }}" |
| 34 | + username: "{{ pulp_username }}" |
| 35 | + password: "{{ pulp_password }}" |
| 36 | + validate_certs: "{{ pulp_validate_certs }}" |
| 37 | + name: test_python_repo |
| 38 | + register: repo_result |
| 39 | + |
| 40 | + - name: Query distribution |
| 41 | + pulp.squeezer.python_distribution: |
| 42 | + pulp_url: "{{ pulp_url }}" |
| 43 | + username: "{{ pulp_username }}" |
| 44 | + password: "{{ pulp_password }}" |
| 45 | + validate_certs: "{{ pulp_validate_certs }}" |
| 46 | + name: test_python_distribution |
| 47 | + register: dist_result |
| 48 | + |
| 49 | + - debug: |
| 50 | + var: dist_result |
| 51 | + |
| 52 | + - name: Verify distribution creation |
| 53 | + assert: |
| 54 | + that: |
| 55 | + - dist_result.distribution.name == "test_python_distribution" |
| 56 | + - dist_result.distribution.base_path == "test_python_distribution" |
| 57 | + |
| 58 | + - name: Query distribution package index |
| 59 | + ansible.builtin.uri: |
| 60 | + url: "{{ pulp_url }}{{ dist_result.distribution.base_url | ansible.builtin.urlsplit('path') }}simple/" |
| 61 | + return_content: true |
| 62 | + register: package_index |
| 63 | + |
| 64 | + - debug: |
| 65 | + var: package_index |
| 66 | + |
| 67 | + - name: Verify package index |
| 68 | + ansible.builtin.assert: |
| 69 | + that: |
| 70 | + - package_index.status == 200 |
| 71 | + - "'Simple Index' in package_index.content" |
| 72 | + - "'shelf-reader' not in package_index.content" # gets pulled-through later on |
| 73 | + |
| 74 | + - name: Query shelf-reader from distribution |
| 75 | + ansible.builtin.uri: |
| 76 | + url: "{{ pulp_url }}{{ dist_result.distribution.base_url | ansible.builtin.urlsplit('path') }}simple/shelf-reader/" |
| 77 | + return_content: true |
| 78 | + register: package_index |
| 79 | + |
| 80 | + - name: Verify package index |
| 81 | + ansible.builtin.assert: |
| 82 | + that: |
| 83 | + - package_index.status == 200 |
| 84 | + - "'shelf-reader-0.1.tar.gz' in package_index.content" |
| 85 | + - "'shelf_reader-0.1-py2-none-any.whl' in package_index.content" |
| 86 | + |
| 87 | + - include_role: |
| 88 | + name: pulp_distribution |
| 89 | + vars: |
| 90 | + pulp_distribution_python: |
| 91 | + - name: test_python_distribution |
| 92 | + state: absent |
| 93 | + |
| 94 | + - include_role: |
| 95 | + name: pulp_repository |
| 96 | + vars: |
| 97 | + pulp_repository_python_repos: |
| 98 | + - name: test_python_repo |
| 99 | + state: absent |
| 100 | + |
| 101 | + - name: Query distributions |
| 102 | + pulp.squeezer.python_distribution: |
| 103 | + pulp_url: "{{ pulp_url }}" |
| 104 | + username: "{{ pulp_username }}" |
| 105 | + password: "{{ pulp_password }}" |
| 106 | + validate_certs: "{{ pulp_validate_certs }}" |
| 107 | + register: python_distributions |
| 108 | + |
| 109 | + - name: Verify distribution deletion |
| 110 | + assert: |
| 111 | + that: python_distributions.distributions | length == 0 |
| 112 | + |
| 113 | + # ---- test distribution serving latest version |
| 114 | + - include_role: |
| 115 | + name: pulp_repository |
| 116 | + vars: |
| 117 | + pulp_repository_python_repos: |
| 118 | + - name: test_python_repo |
| 119 | + url: "https://fixtures.pulpproject.org/python-pypi/" |
| 120 | + policy: immediate |
| 121 | + state: present |
| 122 | + includes: ["shelf-reader"] |
| 123 | + |
| 124 | + - include_role: |
| 125 | + name: pulp_distribution |
| 126 | + vars: |
| 127 | + pulp_distribution_python: |
| 128 | + - name: test_python_distribution |
| 129 | + base_path: test_python_distribution |
| 130 | + repository: test_python_repo |
| 131 | + state: present |
| 132 | + |
| 133 | + - name: Query repository |
| 134 | + pulp.squeezer.python_repository: |
| 135 | + pulp_url: "{{ pulp_url }}" |
| 136 | + username: "{{ pulp_username }}" |
| 137 | + password: "{{ pulp_password }}" |
| 138 | + validate_certs: "{{ pulp_validate_certs }}" |
| 139 | + name: test_python_repo |
| 140 | + register: repo_result |
| 141 | + |
| 142 | + - name: Query distribution |
| 143 | + pulp.squeezer.python_distribution: |
| 144 | + pulp_url: "{{ pulp_url }}" |
| 145 | + username: "{{ pulp_username }}" |
| 146 | + password: "{{ pulp_password }}" |
| 147 | + validate_certs: "{{ pulp_validate_certs }}" |
| 148 | + name: test_python_distribution |
| 149 | + register: dist_result |
| 150 | + |
| 151 | + - debug: |
| 152 | + var: dist_result |
| 153 | + |
| 154 | + - name: Verify distribution creation |
| 155 | + assert: |
| 156 | + that: |
| 157 | + - dist_result.distribution.name == "test_python_distribution" |
| 158 | + - dist_result.distribution.base_path == "test_python_distribution" |
| 159 | + |
| 160 | + - name: Query distribution package index |
| 161 | + ansible.builtin.uri: |
| 162 | + url: "{{ pulp_url }}{{ dist_result.distribution.base_url | ansible.builtin.urlsplit('path') }}simple/" |
| 163 | + return_content: true |
| 164 | + register: package_index |
| 165 | + |
| 166 | + - debug: |
| 167 | + var: package_index |
| 168 | + |
| 169 | + - name: Verify package index |
| 170 | + ansible.builtin.assert: |
| 171 | + that: |
| 172 | + - package_index.status == 200 |
| 173 | + - "'Simple Index' in package_index.content" |
| 174 | + - "'shelf-reader' in package_index.content" # already there because the repository is synced |
| 175 | + |
| 176 | + - include_role: |
| 177 | + name: pulp_distribution |
| 178 | + vars: |
| 179 | + pulp_distribution_python: |
| 180 | + - name: test_python_distribution |
| 181 | + state: absent |
| 182 | + |
| 183 | + - include_role: |
| 184 | + name: pulp_repository |
| 185 | + vars: |
| 186 | + pulp_repository_python_repos: |
| 187 | + - name: test_python_repo |
| 188 | + state: absent |
| 189 | + |
| 190 | + - name: Query distributions |
| 191 | + pulp.squeezer.python_distribution: |
| 192 | + pulp_url: "{{ pulp_url }}" |
| 193 | + username: "{{ pulp_username }}" |
| 194 | + password: "{{ pulp_password }}" |
| 195 | + validate_certs: "{{ pulp_validate_certs }}" |
| 196 | + register: python_distributions |
| 197 | + |
| 198 | + - name: Verify distribution deletion |
| 199 | + assert: |
| 200 | + that: python_distributions.distributions | length == 0 |
0 commit comments