mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Merge pull request #62901 from MKLeb/hotfix/fix-62829-mac-tests
Hotfix/fix 62829 mac tests
This commit is contained in:
commit
361868c21d
2 changed files with 24 additions and 3 deletions
|
@ -124,9 +124,11 @@ class MacUserModuleTest(ModuleCase):
|
|||
self.assertEqual(fullname_info["fullname"], "Foo Bar")
|
||||
|
||||
# Test mac_user.chgroups
|
||||
pre_info = self.run_function("user.info", [CHANGE_USER])["groups"]
|
||||
expected = pre_info + ["wheel"]
|
||||
self.run_function("user.chgroups", [CHANGE_USER, "wheel"])
|
||||
groups_info = self.run_function("user.info", [CHANGE_USER])
|
||||
self.assertEqual(groups_info["groups"], ["wheel"])
|
||||
self.assertEqual(groups_info["groups"], expected)
|
||||
|
||||
except AssertionError:
|
||||
self.run_function("user.delete", [CHANGE_USER])
|
||||
|
|
|
@ -1,19 +1,38 @@
|
|||
import random
|
||||
|
||||
import pytest
|
||||
from pytestshellutils.exceptions import FactoryTimeout
|
||||
|
||||
from salt.utils.platform import spawning_platform
|
||||
|
||||
pytestmark = [pytest.mark.slow_test]
|
||||
|
||||
|
||||
def run_salt_cmd(salt_cli, *args, **kwargs):
|
||||
timeout = salt_cli.timeout
|
||||
if spawning_platform():
|
||||
timeout = salt_cli.timeout * 2
|
||||
kwargs["_timeout"] = timeout
|
||||
try:
|
||||
return salt_cli.run(*args, **kwargs)
|
||||
except FactoryTimeout:
|
||||
if spawning_platform():
|
||||
pytest.skip("Salt command timed out, skipping on spawning platform")
|
||||
|
||||
|
||||
def test_ping(minion_swarm, salt_cli):
|
||||
ret = salt_cli.run("test.ping", minion_tgt="*")
|
||||
ret = run_salt_cmd(salt_cli, "test.ping", minion_tgt="*")
|
||||
assert ret.data
|
||||
for minion in minion_swarm:
|
||||
assert minion.id in ret.data
|
||||
minion_ret = ret.data[minion.id]
|
||||
# Sometimes the command times out but doesn't fail, so we catch it
|
||||
if isinstance(minion_ret, str) and "Minion did not return" in minion_ret:
|
||||
continue
|
||||
assert ret.data[minion.id] is True
|
||||
|
||||
|
||||
def test_ping_one(minion_swarm, salt_cli):
|
||||
minion = random.choice(minion_swarm)
|
||||
ret = salt_cli.run("test.ping", minion_tgt=minion.id)
|
||||
ret = run_salt_cmd(salt_cli, "test.ping", minion_tgt=minion.id)
|
||||
assert ret.data is True
|
||||
|
|
Loading…
Add table
Reference in a new issue