diff options
author | Stephen Sorriaux <stephen.sorriaux@gmail.com> | 2023-04-10 17:13:59 -0400 |
---|---|---|
committer | Stephen Sorriaux <stephen.sorriaux@gmail.com> | 2023-04-24 14:04:44 -0400 |
commit | 2c36d699fbf0569f490d5bfa66fa85fbdc68dea3 (patch) | |
tree | 931d2caa9ec9f59ea167f78530fc484fe103e74b /kazoo/testing/common.py | |
parent | d218dc970575f5d6042c14060d36e118a8c92e57 (diff) | |
download | kazoo-master.tar.gz |
Activate `pytest`'s `logcli` setting to better read the client lifecycle during testing.
Add `log()` function to KazooTestHarness class so that it is possible to log like crazy when something is not working
Display the ZK client port in logs when starting a ZK server (useful for test "debug")
Be able to get more than the last 100 lines of ZK logs (can be useful, believe me)
Diffstat (limited to 'kazoo/testing/common.py')
-rw-r--r-- | kazoo/testing/common.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kazoo/testing/common.py b/kazoo/testing/common.py index 7918221..a349199 100644 --- a/kazoo/testing/common.py +++ b/kazoo/testing/common.py @@ -221,8 +221,9 @@ log4j.appender.ROLLINGFILE.File=""" ) self.process = subprocess.Popen(args=args) log.info( - "Started zookeeper process %s using args %s", + "Started zookeeper process %s on port %s using args %s", self.process.pid, + self.server_info.client_port, args, ) self._running = True @@ -304,12 +305,12 @@ log4j.appender.ROLLINGFILE.File=""" shutil.rmtree(self.working_path, True) - def get_logs(self): + def get_logs(self, num_lines=100): log_path = pathlib.Path(self.working_path, "zookeeper.log") if log_path.exists(): log_file = log_path.open("r") lines = log_file.readlines() - return lines[-100:] + return lines[-num_lines:] return [] |