Skip to content

Commit

Permalink
Adding Enable/Disable for automatic inventory upload
Browse files Browse the repository at this point in the history
Signed-off-by: Adarsh Dubey <[email protected]>
  • Loading branch information
adarshdubey-star authored and pondrejk committed Nov 7, 2022
1 parent cef405c commit f1c496c
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions tests/foreman/cli/test_rhcloud_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,24 +288,27 @@ def test_positive_generate_all_reports_job(target_sat):
:CaseLevel: System
"""
target_sat.update_setting('allow_auto_inventory_upload', False)
with target_sat.session.shell() as sh:
sh.send('foreman-rake console')
time.sleep(30) # sleep to allow time for console to open
sh.send(f'ForemanTasks.async_task({generate_report_jobs})')
time.sleep(3) # sleep for the cmd execution
timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M')
wait_for(
lambda: target_sat.api.ForemanTask()
.search(query={'search': f'{generate_report_jobs} and started_at >= "{timestamp}"'})[0]
.result
== 'success',
timeout=400,
delay=15,
silent_failure=True,
handle_exception=True,
)
task_output = target_sat.api.ForemanTask().search(
query={'search': f'{generate_report_jobs} and started_at >= {timestamp}'}
)
assert task_output[0].result == "success"
try:
target_sat.update_setting('allow_auto_inventory_upload', False)
with target_sat.session.shell() as sh:
sh.send('foreman-rake console')
time.sleep(30) # sleep to allow time for console to open
sh.send(f'ForemanTasks.async_task({generate_report_jobs})')
time.sleep(3) # sleep for the cmd execution
timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M')
wait_for(
lambda: target_sat.api.ForemanTask()
.search(query={'search': f'{generate_report_jobs} and started_at >= "{timestamp}"'})[0]
.result
== 'success',
timeout=400,
delay=15,
silent_failure=True,
handle_exception=True,
)
task_output = target_sat.api.ForemanTask().search(
query={'search': f'{generate_report_jobs} and started_at >= {timestamp}'}
)
assert task_output[0].result == "success"
finally:
target_sat.update_setting('allow_auto_inventory_upload', True)

0 comments on commit f1c496c

Please sign in to comment.