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

Check that concurrency level is honored #13198

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
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
72 changes: 72 additions & 0 deletions tests/foreman/cli/test_remoteexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,78 @@ def test_positive_run_concurrent_jobs(self, registered_hosts, target_sat):
target_sat.cli.GlobalParameter().delete({'name': param_name})
assert len(target_sat.cli.GlobalParameter().list({'search': param_name})) == 0

@pytest.mark.tier3
@pytest.mark.no_containers
def test_positive_run_serial(self, registered_hosts, target_sat):
"""Tests subtasks in a job run one by one when concurrency level set to 1
:id: 5ce39447-82d0-42df-81be-16ed3d67a2a4
:Setup:
0. Create 2 hosts
:Steps:
0. Run a bash command job with concurrency level 1
:expectedresults: First subtask should run immediately, second one after the first one finishes
:CaseAutomation: Automated
:CaseLevel: System
:parametrized: yes
"""
hosts = registered_hosts
output_msgs = []
template_file = f"/root/{gen_string('alpha')}.template"
target_sat.execute(
f"echo 'rm /root/test-<%= @host %>; echo $(date +%s) >> /root/test-<%= @host %>; sleep 120; echo $(date +%s) >> /root/test-<%= @host %>' > {template_file}"
Copy link
Contributor

Choose a reason for hiding this comment

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

what does the <%= @host %> part do? Is this specific to Job Templates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's an ERB syntax and it outputs hostname

)
template = target_sat.cli.JobTemplate.create(
{
'name': gen_string('alpha'),
'file': template_file,
'job-category': 'Commands',
'provider-type': 'script',
}
)
invocation = target_sat.cli_factory.job_invocation(
{
'job-template': template['name'],
'search-query': f'name ~ {hosts[0].hostname} or name ~ {hosts[1].hostname}',
'concurrency-level': 1,
}
)
for vm in hosts:
output_msgs.append(
'host output from {}: {}'.format(
vm.hostname,
' '.join(
target_sat.cli.JobInvocation.get_output(
{'id': invocation['id'], 'host': vm.hostname}
)
),
)
)
result = target_sat.cli.JobInvocation.info({'id': invocation['id']})
assert result['success'] == '2', output_msgs
# assert for time diffs
file1 = hosts[0].execute('cat /root/test-$(hostname)').stdout
file2 = hosts[1].execute('cat /root/test-$(hostname)').stdout
file1_start, file1_end = map(int, file1.rstrip().split('\n'))
file2_start, file2_end = map(int, file2.rstrip().split('\n'))
if file1_start > file2_start:
file1_start, file1_end, file2_start, file2_end = (
file2_start,
file2_end,
file1_start,
file1_end,
)
assert file1_end - file1_start >= 120
assert file2_end - file2_start >= 120
assert file2_start >= file1_end # the jobs did NOT run concurrently

@pytest.mark.tier3
@pytest.mark.upgrade
@pytest.mark.e2e
Expand Down
Loading