-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding mirror true check for rpm/file plugin
This commit will test cross plugin scenario. If the user syncs multiple plugin contents into the same repo with the option mirror=True, the existing content should be overwritten. closes #4448
- Loading branch information
Showing
2 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
96 changes: 96 additions & 0 deletions
96
pulpcore/tests/functional/api/using_plugin/test_sync_multiple_plugins.py
This file contains 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,96 @@ | ||
# coding=utf-8 | ||
"""Tests related to multiple plugins.""" | ||
import os | ||
import unittest | ||
|
||
from pulp_smash import api, config | ||
from pulp_smash.pulp3.constants import REPO_PATH | ||
from pulp_smash.pulp3.utils import ( | ||
gen_remote, | ||
gen_repo, | ||
get_added_content_summary, | ||
get_content_summary, | ||
get_removed_content_summary, | ||
sync, | ||
) | ||
|
||
from pulpcore.tests.functional.api.using_plugin.constants import ( | ||
FILE_FIXTURE_MANIFEST_URL, | ||
FILE_FIXTURE_SUMMARY, | ||
FILE_REMOTE_PATH, | ||
RPM_FIXTURE_SUMMARY, | ||
RPM_REMOTE_PATH, | ||
RPM_UNSIGNED_FIXTURE_URL, | ||
) | ||
from pulpcore.tests.functional.utils import skip_if | ||
|
||
|
||
class SyncMultiplePlugins(unittest.TestCase): | ||
"""Sync repositories with the multiple plugins in the same repo.""" | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
"""Create class-wide variables.""" | ||
cls.cfg = config.get_config() | ||
cls.client = api.Client(cls.cfg, api.json_handler) | ||
cls.travis = 'TRAVIS' in os.environ | ||
|
||
@skip_if(bool, 'travis', True) | ||
def test_mirror_sync(self): | ||
"""Sync multiple plugin into the same repo with mirror as `True`. | ||
This test targets the following issue: 4448 | ||
* `<https://pulp.plan.io/issues/4448>`_ | ||
This test does the following: | ||
1. Create a repo. | ||
2. Create two remotes | ||
a. RPM remote | ||
b. File remote | ||
3. Sync the repo with RPM remote. | ||
4. Sync the repo with File remote with ``Mirror=True``. | ||
5. Verify whether the content in the latest version of the repo | ||
has only File content and RPM content is deleted. | ||
""" | ||
# Step 1 | ||
repo = self.client.post(REPO_PATH, gen_repo()) | ||
self.addCleanup(self.client.delete, repo['_href']) | ||
|
||
# Step 2 | ||
rpm_remote_body = gen_remote(url=RPM_UNSIGNED_FIXTURE_URL) | ||
rpm_remote = self.client.post(RPM_REMOTE_PATH, rpm_remote_body) | ||
self.addCleanup(self.client.delete, rpm_remote['_href']) | ||
|
||
file_remote_body = gen_remote(url=FILE_FIXTURE_MANIFEST_URL) | ||
file_remote = self.client.post(FILE_REMOTE_PATH, file_remote_body) | ||
self.addCleanup(self.client.delete, file_remote['_href']) | ||
|
||
# Step 3 | ||
sync(self.cfg, rpm_remote, repo) | ||
repo = self.client.get(repo['_href']) | ||
self.assertIsNotNone(repo['_latest_version_href']) | ||
self.assertDictEqual( | ||
get_added_content_summary(repo), | ||
RPM_FIXTURE_SUMMARY | ||
) | ||
|
||
# Step 4 | ||
sync(self.cfg, file_remote, repo, mirror=True) | ||
repo = self.client.get(repo['_href']) | ||
self.assertIsNotNone(repo['_latest_version_href']) | ||
self.assertDictEqual( | ||
get_added_content_summary(repo), | ||
FILE_FIXTURE_SUMMARY | ||
) | ||
|
||
# Step 5 | ||
self.assertDictEqual( | ||
get_content_summary(repo), | ||
FILE_FIXTURE_SUMMARY | ||
) | ||
self.assertDictEqual( | ||
get_removed_content_summary(repo), | ||
RPM_FIXTURE_SUMMARY | ||
) |