Clean up debugging cruft in test suite

This commit is contained in:
Daniel A. Wozniak 2023-07-25 01:44:40 -07:00 committed by Gareth J. Greenaway
parent 3c788180ff
commit 8190791910
11 changed files with 6 additions and 38 deletions

View file

@ -1145,7 +1145,7 @@ class MinionManager(MinionBase):
last = time.time()
if auth_wait < self.max_auth_wait:
auth_wait += self.auth_wait
await tornado.gen.sleep(auth_wait) # TODO: log?
await asyncio.sleep(auth_wait)
except SaltMasterUnresolvableError:
err = (
"Master address: '{}' could not be resolved. Invalid or"
@ -3246,7 +3246,6 @@ class Minion(MinionBase):
if hasattr(self, "periodic_callbacks"):
for cb in self.periodic_callbacks.values():
cb.stop()
log.error("%r destroy method finished", self)
# pylint: disable=W1701
def __del__(self):

View file

@ -129,7 +129,7 @@ def _minion_hash(hash_type, minion_id):
def ipc_publish_client(node, opts, io_loop):
# Default to ZeroMQ for now
# Default to TCP for now
kwargs = {"transport": "tcp"}
if opts["ipc_mode"] == "tcp":
if node == "master":

View file

@ -438,7 +438,6 @@ class IPCMessageClient(IPCClient):
# FIXME timeout unimplemented
# FIXME tries unimplemented
# @tornado.gen.coroutine
async def send(self, msg, timeout=None, tries=None):
"""
Send a message to an IPC socket

View file

@ -239,7 +239,6 @@ class PublishClient(salt.transport.base.PublishClient):
self.callbacks = {}
for callback, (running, task) in callbacks.items():
running.clear()
# task.cancel()
return
# pylint: enable=W1701
@ -887,7 +886,6 @@ class PublishServer(salt.transport.base.DaemonizedPublishServer):
salt.utils.zeromq.check_ipc_path_max_len(self.pull_uri)
# Start the minion command publisher
# Securely create socket
log.error("PULL URI %r PUB URI %r", self.pull_uri, self.pub_uri)
with salt.utils.files.set_umask(0o177):
log.info("Starting the Salt Publisher on %s", self.pub_uri)
pub_sock.bind(self.pub_uri)

View file

@ -231,7 +231,7 @@ class SaltEvent:
self.io_loop = io_loop
self._run_io_loop_sync = False
else:
# self.io_loop = tornado.ioloop.IOLoop()
self.io_loop = None
self._run_io_loop_sync = True
self.cpub = False
self.cpush = False
@ -532,7 +532,6 @@ class SaltEvent:
try:
if not self.cpub and not self.connect_pub(timeout=wait):
break
# riraw = self.subscriber.read(timeout=wait)
raw = self.subscriber.recv(timeout=wait)
if raw is None:
break

View file

@ -127,17 +127,13 @@ def master_secrets():
def _connect_and_publish(
io_loop, channel_minion_id, channel, server, received, timeout=60
):
log.info("TEST - BEFORE CHANNEL CONNECT")
yield channel.connect()
log.info("TEST - AFTER CHANNEL CONNECT")
def cb(payload):
log.info("TEST - PUB SERVER MSG %r", payload)
received.append(payload)
io_loop.stop()
channel.on_recv(cb)
log.info("TEST - RUN PUBLISH")
io_loop.spawn_callback(
server.publish, {"tgt_type": "glob", "tgt": [channel_minion_id], "WTF": "SON"}
)
@ -163,7 +159,7 @@ def test_pub_server_channel(
req_server_channel.pre_fork(process_manager)
def handle_payload(payload):
log.info("TEST - Req Server handle payload %r", payload)
log.debug("Payload handler got %r", payload)
req_server_channel.post_fork(handle_payload, io_loop=io_loop)
if master_config["transport"] == "zeromq":

View file

@ -1,7 +1,6 @@
import asyncio
import logging
import time
import tracemalloc
from concurrent.futures.thread import ThreadPoolExecutor
import pytest
@ -11,8 +10,6 @@ import salt.channel.server
import salt.master
from tests.support.pytest.transport import PubServerChannelProcess
tracemalloc.start()
log = logging.getLogger(__name__)
@ -76,12 +73,10 @@ def test_publish_to_pubserv_ipc(salt_master, salt_minion, transport):
with PubServerChannelProcess(opts, minion_opts) as server_channel:
send_num = 10000
expect = []
log.error("Sending %d messages", send_num)
for idx in range(send_num):
expect.append(idx)
load = {"tgt_type": "glob", "tgt": "*", "jid": idx}
server_channel.publish(load)
log.error("Finished sending messages")
results = server_channel.collector.results
assert len(results) == send_num, "{} != {}, difference: {}".format(
len(results), send_num, set(expect).difference(results)

View file

@ -22,7 +22,6 @@ def test_zeromq_filtering(salt_master, salt_minion):
"""
Test sending messages to publisher using UDP with zeromq_filtering enabled
"""
log.error("TEST START")
opts = dict(
salt_master.config.copy(),
ipc_mode="ipc",
@ -32,7 +31,6 @@ def test_zeromq_filtering(salt_master, salt_minion):
)
send_num = 1
expect = []
log.error("TEST START 2 ")
with patch(
"salt.utils.minions.CkMinions.check_minions",
MagicMock(
@ -43,12 +41,9 @@ def test_zeromq_filtering(salt_master, salt_minion):
}
),
):
# log.error("Get Server Channel")
log.error("TEST START 3")
with PubServerChannelProcess(
opts, salt_minion.config.copy(), zmq_filtering=True
) as server_channel:
log.error("pub chan started")
expect.append(send_num)
load = {"tgt_type": "glob", "tgt": "*", "jid": send_num}
server_channel.publish(load)

View file

@ -161,7 +161,6 @@ async def test_publish_client_connect_server_down(transport, io_loop):
opts = {"master_ip": "127.0.0.1"}
host = "127.0.0.1"
port = 111222
print(transport)
if transport == "zeromq":
client = salt.transport.zeromq.PublishClient(
opts, io_loop, host=host, port=port
@ -171,7 +170,6 @@ async def test_publish_client_connect_server_down(transport, io_loop):
elif transport == "tcp":
client = salt.transport.tcp.TCPPubClient(opts, io_loop, host=host, port=port)
try:
# XXX: This is an implimentation detail of the tcp transport.
# XXX: This is an implimentation detail of the tcp transport.
# await client.connect(port)
io_loop.spawn_callback(client.connect)

View file

@ -1,3 +1,4 @@
import asyncio
import os
import socket
@ -123,18 +124,12 @@ async def test_message_client_cleanup_on_close(
del orig_loop.stop_called
# orig_loop.clear_current()
# orig_loop.close(all_fds=True)
async def test_async_tcp_pub_channel_connect_publish_port(
temp_salt_master, client_socket
):
"""
test when publish_port is not 4506
"""
import asyncio
opts = dict(
temp_salt_master.config.copy(),
master_uri="tcp://127.0.0.1:1234",

View file

@ -1,6 +1,7 @@
import ctypes
import logging
import multiprocessing
import queue
import socket
import time
@ -192,17 +193,11 @@ class Collector(salt.utils.process.SignalHandlingProcess):
loop.start()
def __enter__(self):
import sys
print("COL ENTER")
sys.stdout.flush()
self.manager.__enter__()
self.start()
# Wait until we can start receiving events
self.started.wait()
self.started.clear()
print("COL ENTER - Done")
sys.stdout.flush()
return self
def __exit__(self, *args):
@ -256,7 +251,6 @@ class PubServerChannelProcess(salt.utils.process.SignalHandlingProcess):
)
def run(self):
import queue
ioloop = tornado.ioloop.IOLoop()
try: