mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge 3006.x into 3007.x
This commit is contained in:
commit
6e1372d66f
13 changed files with 72 additions and 33 deletions
1
changelog/66006.fixed.md
Normal file
1
changelog/66006.fixed.md
Normal file
|
@ -0,0 +1 @@
|
|||
Fix exceptions being set on futures that are already done in ZeroMQ transport
|
|
@ -741,14 +741,16 @@ class AsyncReqMessageClient:
|
|||
try:
|
||||
recv = yield self.socket.recv()
|
||||
except zmq.eventloop.future.CancelledError as exc:
|
||||
future.set_exception(exc)
|
||||
if not future.done():
|
||||
future.set_exception(exc)
|
||||
return
|
||||
|
||||
if not future.done():
|
||||
data = salt.payload.loads(recv)
|
||||
future.set_result(data)
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
future.set_exception(exc)
|
||||
if not future.done():
|
||||
future.set_exception(exc)
|
||||
|
||||
|
||||
class ZeroMQSocketMonitor:
|
||||
|
|
|
@ -460,9 +460,12 @@ def pytest_collection_modifyitems(config, items):
|
|||
if marker is not None:
|
||||
if not salt.utils.platform.is_windows():
|
||||
# Apply the marker since we're not on windows
|
||||
item.add_marker(
|
||||
pytest.mark.timeout(*marker.args, **marker.kwargs.copy())
|
||||
)
|
||||
marker_kwargs = marker.kwargs.copy()
|
||||
if "func_only" not in marker_kwargs:
|
||||
# Default to counting only the test execution for the timeouts, ie,
|
||||
# withough including the fixtures setup time towards the timeout.
|
||||
marker_kwargs["func_only"] = True
|
||||
item.add_marker(pytest.mark.timeout(*marker.args, **marker_kwargs))
|
||||
else:
|
||||
if (
|
||||
not salt.utils.platform.is_windows()
|
||||
|
@ -473,7 +476,9 @@ def pytest_collection_modifyitems(config, items):
|
|||
):
|
||||
# Let's apply the timeout marker on the test, if the marker
|
||||
# is not already applied
|
||||
item.add_marker(pytest.mark.timeout(90))
|
||||
# Default to counting only the test execution for the timeouts, ie,
|
||||
# withough including the fixtures setup time towards the timeout.
|
||||
item.add_marker(pytest.mark.timeout(90, func_only=True))
|
||||
for fixture in item.fixturenames:
|
||||
if fixture not in item._fixtureinfo.name2fixturedefs:
|
||||
continue
|
||||
|
|
|
@ -56,7 +56,6 @@ class SSHStateTest(SSHCase):
|
|||
self.assertTrue(check_file)
|
||||
|
||||
@pytest.mark.slow_test
|
||||
@pytest.mark.timeout_unless_on_windows(120)
|
||||
def test_state_sls_id(self):
|
||||
"""
|
||||
test state.sls_id with salt-ssh
|
||||
|
|
|
@ -9,7 +9,7 @@ from tests.support.pytest.helpers import FakeSaltExtension
|
|||
pytestmark = [
|
||||
# These are slow because they create a virtualenv and install salt in it
|
||||
pytest.mark.slow_test,
|
||||
pytest.mark.timeout_unless_on_windows(120),
|
||||
pytest.mark.timeout_unless_on_windows(240),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ pytestmark = [
|
|||
pytest.mark.slow_test,
|
||||
pytest.mark.skip_if_not_root,
|
||||
pytest.mark.destructive_test,
|
||||
pytest.mark.timeout_unless_on_windows(120),
|
||||
pytest.mark.timeout_unless_on_windows(240),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ pytestmark = [
|
|||
reason="Deltaproxy minions do not currently work on spawning platforms.",
|
||||
),
|
||||
pytest.mark.core_test,
|
||||
pytest.mark.timeout_unless_on_windows(320),
|
||||
pytest.mark.timeout_unless_on_windows(400),
|
||||
]
|
||||
|
||||
|
||||
|
@ -182,7 +182,7 @@ def test_exit_status_correct_usage(
|
|||
proxy_minion_id,
|
||||
defaults=config_defaults,
|
||||
extra_cli_arguments_after_first_start_failure=["--log-level=info"],
|
||||
start_timeout=240,
|
||||
start_timeout=320,
|
||||
)
|
||||
|
||||
for minion_id in (proxy_minion_id, proxy_one, proxy_two):
|
||||
|
@ -285,7 +285,7 @@ def test_missing_pillar_file(
|
|||
proxy_minion_id,
|
||||
defaults=config_defaults,
|
||||
extra_cli_arguments_after_first_start_failure=["--log-level=info"],
|
||||
start_timeout=240,
|
||||
start_timeout=320,
|
||||
)
|
||||
|
||||
for minion_id in (proxy_minion_id, proxy_one, proxy_two):
|
||||
|
@ -409,7 +409,7 @@ def test_invalid_connection(
|
|||
proxy_minion_id,
|
||||
defaults=config_defaults,
|
||||
extra_cli_arguments_after_first_start_failure=["--log-level=info"],
|
||||
start_timeout=240,
|
||||
start_timeout=320,
|
||||
)
|
||||
|
||||
for minion_id in (
|
||||
|
@ -538,7 +538,7 @@ def ping():
|
|||
proxy_minion_id,
|
||||
defaults=config_defaults,
|
||||
extra_cli_arguments_after_first_start_failure=["--log-level=info"],
|
||||
start_timeout=240,
|
||||
start_timeout=320,
|
||||
)
|
||||
|
||||
for minion_id in (proxy_minion_id, proxy_one, proxy_two):
|
||||
|
@ -671,7 +671,7 @@ def ping():
|
|||
proxy_minion_id,
|
||||
defaults=config_defaults,
|
||||
extra_cli_arguments_after_first_start_failure=["--log-level=info"],
|
||||
start_timeout=240,
|
||||
start_timeout=320,
|
||||
)
|
||||
|
||||
for minion_id in (proxy_minion_id, proxy_one, proxy_two):
|
||||
|
@ -812,7 +812,7 @@ def test_exit_status_correct_usage_large_number_of_minions(
|
|||
proxy_minion_id,
|
||||
defaults=config_defaults,
|
||||
extra_cli_arguments_after_first_start_failure=["--log-level=info"],
|
||||
start_timeout=240,
|
||||
start_timeout=320,
|
||||
)
|
||||
|
||||
for minion_id in [proxy_minion_id] + sub_proxies:
|
||||
|
|
|
@ -12,7 +12,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
pytestmark = [
|
||||
pytest.mark.core_test,
|
||||
pytest.mark.timeout_unless_on_windows(600, func_only=True),
|
||||
pytest.mark.timeout_unless_on_windows(600),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -6,18 +6,15 @@ import pytest
|
|||
|
||||
pytestmark = [
|
||||
pytest.mark.slow_test,
|
||||
pytest.mark.timeout_unless_on_windows(360),
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def testfile_path(tmp_path):
|
||||
return tmp_path / "testfile"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def file_add_delete_sls(testfile_path, base_env_state_tree_root_dir):
|
||||
def file_add_delete_sls(tmp_path, salt_master):
|
||||
path = tmp_path / "testfile"
|
||||
sls_name = "file_add"
|
||||
sls_contents = """
|
||||
sls_contents = f"""
|
||||
add_file:
|
||||
file.managed:
|
||||
- name: {path}
|
||||
|
@ -35,16 +32,13 @@ def file_add_delete_sls(testfile_path, base_env_state_tree_root_dir):
|
|||
echo:
|
||||
cmd.run:
|
||||
- name: \"echo 'This is a test!'\"
|
||||
""".format(
|
||||
path=testfile_path
|
||||
)
|
||||
with pytest.helpers.temp_file(
|
||||
f"{sls_name}.sls", sls_contents, base_env_state_tree_root_dir
|
||||
):
|
||||
"""
|
||||
with salt_master.state_tree.base.temp_file(f"{sls_name}.sls", sls_contents):
|
||||
yield sls_name
|
||||
|
||||
|
||||
@pytest.mark.skip_on_fips_enabled_platform
|
||||
@pytest.mark.skip_on_windows(reason="Windows is a spawning platform, won't work")
|
||||
@pytest.mark.skip_on_darwin(reason="MacOS is a spawning platform, won't work")
|
||||
@pytest.mark.flaky(max_runs=4)
|
||||
def test_memory_leak(salt_cli, salt_minion, file_add_delete_sls):
|
||||
|
|
|
@ -15,7 +15,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
pytestmark = [
|
||||
pytest.mark.slow_test,
|
||||
pytest.mark.timeout_unless_on_windows(120, func_only=True),
|
||||
pytest.mark.timeout_unless_on_windows(120),
|
||||
pytest.mark.skip_if_binaries_missing("docker"),
|
||||
]
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ def test_ssh_disabled(client, auth_creds):
|
|||
assert ret is None
|
||||
|
||||
|
||||
@pytest.mark.timeout_unless_on_windows(360, func_only=True)
|
||||
@pytest.mark.timeout_unless_on_windows(360)
|
||||
def test_shell_inject_ssh_priv(
|
||||
client, salt_ssh_roster_file, rosters_dir, tmp_path, salt_auto_account, grains
|
||||
):
|
||||
|
|
|
@ -9,7 +9,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
@pytest.mark.slow_test
|
||||
@pytest.mark.timeout_unless_on_windows(120)
|
||||
@pytest.mark.timeout_unless_on_windows(240)
|
||||
def test_present_absent(salt_master, salt_minion, salt_call_cli):
|
||||
ret = salt_call_cli.run("beacons.reset")
|
||||
|
||||
|
|
|
@ -2,10 +2,15 @@ import logging
|
|||
|
||||
import msgpack
|
||||
import pytest
|
||||
import zmq.eventloop.future
|
||||
|
||||
import salt.config
|
||||
import salt.transport.base
|
||||
import salt.transport.zeromq
|
||||
import salt.utils.platform
|
||||
import salt.utils.process
|
||||
import salt.utils.stringutils
|
||||
from tests.support.mock import AsyncMock, MagicMock
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -53,6 +58,39 @@ async def test_client_timeout_msg(minion_opts):
|
|||
client.close()
|
||||
|
||||
|
||||
async def test_client_send_recv_on_cancelled_error(minion_opts):
|
||||
client = salt.transport.zeromq.AsyncReqMessageClient(
|
||||
minion_opts, "tcp://127.0.0.1:4506"
|
||||
)
|
||||
|
||||
mock_future = MagicMock(**{"done.return_value": True})
|
||||
|
||||
try:
|
||||
client.socket = AsyncMock()
|
||||
client.socket.recv.side_effect = zmq.eventloop.future.CancelledError
|
||||
await client._send_recv({"meh": "bah"}, mock_future)
|
||||
|
||||
mock_future.set_exception.assert_not_called()
|
||||
finally:
|
||||
client.close()
|
||||
|
||||
|
||||
async def test_client_send_recv_on_exception(minion_opts):
|
||||
client = salt.transport.zeromq.AsyncReqMessageClient(
|
||||
minion_opts, "tcp://127.0.0.1:4506"
|
||||
)
|
||||
|
||||
mock_future = MagicMock(**{"done.return_value": True})
|
||||
|
||||
try:
|
||||
client.socket = None
|
||||
await client._send_recv({"meh": "bah"}, mock_future)
|
||||
|
||||
mock_future.set_exception.assert_not_called()
|
||||
finally:
|
||||
client.close()
|
||||
|
||||
|
||||
def test_pub_client_init(minion_opts, io_loop):
|
||||
minion_opts["id"] = "minion"
|
||||
minion_opts["__role"] = "syndic"
|
||||
|
|
Loading…
Add table
Reference in a new issue