forked from pulp/pulp_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sync.py
More file actions
326 lines (265 loc) · 12.3 KB
/
Copy pathtest_sync.py
File metadata and controls
326 lines (265 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
import pytest
from pulp_python.tests.functional.constants import (
PYTHON_XS_PACKAGE_COUNT,
PYTHON_PRERELEASE_TEST_SPECIFIER,
PYTHON_WITH_PRERELEASE_COUNT,
PYTHON_WITHOUT_PRERELEASE_COUNT,
PYTHON_XS_PROJECT_SPECIFIER,
PYTHON_MD_PROJECT_SPECIFIER,
PYTHON_MD_PACKAGE_COUNT,
PYTHON_SM_PROJECT_SPECIFIER,
PYTHON_SM_PACKAGE_COUNT,
PYTHON_UNAVAILABLE_PACKAGE_COUNT,
PYTHON_UNAVAILABLE_PROJECT_SPECIFIER,
PYTHON_LG_PROJECT_SPECIFIER,
PYTHON_LG_PACKAGE_COUNT,
PYTHON_LG_FIXTURE_COUNTS,
DJANGO_LATEST_3,
SCIPY_COUNTS,
)
@pytest.mark.parallel
def test_sync(
python_bindings, python_repo, python_remote_factory, python_content_summary, monitor_task
):
"""Sync repositories with the python plugin."""
remote = python_remote_factory()
# Sync the repository.
sync_data = dict(remote=remote.pulp_href)
response = python_bindings.RepositoriesPythonApi.sync(python_repo.pulp_href, sync_data)
task = monitor_task(response.task)
repo = python_bindings.RepositoriesPythonApi.read(python_repo.pulp_href)
assert task.created_resources[0] == repo.latest_version_href
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.added["python.python"]["count"] == PYTHON_XS_PACKAGE_COUNT
assert summary.present["python.python"]["count"] == PYTHON_XS_PACKAGE_COUNT
# Sync the repository again.
latest_version_href = repo.latest_version_href
response = python_bindings.RepositoriesPythonApi.sync(repo.pulp_href, sync_data)
task = monitor_task(response.task)
repo = python_bindings.RepositoriesPythonApi.read(repo.pulp_href)
assert latest_version_href == repo.latest_version_href
assert len(task.created_resources) == 0
@pytest.mark.parallel
def test_sync_prereleases(python_repo_with_sync, python_remote_factory, python_content_summary):
"""Test syncing with prereleases filter."""
remote = python_remote_factory(includes=PYTHON_PRERELEASE_TEST_SPECIFIER, prereleases=False)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_WITHOUT_PRERELEASE_COUNT
# Now sync with prereleases=True
remote = python_remote_factory(includes=PYTHON_PRERELEASE_TEST_SPECIFIER, prereleases=True)
repo = python_repo_with_sync(remote, repository=repo)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_WITH_PRERELEASE_COUNT
diff_count = PYTHON_WITH_PRERELEASE_COUNT - PYTHON_WITHOUT_PRERELEASE_COUNT
assert summary.added["python.python"]["count"] == diff_count
# Sync w/ mirror=True & prereleases=False to ensure units are removed
remote = python_remote_factory(includes=PYTHON_PRERELEASE_TEST_SPECIFIER, prereleases=False)
repo = python_repo_with_sync(remote, mirror=True, repository=repo)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_WITHOUT_PRERELEASE_COUNT
assert summary.removed["python.python"]["count"] == diff_count
@pytest.mark.parallel
def test_sync_includes_excludes(
python_repo_with_sync, python_remote_factory, python_content_summary
):
"""Test behavior of the includes and excludes fields on the Remote during sync."""
remote = python_remote_factory(includes=PYTHON_XS_PROJECT_SPECIFIER)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_XS_PACKAGE_COUNT
# Test w/ large superset includes
remote = python_remote_factory(includes=PYTHON_MD_PROJECT_SPECIFIER)
repo = python_repo_with_sync(remote, repository=repo)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_MD_PACKAGE_COUNT
# Test w/ exclude subset
remote = python_remote_factory(
includes=PYTHON_MD_PROJECT_SPECIFIER, excludes=PYTHON_SM_PROJECT_SPECIFIER
)
repo = python_repo_with_sync(remote, repository=repo, mirror=True)
summary = python_content_summary(repository_version=repo.latest_version_href)
diff_count = PYTHON_MD_PACKAGE_COUNT - PYTHON_SM_PACKAGE_COUNT
assert summary.present["python.python"]["count"] == diff_count
assert summary.removed["python.python"]["count"] == PYTHON_SM_PACKAGE_COUNT
# Test w/ even smaller exclude subset
remote = python_remote_factory(
includes=PYTHON_MD_PROJECT_SPECIFIER, excludes=PYTHON_XS_PROJECT_SPECIFIER
)
repo = python_repo_with_sync(remote, repository=repo, mirror=True)
summary = python_content_summary(repository_version=repo.latest_version_href)
diff_count = PYTHON_MD_PACKAGE_COUNT - PYTHON_XS_PACKAGE_COUNT
assert summary.present["python.python"]["count"] == diff_count
@pytest.mark.parallel
def test_sync_unavailable_projects(
python_repo_with_sync, python_remote_factory, python_content_summary
):
"""
Test syncing with projects that aren't on the upstream remote.
Tests that sync doesn't fail if the Remote contains projects (includes or excludes) for which
metadata does not exist on the upstream remote.
"""
remote = python_remote_factory(includes=PYTHON_UNAVAILABLE_PROJECT_SPECIFIER)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_UNAVAILABLE_PACKAGE_COUNT
remote = python_remote_factory(
includes=PYTHON_MD_PROJECT_SPECIFIER, excludes=PYTHON_UNAVAILABLE_PROJECT_SPECIFIER
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
diff_count = PYTHON_MD_PACKAGE_COUNT - PYTHON_UNAVAILABLE_PACKAGE_COUNT
assert summary.present["python.python"]["count"] == diff_count
@pytest.mark.parallel
def test_sync_latest_kept(python_repo_with_sync, python_remote_factory, python_content_summary):
"""
Test checks that latest X packages are synced when latest kept is
specified
This feature uses Bandersnatch's latest_kept filter which doesn't work well
with the other filters like pre-releases and allow/blocklist. Whether to
count the behavior as a bug or feature is hard to tell.
"""
# Tests latest_kept on syncing one package w/ prereleases
remote = python_remote_factory(
includes=["Django"],
keep_latest_packages=3,
prereleases=True,
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == DJANGO_LATEST_3
# Tests latest_kept on syncing multiple packages w/ prereleases
remote = python_remote_factory(
includes=PYTHON_LG_PROJECT_SPECIFIER,
keep_latest_packages=3,
prereleases=True,
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_LG_FIXTURE_COUNTS["latest_3"]
@pytest.mark.parallel
def test_sync_package_type(python_repo_with_sync, python_remote_factory, python_content_summary):
"""Tests that check only specified package types can be synced."""
# Checks that only sdist content is synced
remote = python_remote_factory(
includes=PYTHON_LG_PROJECT_SPECIFIER,
package_types=["sdist"],
prereleases=True,
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_LG_FIXTURE_COUNTS["sdist"]
# Checks that only bdist_wheel content is synced
remote = python_remote_factory(
includes=PYTHON_LG_PROJECT_SPECIFIER,
package_types=["bdist_wheel"],
prereleases=True,
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_LG_FIXTURE_COUNTS["bdist_wheel"]
# Checks that specifying sdist and bdist_wheel gets all packages
remote = python_remote_factory(
includes=PYTHON_LG_PROJECT_SPECIFIER,
package_types=["sdist", "bdist_wheel"],
prereleases=True,
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_LG_PACKAGE_COUNT
@pytest.mark.parallel
def test_sync_platform_exclude(
python_repo_with_sync, python_remote_factory, python_content_summary
):
"""
Tests for platform specific packages not being synced when specified
Only our scipy packages have platform specific versions
23 release files:
4 macos releases
8 windows releases
10 linux releases
1 any platform release
"""
# Tests that no windows packages are synced
remote = python_remote_factory(
includes=["scipy"],
exclude_platforms=["windows"],
prereleases=True,
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
diff_count = SCIPY_COUNTS["total"] - SCIPY_COUNTS["windows"]
assert summary.present["python.python"]["count"] == diff_count
# Tests that no macos packages are synced
remote = python_remote_factory(
includes=["scipy"],
exclude_platforms=["macos"],
prereleases=True,
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
diff_count = SCIPY_COUNTS["total"] - SCIPY_COUNTS["macos"]
assert summary.present["python.python"]["count"] == diff_count
# Tests that no linux packages are synced
remote = python_remote_factory(
includes=["scipy"],
exclude_platforms=["linux"],
prereleases=True,
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
diff_count = SCIPY_COUNTS["total"] - SCIPY_COUNTS["linux"]
assert summary.present["python.python"]["count"] == diff_count
# Tests that no package specified for a platform is synced
remote = python_remote_factory(
includes=["scipy"],
exclude_platforms=["windows", "macos", "linux", "freebsd"],
prereleases=True,
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == SCIPY_COUNTS["no_os"]
@pytest.mark.parallel
def test_sync_multiple_filters(
python_repo_with_sync, python_remote_factory, python_content_summary
):
"""Tests sync with multiple filters."""
remote = python_remote_factory(
includes=PYTHON_LG_PROJECT_SPECIFIER,
package_types=["bdist_wheel"],
keep_latest_packages=1,
prereleases=False,
)
repo = python_repo_with_sync(remote)
summary = python_content_summary(repository_version=repo.latest_version_href)
assert summary.present["python.python"]["count"] == PYTHON_LG_FIXTURE_COUNTS["multi"]
@pytest.mark.parallel
def test_proxy_sync(
python_bindings,
python_repo_with_sync,
python_remote_factory,
http_proxy,
):
"""Test syncing with a proxy."""
remote = python_remote_factory(proxy_url=http_proxy.proxy_url)
repo = python_repo_with_sync(remote)
assert repo.latest_version_href[-2] == "1"
content = python_bindings.ContentPackagesApi.list(repository_version=repo.latest_version_href)
assert content.count == 2
@pytest.mark.parallel
def test_proxy_auth_sync(
python_bindings,
python_repo_with_sync,
python_remote_factory,
http_proxy_with_auth,
):
"""Test syncing with a proxy with auth."""
remote = python_remote_factory(
proxy_url=http_proxy_with_auth.proxy_url,
proxy_username=http_proxy_with_auth.username,
proxy_password=http_proxy_with_auth.password,
)
repo = python_repo_with_sync(remote)
assert repo.latest_version_href[-2] == "1"
content = python_bindings.ContentPackagesApi.list(repository_version=repo.latest_version_href)
assert content.count == 2