Skip to content

Commit

Permalink
Add test case for ISS export with history ID
Browse files Browse the repository at this point in the history
  • Loading branch information
vsedmik committed Jan 3, 2024
1 parent 6a42f67 commit 352562f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 8 deletions.
2 changes: 1 addition & 1 deletion robottelo/cli/content_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ContentExport(Base):
command_requires_org = True

@classmethod
def list(cls, output_format='json', options=None):
def list(cls, options=None, output_format='json'):
"""
List previous exports
"""
Expand Down
76 changes: 69 additions & 7 deletions tests/foreman/cli/test_satellitesync.py
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,8 @@ def test_positive_export_incremental_syncable_check_content(
:id: 6ff771cd-39ef-4865-8ae8-629f4baf5f98
:parametrized: yes
:setup:
1. Enabled and synced RH repository.
Expand Down Expand Up @@ -1839,23 +1841,81 @@ def test_positive_reimport_repo(self):
:CaseLevel: System
"""

@pytest.mark.stubbed
@pytest.mark.tier3
def test_negative_export_repo_from_future_datetime(self):
"""Incremental export fails with future datetime.
@pytest.mark.parametrize(
'function_synced_rhel_repo',
['rhae2'],
indirect=True,
)
def test_export_repo_incremental_with_history_id(
self,
target_sat,
export_import_cleanup_function,
config_export_import_settings,
function_sca_manifest_org,
function_synced_rhel_repo,
):
"""Test incremental export with history id.
:id: 1e8bc352-198f-4d59-b437-1b184141fab4
:parametrized: yes
:setup:
1. Enabled and synced RH repository.
:steps:
1. Export the repo incrementally from the future date time.
1. Run repo complete export, ensure it's listed in history.
2. Run incremental export using history id of the complete export,
ensure it's listed in history.
3. Run incremental export using non-existent history id.
:expectedresults:
1. Error is raised for attempting to export from future datetime.
:CaseAutomation: NotAutomated
1. First (complete) export succeeds and can be listed including history id.
2. Second (incremental) export succeeds and can be listed including history id.
3. Third (incremental) export fails when wrong id is provided.
:CaseLevel: System
"""
# Verify export directory is empty
assert target_sat.validate_pulp_filepath(function_sca_manifest_org, PULP_EXPORT_DIR) == ''

# Run repo complete export, ensure it's listed in history.
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
)

history = target_sat.cli.ContentExport.list(
{'organization-id': function_sca_manifest_org.id}
)
assert len(history) == 1, 'Expected just one item in the export history'

# Run incremental export using history id of the complete export,
# ensure it's listed in history.
target_sat.cli.ContentExport.incrementalRepository(
{'id': function_synced_rhel_repo['id'], 'from-history-id': history[0]['id']}
)
assert '2.0' in target_sat.validate_pulp_filepath(
function_sca_manifest_org, PULP_EXPORT_DIR
)

history = target_sat.cli.ContentExport.list(
{'organization-id': function_sca_manifest_org.id}
)
assert len(history) == 2, 'Expected two items in the export history'
assert int(history[1]['id']) == int(history[0]['id']) + 1, 'Inconsistent history spotted'

# Run incremental export using non-existent history id.
next_id = int(history[1]['id']) + 1
with pytest.raises(CLIReturnCodeError) as error:
target_sat.cli.ContentExport.incrementalRepository(
{'id': function_synced_rhel_repo['id'], 'from-history-id': next_id}
)
assert (
f"Couldn't find Katello::ContentViewVersionExportHistory with 'id'={next_id}"
in error.value.message
), 'Unexpected error message'

@pytest.mark.tier3
@pytest.mark.upgrade
Expand Down Expand Up @@ -1962,6 +2022,8 @@ def test_positive_export_import_mismatch_label(
:id: eb2f3e8e-3ee6-4713-80ab-3811a098e079
:parametrized: yes
:setup:
1. Enabled and synced RH yum repository.
Expand Down

0 comments on commit 352562f

Please sign in to comment.