mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Updated test
This commit is contained in:
parent
c63920b2f1
commit
b78d771454
1 changed files with 42 additions and 0 deletions
42
tests/pytests/integration/master/test_payload.py
Normal file
42
tests/pytests/integration/master/test_payload.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
"""
|
||||
Tests for payload
|
||||
"""
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.slow_test
|
||||
@pytest.mark.skip_if_not_root
|
||||
@pytest.mark.skip_on_windows
|
||||
@pytest.mark.skip_on_darwin
|
||||
def test_payload_no_exception(salt_cli, salt_master, salt_minion):
|
||||
"""
|
||||
Test to confirm that no exception is thrown with the jinja file
|
||||
when executed on the minion
|
||||
"""
|
||||
test_set_hostname = """
|
||||
{%- set host = pillar.get("hostname", "UNKNOWN") %}
|
||||
{%- if host == 'UNKNOWN' %}
|
||||
{{ raise("Unsupported UNKNOWN hostname") }}
|
||||
{%- else %}
|
||||
hostnamectl set-hostname {{ host }}
|
||||
{%- endif %}
|
||||
"""
|
||||
with salt_master.state_tree.base.temp_file("set_hostname.j2", test_set_hostname):
|
||||
|
||||
ret = salt_cli.run("test.ping", minion_tgt=salt_minion.id)
|
||||
assert ret.returncode == 0
|
||||
assert ret.data is True
|
||||
|
||||
ret = salt_cli.run(
|
||||
"cmd.script",
|
||||
"salt://set_hostname.j2",
|
||||
"template=jinja",
|
||||
pillar={"hostname": "test"},
|
||||
minion_tgt=salt_minion.id,
|
||||
)
|
||||
log.warning(f"DGM output '{ret}'")
|
||||
## assert not ret.stdout.startswith("Authentication failure")
|
Loading…
Add table
Reference in a new issue