mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Updated tests and removed debugging statements
This commit is contained in:
parent
cb39a7d377
commit
fa295250af
2 changed files with 4 additions and 118 deletions
|
@ -6,7 +6,6 @@ import fnmatch
|
||||||
import glob
|
import glob
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import traceback
|
|
||||||
|
|
||||||
import salt.client
|
import salt.client
|
||||||
import salt.defaults.exitcodes
|
import salt.defaults.exitcodes
|
||||||
|
@ -342,12 +341,7 @@ class ReactWrap:
|
||||||
"""
|
"""
|
||||||
Execute a reaction by invoking the proper wrapper func
|
Execute a reaction by invoking the proper wrapper func
|
||||||
"""
|
"""
|
||||||
print(f"DGM class ReactWrap entry run, low '{low}'", flush=True)
|
|
||||||
self.populate_client_cache(low)
|
self.populate_client_cache(low)
|
||||||
print(
|
|
||||||
f"DGM class ReactWrap run, self.client_cache '{self.client_cache}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
l_fun = getattr(self, low["state"])
|
l_fun = getattr(self, low["state"])
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -470,21 +464,10 @@ class ReactWrap:
|
||||||
"""
|
"""
|
||||||
Wrap RunnerClient for executing :ref:`runner modules <all-salt.runners>`
|
Wrap RunnerClient for executing :ref:`runner modules <all-salt.runners>`
|
||||||
"""
|
"""
|
||||||
stk_summary = traceback.format_stack()
|
|
||||||
print(f"DGM class ReactWrap runner entry, backtrace '{stk_summary}'")
|
|
||||||
# pylint: disable=unsupported-membership-test,unsupported-assignment-operation
|
# pylint: disable=unsupported-membership-test,unsupported-assignment-operation
|
||||||
print(
|
|
||||||
f"DGM class ReactWrap runner, client_cache '{self.client_cache}', fun '{fun}', kwargs '{kwargs}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
if "runner" not in self.client_cache:
|
if "runner" not in self.client_cache:
|
||||||
log.debug("reactor edge case: re-populating client_cache for runner")
|
log.debug("reactor edge case: re-populating client_cache for runner")
|
||||||
low = {"state": "runner"}
|
low = {"state": "runner"}
|
||||||
print(
|
|
||||||
f"DGM class ReactWrap runner not in client_cache, low '{low}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
self.populate_client_cache(low)
|
self.populate_client_cache(low)
|
||||||
return self.pool.fire_async(self.client_cache["runner"].low, args=(fun, kwargs))
|
return self.pool.fire_async(self.client_cache["runner"].low, args=(fun, kwargs))
|
||||||
|
|
||||||
|
@ -493,17 +476,9 @@ class ReactWrap:
|
||||||
Wrap Wheel to enable executing :ref:`wheel modules <all-salt.wheel>`
|
Wrap Wheel to enable executing :ref:`wheel modules <all-salt.wheel>`
|
||||||
"""
|
"""
|
||||||
# pylint: disable=unsupported-membership-test,unsupported-assignment-operation
|
# pylint: disable=unsupported-membership-test,unsupported-assignment-operation
|
||||||
print(
|
|
||||||
f"DGM class ReactWrap wheel, client_cache '{self.client_cache}', fun '{fun}', kwargs '{kwargs}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
if "wheel" not in self.client_cache:
|
if "wheel" not in self.client_cache:
|
||||||
log.debug("reactor edge case: re-populating client_cache for wheel")
|
log.debug("reactor edge case: re-populating client_cache for wheel")
|
||||||
low = {"state": "wheel"}
|
low = {"state": "wheel"}
|
||||||
print(
|
|
||||||
f"DGM class ReactWrap wheel not in client_cache, low '{low}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
self.populate_client_cache(low)
|
self.populate_client_cache(low)
|
||||||
return self.pool.fire_async(self.client_cache["wheel"].low, args=(fun, kwargs))
|
return self.pool.fire_async(self.client_cache["wheel"].low, args=(fun, kwargs))
|
||||||
|
|
||||||
|
@ -512,17 +487,9 @@ class ReactWrap:
|
||||||
Wrap LocalClient for running :ref:`execution modules <all-salt.modules>`
|
Wrap LocalClient for running :ref:`execution modules <all-salt.modules>`
|
||||||
"""
|
"""
|
||||||
# pylint: disable=unsupported-membership-test,unsupported-assignment-operation
|
# pylint: disable=unsupported-membership-test,unsupported-assignment-operation
|
||||||
print(
|
|
||||||
f"DGM class ReactWrap local, client_cache '{self.client_cache}', fun '{fun}', kwargs '{kwargs}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
if "local" not in self.client_cache:
|
if "local" not in self.client_cache:
|
||||||
log.debug("reactor edge case: re-populating client_cache for local")
|
log.debug("reactor edge case: re-populating client_cache for local")
|
||||||
low = {"state": "local"}
|
low = {"state": "local"}
|
||||||
print(
|
|
||||||
f"DGM class ReactWrap local not in client_cache, low '{low}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
self.populate_client_cache(low)
|
self.populate_client_cache(low)
|
||||||
self.client_cache["local"].cmd_async(tgt, fun, **kwargs)
|
self.client_cache["local"].cmd_async(tgt, fun, **kwargs)
|
||||||
|
|
||||||
|
@ -531,16 +498,8 @@ class ReactWrap:
|
||||||
Wrap LocalCaller to execute remote exec functions locally on the Minion
|
Wrap LocalCaller to execute remote exec functions locally on the Minion
|
||||||
"""
|
"""
|
||||||
# pylint: disable=unsupported-membership-test,unsupported-assignment-operation
|
# pylint: disable=unsupported-membership-test,unsupported-assignment-operation
|
||||||
print(
|
|
||||||
f"DGM class ReactWrap caller, client_cache '{self.client_cache}', fun '{fun}', kwargs '{kwargs}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
if "caller" not in self.client_cache:
|
if "caller" not in self.client_cache:
|
||||||
log.debug("reactor edge case: re-populating client_cache for caller")
|
log.debug("reactor edge case: re-populating client_cache for caller")
|
||||||
low = {"state": "caller"}
|
low = {"state": "caller"}
|
||||||
print(
|
|
||||||
f"DGM class ReactWrap caller not in client_cache, low '{low}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
self.populate_client_cache(low)
|
self.populate_client_cache(low)
|
||||||
self.client_cache["caller"].cmd(fun, *kwargs["arg"], **kwargs["kwarg"])
|
self.client_cache["caller"].cmd(fun, *kwargs["arg"], **kwargs["kwarg"])
|
||||||
|
|
|
@ -560,54 +560,7 @@ def test_caller(schema, react_wrap):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
## DGM ## DGM @pytest.mark.parametrize("file_client", ["runner", "wheel", "local", "caller"])
|
@pytest.mark.parametrize("file_client", ["runner", "wheel", "local", "caller"])
|
||||||
## DGM @pytest.mark.parametrize("file_client", ["runner"])
|
|
||||||
## DGM def test_client_cache_missing_key(file_client, react_wrap):
|
|
||||||
## DGM """
|
|
||||||
## DGM Test client_cache file_client missing, gets repopulated
|
|
||||||
## DGM """
|
|
||||||
## DGM client_cache = {}
|
|
||||||
## DGM tag = f"new_{file_client}"
|
|
||||||
## DGM chunk = LOW_CHUNKS[tag][0]
|
|
||||||
## DGM print(
|
|
||||||
## DGM f"DGM test_client_cache_missing_key, file_client '{file_client}', tag '{tag}', chunk '{chunk}'",
|
|
||||||
## DGM flush=True,
|
|
||||||
## DGM )
|
|
||||||
## DGM thread_pool = Mock()
|
|
||||||
## DGM thread_pool.fire_async = Mock()
|
|
||||||
## DGM with patch.object(react_wrap, "client_cache", client_cache):
|
|
||||||
## DGM print(
|
|
||||||
## DGM f"DGM test_client_cache_missing_key patch client_cache, file_client '{file_client}', react_wrap.client_cache '{react_wrap.client_cache}'",
|
|
||||||
## DGM flush=True,
|
|
||||||
## DGM )
|
|
||||||
## DGM with patch.object(react_wrap, "pool", thread_pool):
|
|
||||||
## DGM print(
|
|
||||||
## DGM f"DGM test_client_cache_missing_key patch pool, file_client '{file_client}', react_wrap.client_cache '{react_wrap.client_cache}'",
|
|
||||||
## DGM flush=True,
|
|
||||||
## DGM )
|
|
||||||
## DGM ## DGM del react_wrap.client_cache[f"{file_client}"]
|
|
||||||
## DGM print(
|
|
||||||
## DGM f"DGM test_client_cache_missing_key post del key, file_client '{file_client}', react_wrap.client_cache '{react_wrap.client_cache}'",
|
|
||||||
## DGM flush=True,
|
|
||||||
## DGM )
|
|
||||||
## DGM react_wrap.run(chunk)
|
|
||||||
## DGM
|
|
||||||
## DGM print(
|
|
||||||
## DGM f"DGM test_client_cache_missing_key post patch, file_client '{file_client}', react_wrap.client_cache '{react_wrap.client_cache}'",
|
|
||||||
## DGM flush=True,
|
|
||||||
## DGM )
|
|
||||||
## DGM
|
|
||||||
## DGM thread_pool.fire_async.assert_called_with(
|
|
||||||
## DGM react_wrap.client_cache[file_client].low,
|
|
||||||
## DGM args=WRAPPER_CALLS[tag],
|
|
||||||
## DGM )
|
|
||||||
## DGM client_cache[file_client].cmd.assert_called_with(
|
|
||||||
## DGM *WRAPPER_CALLS[tag]["args"], **WRAPPER_CALLS[tag]["kwargs"]
|
|
||||||
## DGM )
|
|
||||||
|
|
||||||
|
|
||||||
## DGM @pytest.mark.parametrize("file_client", ["runner", "wheel", "local", "caller"])
|
|
||||||
@pytest.mark.parametrize("file_client", ["runner"])
|
|
||||||
def test_client_cache_missing_key(file_client, react_wrap):
|
def test_client_cache_missing_key(file_client, react_wrap):
|
||||||
"""
|
"""
|
||||||
Test client_cache file_client missing, gets repopulated
|
Test client_cache file_client missing, gets repopulated
|
||||||
|
@ -615,37 +568,11 @@ def test_client_cache_missing_key(file_client, react_wrap):
|
||||||
client_cache = {}
|
client_cache = {}
|
||||||
tag = f"new_{file_client}"
|
tag = f"new_{file_client}"
|
||||||
chunk = LOW_CHUNKS[tag][0]
|
chunk = LOW_CHUNKS[tag][0]
|
||||||
print(
|
|
||||||
f"DGM test_client_cache_missing_key, file_client '{file_client}', tag '{tag}', chunk '{chunk}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
thread_pool = Mock()
|
|
||||||
thread_pool.fire_async = Mock()
|
|
||||||
with patch.object(react_wrap, "client_cache", client_cache):
|
with patch.object(react_wrap, "client_cache", client_cache):
|
||||||
print(
|
|
||||||
f"DGM test_client_cache_missing_key patch client_cache, file_client '{file_client}', react_wrap.client_cache '{react_wrap.client_cache}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
react_wrap.runner(chunk)
|
react_wrap.runner(chunk)
|
||||||
print(
|
file_client_key = None
|
||||||
f"DGM test_client_cache_missing_key post runner, file_client '{file_client}', react_wrap.client_cache '{react_wrap.client_cache}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
## DGM dgm_key = react_wrap.client_cache.get(f"{file_client}")
|
|
||||||
## DGM dgm_key = [key for key in react_wrap.client_cache.keys() if key == f"{file_client}"]
|
|
||||||
## DGM dgm_key = None
|
|
||||||
## DGM dgm_key = [key if key == f"{file_client}" for key in react_wrap.client_cache.keys()]
|
|
||||||
dgm_keys = None
|
|
||||||
for key in react_wrap.client_cache.keys():
|
for key in react_wrap.client_cache.keys():
|
||||||
if key == f"{file_client}":
|
if key == f"{file_client}":
|
||||||
dgm_key = key
|
file_client_key = key
|
||||||
print(
|
|
||||||
f"DGM test_client_cache_missing_key check key, file_client '{file_client}', dgm_key '{dgm_key}', react_wrap.client_cache.keys '{react_wrap.client_cache.keys()}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
print(
|
assert file_client_key == f"{file_client}"
|
||||||
f"DGM test_client_cache_missing_key post get key, file_client '{file_client}', dgm_key '{dgm_key}', react_wrap.client_cache '{react_wrap.client_cache}'",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
assert dgm_key == f"{file_client}"
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue