Skip to content
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

Add coverage for BZ#2092039 and update few docstrings #13187

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
lhellebr marked this conversation as resolved.
Show resolved Hide resolved
):
"""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=300000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a 300000 second timeout? If so, I think we should turn it down.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in miliseconds I guess (at least from what I can see elsewhere grepping for \.cli\..*timeout)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the steps to here https://github.com/SatelliteQE/broker/blob/master/broker/hosts.py#L139. It's possible VS Code led me astray, so I'll double check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to tag @JacobCallahan here for confirmation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Griffin-Sullivan is correct, that timeout is in seconds. In fact, Broker also allows you to use more clear timeout formatting so instead of specifying a long timeout like that, you can just pass timeout="5m"
https://github.com/SatelliteQE/broker/blob/master/broker/session.py#L99
https://github.com/SatelliteQE/broker/blob/master/broker/helpers.py#L417

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, changed to the nicer format, let's wait for the PRT.

)
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=300000,
)

# 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