-
Notifications
You must be signed in to change notification settings - Fork 83
Support automatically publishing new repository versions #1337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Added autopublish functionality. | ||
| Creates a structured APT publication when used. | ||
| Cannot be used to create verbatim publications. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| from django.db import migrations, models | ||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('deb', '0001_initial_squashed_0031_add_domains'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='aptrepository', | ||
| name='autopublish', | ||
| field=models.BooleanField(default=False), | ||
| ), | ||
| ] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import pytest | ||
|
|
||
| from pulpcore.client.pulp_deb import ( | ||
| AptRepositorySyncURL, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def setup_autopublish( | ||
| deb_get_fixture_server_url, deb_repository_factory, deb_remote_factory, deb_distribution_factory | ||
| ): | ||
| """Create remote, repo, publish settings, and distribution.""" | ||
| url = deb_get_fixture_server_url() | ||
| remote = deb_remote_factory(url=url) | ||
| repo = deb_repository_factory(autopublish=True) | ||
| distribution = deb_distribution_factory(repository=repo) | ||
|
|
||
| return repo, remote, distribution | ||
|
|
||
|
|
||
| @pytest.mark.parallel | ||
| def test_01_sync(setup_autopublish, apt_repository_api, apt_publication_api, monitor_task): | ||
| """Assert that syncing the repository triggers auto-publish and auto-distribution.""" | ||
| repo, remote, distribution = setup_autopublish | ||
| assert apt_publication_api.list(repository=repo.pulp_href).count == 0 | ||
| assert distribution.publication is None | ||
|
|
||
| # Sync the repository. | ||
| repository_sync_data = AptRepositorySyncURL(remote=remote.pulp_href) | ||
| sync_response = apt_repository_api.sync(repo.pulp_href, repository_sync_data) | ||
| task = monitor_task(sync_response.task) | ||
|
|
||
| # Check that all the appropriate resources were created | ||
| assert len(task.created_resources) > 1 | ||
| publications = apt_publication_api.list(repository=repo.pulp_href) | ||
| assert publications.count == 1 | ||
|
|
||
| # Sync the repository again. Since there should be no new repository version, there | ||
| # should be no new publications or distributions either. | ||
| sync_response = apt_repository_api.sync(repo.pulp_href, repository_sync_data) | ||
| task = monitor_task(sync_response.task) | ||
|
|
||
| assert len(task.created_resources) == 0 | ||
| assert apt_publication_api.list(repository=repo.pulp_href).count == 1 | ||
|
|
||
|
|
||
| @pytest.mark.parallel | ||
| def test_02_modify( | ||
| setup_autopublish, apt_repository_api, apt_package_api, apt_publication_api, monitor_task | ||
| ): | ||
| """Assert that modifying the repository triggers auto-publish and auto-distribution.""" | ||
| repo, remote, distribution = setup_autopublish | ||
| assert apt_publication_api.list(repository=repo.pulp_href).count == 0 | ||
| assert distribution.publication is None | ||
|
|
||
| # Modify the repository by adding a content unit | ||
| content = apt_package_api.list().results[0].pulp_href | ||
|
|
||
| modify_response = apt_repository_api.modify(repo.pulp_href, {"add_content_units": [content]}) | ||
| task = monitor_task(modify_response.task) | ||
|
|
||
| # Check that all the appropriate resources were created | ||
| assert len(task.created_resources) > 1 | ||
| publications = apt_publication_api.list(repository=repo.pulp_href) | ||
| assert publications.count == 1 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.