Try to address test flakyness

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-02-22 14:32:01 +00:00 committed by Pedro Algarvio
parent 3e0abed7dd
commit 7e83543354

View file

@ -384,18 +384,23 @@ class MockSaltMinionMaster:
)
self.server_thread.start()
minion_opts = temp_salt_minion.config.copy()
minion_opts.update({"master_ip": "127.0.0.1"})
minion_opts.update({"transport": "zeromq"})
minion_opts.update(
{
"master_ip": "127.0.0.1",
"transport": "zeromq",
}
)
self.channel = salt.channel.client.ReqChannel.factory(
minion_opts, crypt="clear"
)
def __enter__(self):
self.channel.__enter__()
self.evt.wait()
return self
def __exit__(self, *args, **kwargs):
self.channel.close()
self.channel.__exit__(*args, **kwargs)
del self.channel
# Attempting to kill the children hangs the test suite.
# Let the test suite handle this instead.
@ -666,6 +671,8 @@ def test_req_chan_decode_data_dict_entry_v1(pki_dir):
"id": "minion",
"__role": "minion",
"keysize": 4096,
"acceptance_wait_time": 3,
"acceptance_wait_time_max": 3,
}
master_opts = dict(opts, pki_dir=str(pki_dir.joinpath("master")))
server = salt.channel.server.ReqServerChannel.factory(master_opts)
@ -697,6 +704,8 @@ async def test_req_chan_decode_data_dict_entry_v2(pki_dir):
"id": "minion",
"__role": "minion",
"keysize": 4096,
"acceptance_wait_time": 3,
"acceptance_wait_time_max": 3,
}
master_opts = dict(opts, pki_dir=str(pki_dir.joinpath("master")))
server = salt.channel.server.ReqServerChannel.factory(master_opts)
@ -761,6 +770,8 @@ async def test_req_chan_decode_data_dict_entry_v2_bad_nonce(pki_dir):
"id": "minion",
"__role": "minion",
"keysize": 4096,
"acceptance_wait_time": 3,
"acceptance_wait_time_max": 3,
}
master_opts = dict(opts, pki_dir=str(pki_dir.joinpath("master")))
server = salt.channel.server.ReqServerChannel.factory(master_opts)
@ -825,6 +836,8 @@ async def test_req_chan_decode_data_dict_entry_v2_bad_signature(pki_dir):
"id": "minion",
"__role": "minion",
"keysize": 4096,
"acceptance_wait_time": 3,
"acceptance_wait_time_max": 3,
}
master_opts = dict(opts, pki_dir=str(pki_dir.joinpath("master")))
server = salt.channel.server.ReqServerChannel.factory(master_opts)
@ -905,6 +918,8 @@ async def test_req_chan_decode_data_dict_entry_v2_bad_key(pki_dir):
"id": "minion",
"__role": "minion",
"keysize": 4096,
"acceptance_wait_time": 3,
"acceptance_wait_time_max": 3,
}
master_opts = dict(opts, pki_dir=str(pki_dir.joinpath("master")))
server = salt.channel.server.ReqServerChannel.factory(master_opts)
@ -973,7 +988,7 @@ async def test_req_chan_decode_data_dict_entry_v2_bad_key(pki_dir):
}
with pytest.raises(salt.crypt.AuthenticationError) as excinfo:
ret = await client.crypted_transfer_decode_dictentry(
await client.crypted_transfer_decode_dictentry(
load,
dictkey="pillar",
)
@ -981,7 +996,6 @@ async def test_req_chan_decode_data_dict_entry_v2_bad_key(pki_dir):
async def test_req_serv_auth_v1(pki_dir):
mockloop = MagicMock()
opts = {
"master_uri": "tcp://127.0.0.1:4506",
"interface": "127.0.0.1",
@ -1035,7 +1049,6 @@ async def test_req_serv_auth_v1(pki_dir):
async def test_req_serv_auth_v2(pki_dir):
mockloop = MagicMock()
opts = {
"master_uri": "tcp://127.0.0.1:4506",
"interface": "127.0.0.1",
@ -1091,7 +1104,6 @@ async def test_req_serv_auth_v2(pki_dir):
async def test_req_chan_auth_v2(pki_dir, io_loop):
mockloop = MagicMock()
opts = {
"master_uri": "tcp://127.0.0.1:4506",
"interface": "127.0.0.1",
@ -1108,6 +1120,8 @@ async def test_req_chan_auth_v2(pki_dir, io_loop):
"key_pass": None,
"publish_port": 4505,
"auth_mode": 1,
"acceptance_wait_time": 3,
"acceptance_wait_time_max": 3,
}
SMaster.secrets["aes"] = {
"secret": multiprocessing.Array(
@ -1139,7 +1153,6 @@ async def test_req_chan_auth_v2(pki_dir, io_loop):
async def test_req_chan_auth_v2_with_master_signing(pki_dir, io_loop):
mockloop = MagicMock()
opts = {
"master_uri": "tcp://127.0.0.1:4506",
"interface": "127.0.0.1",
@ -1156,6 +1169,8 @@ async def test_req_chan_auth_v2_with_master_signing(pki_dir, io_loop):
"key_pass": None,
"publish_port": 4505,
"auth_mode": 1,
"acceptance_wait_time": 3,
"acceptance_wait_time_max": 3,
}
SMaster.secrets["aes"] = {
"secret": multiprocessing.Array(
@ -1231,7 +1246,6 @@ async def test_req_chan_auth_v2_with_master_signing(pki_dir, io_loop):
async def test_req_chan_auth_v2_new_minion_with_master_pub(pki_dir, io_loop):
pki_dir.joinpath("master", "minions", "minion").unlink()
mockloop = MagicMock()
opts = {
"master_uri": "tcp://127.0.0.1:4506",
"interface": "127.0.0.1",
@ -1249,6 +1263,7 @@ async def test_req_chan_auth_v2_new_minion_with_master_pub(pki_dir, io_loop):
"publish_port": 4505,
"auth_mode": 1,
"acceptance_wait_time": 3,
"acceptance_wait_time_max": 3,
}
SMaster.secrets["aes"] = {
"secret": multiprocessing.Array(
@ -1289,7 +1304,6 @@ async def test_req_chan_auth_v2_new_minion_with_master_pub_bad_sig(pki_dir, io_l
mapub.unlink()
mapub.write_text(MASTER2_PUB_KEY.strip())
mockloop = MagicMock()
opts = {
"master_uri": "tcp://127.0.0.1:4506",
"interface": "127.0.0.1",
@ -1307,6 +1321,7 @@ async def test_req_chan_auth_v2_new_minion_with_master_pub_bad_sig(pki_dir, io_l
"publish_port": 4505,
"auth_mode": 1,
"acceptance_wait_time": 3,
"acceptance_wait_time_max": 3,
}
SMaster.secrets["aes"] = {
"secret": multiprocessing.Array(
@ -1339,7 +1354,6 @@ async def test_req_chan_auth_v2_new_minion_without_master_pub(pki_dir, io_loop):
pki_dir.joinpath("master", "minions", "minion").unlink()
pki_dir.joinpath("minion", "minion_master.pub").unlink()
mockloop = MagicMock()
opts = {
"master_uri": "tcp://127.0.0.1:4506",
"interface": "127.0.0.1",
@ -1357,6 +1371,7 @@ async def test_req_chan_auth_v2_new_minion_without_master_pub(pki_dir, io_loop):
"publish_port": 4505,
"auth_mode": 1,
"acceptance_wait_time": 3,
"acceptance_wait_time_max": 3,
}
SMaster.secrets["aes"] = {
"secret": multiprocessing.Array(