-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into document-conn-limit
- Loading branch information
Showing
7 changed files
with
99 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
### Added | ||
|
||
### Fixed | ||
- Job_template and workflow_template actions honor custom hosts limit | ||
|
||
### Removed | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
from ansible_rulebook.action.control import Control | ||
from ansible_rulebook.action.metadata import Metadata | ||
|
||
|
||
@pytest.fixture | ||
def base_metadata(): | ||
return Metadata( | ||
rule="r1", | ||
rule_set="rs1", | ||
rule_uuid="u1", | ||
rule_set_uuid="u2", | ||
rule_run_at="abc", | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def base_control(): | ||
return Control( | ||
queue=asyncio.Queue(), | ||
inventory="abc", | ||
hosts=["all"], | ||
variables={"a": 1}, | ||
project_data_file="", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import pytest | ||
|
||
from ansible_rulebook.action.run_job_template import RunJobTemplate | ||
from ansible_rulebook.action.run_workflow_template import RunWorkflowTemplate | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"template_class", | ||
[ | ||
pytest.param(RunJobTemplate, id="job_template"), | ||
pytest.param(RunWorkflowTemplate, id="workflow_template"), | ||
], | ||
) | ||
@pytest.mark.parametrize( | ||
"input,expected", | ||
[ | ||
pytest.param({"limit": "localhost"}, "localhost", id="single_host"), | ||
pytest.param( | ||
{"limit": "localhost,localhost2"}, | ||
"localhost,localhost2", | ||
id="multiple_hosts_str", | ||
), | ||
pytest.param( | ||
{"limit": ["localhost", "localhost2"]}, | ||
"localhost,localhost2", | ||
id="multiple_hosts", | ||
), | ||
pytest.param({}, "all", id="default"), | ||
], | ||
) | ||
@pytest.mark.asyncio | ||
async def test_controller_custom_host_limit( | ||
input, expected, template_class, base_metadata, base_control | ||
): | ||
"""Test controller templates process the host limit in job_args.""" | ||
action_args = { | ||
"name": "fred", | ||
"organization": "Default", | ||
"retries": 1, | ||
"retry": True, | ||
"delay": 1, | ||
"set_facts": True, | ||
"job_args": input, | ||
} | ||
template = template_class(base_metadata, base_control, **action_args) | ||
assert template.job_args["limit"] == expected |