From 8190791910315ec4e6a77de136342cebafddc6cf Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Tue, 25 Jul 2023 01:44:40 -0700 Subject: [PATCH] Clean up debugging cruft in test suite --- salt/minion.py | 3 +-- salt/transport/base.py | 2 +- salt/transport/ipc.py | 1 - salt/transport/zeromq.py | 2 -- salt/utils/event.py | 3 +-- tests/pytests/functional/channel/test_server.py | 6 +----- .../functional/transport/ipc/test_pub_server_channel.py | 5 ----- .../transport/zeromq/test_pub_server_channel.py | 5 ----- tests/pytests/unit/transport/test_publish_client.py | 2 -- tests/pytests/unit/transport/test_tcp.py | 7 +------ tests/support/pytest/transport.py | 8 +------- 11 files changed, 6 insertions(+), 38 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index 0a717808886..a1040cdaec0 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -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): diff --git a/salt/transport/base.py b/salt/transport/base.py index f03f8fdf5ed..7fdd733f938 100644 --- a/salt/transport/base.py +++ b/salt/transport/base.py @@ -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": diff --git a/salt/transport/ipc.py b/salt/transport/ipc.py index 8493b6548b0..92beba73422 100644 --- a/salt/transport/ipc.py +++ b/salt/transport/ipc.py @@ -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 diff --git a/salt/transport/zeromq.py b/salt/transport/zeromq.py index 70443717f72..166b3baaeaa 100644 --- a/salt/transport/zeromq.py +++ b/salt/transport/zeromq.py @@ -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) diff --git a/salt/utils/event.py b/salt/utils/event.py index c3c474158f7..e555c037b06 100644 --- a/salt/utils/event.py +++ b/salt/utils/event.py @@ -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 diff --git a/tests/pytests/functional/channel/test_server.py b/tests/pytests/functional/channel/test_server.py index 58bf654704a..559ab645327 100644 --- a/tests/pytests/functional/channel/test_server.py +++ b/tests/pytests/functional/channel/test_server.py @@ -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": diff --git a/tests/pytests/functional/transport/ipc/test_pub_server_channel.py b/tests/pytests/functional/transport/ipc/test_pub_server_channel.py index c66ee8ebbac..da669621bd1 100644 --- a/tests/pytests/functional/transport/ipc/test_pub_server_channel.py +++ b/tests/pytests/functional/transport/ipc/test_pub_server_channel.py @@ -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) diff --git a/tests/pytests/functional/transport/zeromq/test_pub_server_channel.py b/tests/pytests/functional/transport/zeromq/test_pub_server_channel.py index b41d9e60ca1..3e46ab1b6a1 100644 --- a/tests/pytests/functional/transport/zeromq/test_pub_server_channel.py +++ b/tests/pytests/functional/transport/zeromq/test_pub_server_channel.py @@ -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) diff --git a/tests/pytests/unit/transport/test_publish_client.py b/tests/pytests/unit/transport/test_publish_client.py index b8666f3052c..18147f1831f 100644 --- a/tests/pytests/unit/transport/test_publish_client.py +++ b/tests/pytests/unit/transport/test_publish_client.py @@ -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) diff --git a/tests/pytests/unit/transport/test_tcp.py b/tests/pytests/unit/transport/test_tcp.py index f61bcca15f2..8173a32841a 100644 --- a/tests/pytests/unit/transport/test_tcp.py +++ b/tests/pytests/unit/transport/test_tcp.py @@ -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", diff --git a/tests/support/pytest/transport.py b/tests/support/pytest/transport.py index 335dba37e6d..26397d3952a 100644 --- a/tests/support/pytest/transport.py +++ b/tests/support/pytest/transport.py @@ -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: