Skip to content

Commit

Permalink
[6.15.z] less flakiness in rex module (#17664)
Browse files Browse the repository at this point in the history
  • Loading branch information
Satellite-QE authored Feb 24, 2025
1 parent 0d0a8db commit 5cc608b
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions tests/foreman/cli/test_remoteexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ def test_positive_time_expressions(self, rex_contenthost, target_sat):
"""
client = rex_contenthost
today = datetime.today()
hour = datetime.now().hour
last_day_of_month = monthrange(today.year, today.month)[1]
# cronline uses https://github.com/floraison/fugit
fugit_expressions = [
Expand All @@ -484,22 +483,11 @@ def test_positive_time_expressions(self, rex_contenthost, target_sat):
'@hourly',
f'{(datetime.utcnow() + timedelta(hours=1)).strftime("%Y/%m/%d %H")}:00:00',
],
# 23 mins after every other hour
[
'23 0-23/2 * * *',
f'{today.strftime("%Y/%m/%d")} '
f'{(str(hour if hour % 2 == 0 else hour + 1)).rjust(2, "0")}:23:00',
],
# last day of month
[
'0 0 last * *',
f'{today.strftime("%Y/%m")}/{last_day_of_month} 00:00:00',
],
# last 7 days of month
[
'0 0 -7-L * *',
f'{today.strftime("%Y/%m")}/{last_day_of_month - 6} 00:00:00',
],
# last friday of month at 7
[
'0 7 * * fri#-1',
Expand All @@ -526,7 +514,7 @@ def test_positive_time_expressions(self, rex_contenthost, target_sat):
)

@pytest.mark.tier3
@pytest.mark.rhel_ver_list([8])
@pytest.mark.rhel_ver_list([9])
def test_positive_run_scheduled_job_template(self, rex_contenthost, target_sat):
"""Schedule a job to be ran against a host
Expand All @@ -540,7 +528,7 @@ def test_positive_run_scheduled_job_template(self, rex_contenthost, target_sat):
client = rex_contenthost
system_current_time = target_sat.execute('date --utc +"%b %d %Y %I:%M%p"').stdout
current_time_object = datetime.strptime(system_current_time.strip('\n'), '%b %d %Y %I:%M%p')
plan_time = (current_time_object + timedelta(seconds=30)).strftime("%Y-%m-%d %H:%M")
plan_time = (current_time_object + timedelta(seconds=30)).strftime("%Y-%m-%d %H:%M UTC")
invocation_command = target_sat.cli_factory.job_invocation(
{
'job-template': 'Run Command - Script Default',
Expand All @@ -550,12 +538,9 @@ def test_positive_run_scheduled_job_template(self, rex_contenthost, target_sat):
}
)
# Wait until the job runs
pending_state = '1'
while pending_state != '0':
invocation_info = target_sat.cli.JobInvocation.info({'id': invocation_command['id']})
pending_state = invocation_info['pending']
sleep(30)
assert_job_invocation_result(target_sat, invocation_command['id'], client.hostname)
target_sat.wait_for_tasks(
f'resource_type = JobInvocation and resource_id = {invocation_command["id"]}'
)

@pytest.mark.tier3
@pytest.mark.rhel_ver_list([8, 9])
Expand Down

0 comments on commit 5cc608b

Please sign in to comment.