Skip to content

Commit

Permalink
[6.15.z] Add coverage for BZ#2092039 and update few docstrings (Satel…
Browse files Browse the repository at this point in the history
…liteQE#13242)

* Add coverage for BZ#2092039 and update few docstrings

* Use better timeout format
  • Loading branch information
vsedmik authored Dec 5, 2023
1 parent b06e10f commit 5643a65
Showing 1 changed file with 105 additions and 26 deletions.
131 changes: 105 additions & 26 deletions tests/foreman/cli/test_satellitesync.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,6 @@ def test_positive_export_import_cv_end_to_end(
1. CV version custom contents has been exported to directory.
2. All The exported custom contents has been imported in org/satellite.
:CaseImportance: High
:CaseLevel: System
:BZ: 1832858
Expand Down Expand Up @@ -772,8 +770,6 @@ def test_positive_export_import_filtered_cvv(
1. Filtered CV version custom contents has been exported to directory
2. Filtered exported custom contents has been imported in org/satellite
:CaseImportance: High
:CaseLevel: System
"""
exporting_cv_name = importing_cvv = gen_string('alpha')
Expand Down Expand Up @@ -953,8 +949,6 @@ def test_positive_export_import_redhat_cv(
:customerscenario: true
:CaseImportance: High
:CaseLevel: System
"""
# Create cv and publish
Expand Down Expand Up @@ -1184,13 +1178,10 @@ def test_negative_import_invalid_path(self, module_org, module_target_sat):
:id: 4cc69666-407f-4d66-b3d2-8fe2ed135a5f
:steps:
1. Import a cv with a path that doesn't exist
1. Import a CV with a path that doesn't exist.
:expectedresults:
1. Error 'Unable to sync repositories, no library repository found' should be
displayed
1. Error 'Unable to sync repositories, no library repository found' should be displayed.
"""
export_folder = gen_string('alpha')
import_path = f'{PULP_IMPORT_DIR}{export_folder}'
Expand Down Expand Up @@ -1233,7 +1224,6 @@ def test_postive_export_cv_with_mixed_content_repos(
:BZ: 1726457
:customerscenario: true
"""
content_view = target_sat.cli_factory.make_content_view(
{'organization-id': function_org.id}
Expand Down Expand Up @@ -1342,9 +1332,9 @@ def test_postive_export_import_cv_with_file_content(
1. Product with synced file-type repository.
:steps:
3. Create CV, add the file repo and publish.
4. Export the CV and import it into another organization.
5. Check the imported CV has files in it.
1. Create CV, add the file repo and publish.
2. Export the CV and import it into another organization.
3. Check the imported CV has files in it.
:expectedresults:
1. Imported CV should have the files present.
Expand Down Expand Up @@ -1723,7 +1713,7 @@ def test_positive_import_content_for_disconnected_sat_with_existing_content(
1. Import should fail with correct message when existing CV has 'import-only' set False.
2. Import should succeed when existing CV has 'import-only' set True.
:bz: 2030101
:BZ: 2030101
:customerscenario: true
"""
Expand Down Expand Up @@ -1903,14 +1893,13 @@ def test_positive_reimport_repo(self):
:id: b3a71405-d8f0-4085-b728-8fc3513611c8
:steps:
1. From upstream Export repo fully and import it in downstream.
2. In upstream delete some packages from repo.
3. Re-export the full repo.
4. In downstream, reimport the repo re-exported.
:expectedresults: Deleted packages from upstream are removed from
downstream.
:expectedresults:
1. Deleted packages from upstream are removed from downstream.
:CaseAutomation: NotAutomated
Expand All @@ -1924,10 +1913,11 @@ def test_negative_export_repo_from_future_datetime(self):
:id: 1e8bc352-198f-4d59-b437-1b184141fab4
:steps: Export the repo incrementally from the future date time.
:steps:
1. Export the repo incrementally from the future date time.
:expectedresults: Error is raised for attempting to export from future
datetime.
:expectedresults:
1. Error is raised for attempting to export from future datetime.
:CaseAutomation: NotAutomated
Expand Down Expand Up @@ -1963,8 +1953,6 @@ def test_positive_export_import_incremental_yum_repo(
in the importing organization and content counts match.
2. Incremental export and import succeeds, content counts match the updated counts.
:CaseAutomation: Automated
:CaseLevel: System
"""
export_cc = target_sat.cli.Repository.info({'id': function_synced_custom_repo.id})[
Expand Down Expand Up @@ -2022,6 +2010,97 @@ def test_positive_export_import_incremental_yum_repo(
export_cc['packages'] = str(int(export_cc['packages']) + 1)
assert import_repo['content-counts'] == export_cc, 'Import counts do not match the export.'

@pytest.mark.tier3
@pytest.mark.parametrize(
'function_synced_rhel_repo',
['rhae2'],
indirect=True,
)
def test_positive_export_import_mismatch_label(
self,
target_sat,
export_import_cleanup_function,
config_export_import_settings,
function_sca_manifest_org,
function_import_org_with_manifest,
function_synced_rhel_repo,
):
"""Export and import repo with mismatched label
:id: eb2f3e8e-3ee6-4713-80ab-3811a098e079
:setup:
1. Enabled and synced RH yum repository.
:steps:
1. Export and import a RH yum repo, verify it was imported.
2. Export the repo again and change the repository label.
3. Import the changed repository again, it should succeed without errors.
:expectedresults:
1. All exports and imports succeed.
:CaseLevel: System
:CaseImportance: Medium
:BZ: 2092039
:customerscenario: true
"""
# Verify export directory is empty
assert target_sat.validate_pulp_filepath(function_sca_manifest_org, PULP_EXPORT_DIR) == ''
# Export the repository and check the export directory
export = target_sat.cli.ContentExport.completeRepository(
{'id': function_synced_rhel_repo['id']}
)
assert '1.0' in target_sat.validate_pulp_filepath(
function_sca_manifest_org, PULP_EXPORT_DIR
)

# Run import and verify the product and repo is created in the importing org
import_path = target_sat.move_pulp_archive(function_sca_manifest_org, export['message'])
target_sat.cli.ContentImport.repository(
{'organization-id': function_import_org_with_manifest.id, 'path': import_path},
timeout='5m',
)
import_repo = target_sat.cli.Repository.info(
{
'name': function_synced_rhel_repo['name'],
'product': function_synced_rhel_repo['product']['name'],
'organization-id': function_sca_manifest_org.id,
}
)
assert import_repo

# Export again and check the export directory
export = target_sat.cli.ContentExport.completeRepository(
{'id': function_synced_rhel_repo['id']}
)
assert '2.0' in target_sat.validate_pulp_filepath(
function_sca_manifest_org, PULP_EXPORT_DIR
)

# Change the repo label in metadata.json and run the import again
import_path = target_sat.move_pulp_archive(function_sca_manifest_org, export['message'])
target_sat.execute(
f'''sed -i 's/"label":"{function_synced_rhel_repo['label']}"/'''
f'''"label":"{gen_string("alpha")}"/g' {import_path}/metadata.json'''
)
target_sat.cli.ContentImport.repository(
{'organization-id': function_import_org_with_manifest.id, 'path': import_path},
timeout='5m',
)

# Verify that both import tasks succeeded
tasks = target_sat.cli.Task.list_tasks(
{'search': f"Import Repository organization '{function_import_org_with_manifest.name}'"}
)
assert len(tasks) == 2, f'Expected 2 import tasks in this Org but found {len(tasks)}'
assert all(
['success' in task['result'] for task in tasks]
), 'Not every import task succeeded'

@pytest.mark.stubbed
@pytest.mark.tier3
@pytest.mark.upgrade
Expand All @@ -2040,8 +2119,8 @@ def test_positive_install_package_from_imported_repos(self):
5. Attempt to install a package on a client from imported repo of
downstream.
:expectedresults: The package is installed on client from imported repo
of downstream satellite.
:expectedresults:
1. The package is installed on client from imported repo of downstream satellite.
:CaseAutomation: NotAutomated
Expand Down

0 comments on commit 5643a65

Please sign in to comment.