Skip to content

Commit

Permalink
Merge pull request #302 from mitzkia/light-various-fixes
Browse files Browse the repository at this point in the history
light: Add 3 minor fixes for a: deprecation warning, flaky testcase and crash detection
  • Loading branch information
MrAnno authored Sep 23, 2024
2 parents 1ee8c4c + 15f4f9e commit a750a3b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/light/functional_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def setup(request):
global base_number_of_open_fds
number_of_open_fds = len(psutil.Process().open_files())
assert base_number_of_open_fds + 1 == number_of_open_fds, "Previous testcase has unclosed opened fds"
assert len(psutil.Process().connections(kind="inet")) == 0, "Previous testcase has unclosed opened sockets"
assert len(psutil.Process().net_connections(kind="inet")) == 0, "Previous testcase has unclosed opened sockets"
testcase_parameters = request.getfixturevalue("testcase_parameters")

copy_file(testcase_parameters.get_testcase_file(), Path.cwd())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# COPYING for details.
#
#############################################################################
from src.common.blocking import wait_until_true
from src.syslog_ng_config.renderer import render_statement
from src.syslog_ng_ctl.prometheus_stats_handler import MetricFilter

Expand Down Expand Up @@ -184,6 +185,7 @@ def test_filterx_update_metric_level(config, port_allocator, syslog_ng):
network_source.write_log("foo\n")
file_destination.read_log()

assert wait_until_true(lambda: config.get_prometheus_samples([MetricFilter("syslogng_metric", {})]) != [])
samples = config.get_prometheus_samples([MetricFilter("syslogng_metric", {})])
assert len(samples) == 1
assert int(samples[0].value) == 1
Expand Down
5 changes: 4 additions & 1 deletion tests/light/src/syslog_ng/syslog_ng_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def is_process_running(self):
def __wait_for_control_socket_alive(self):
def is_alive(s):
if not s.is_process_running():
self.__process = None
self.__error_handling("syslog-ng is not running")
return s.__syslog_ng_ctl.is_control_socket_alive()
return wait_until_true(is_alive, self)
Expand Down Expand Up @@ -167,6 +166,10 @@ def __handle_core_file(self):
core_file.replace(Path(core_file))
if core_file_found:
raise Exception("syslog-ng core file was found and processed")
if self.__process.returncode in [-6, -9, -11]:
ret_code = self.__process.returncode
self.__process = None
raise Exception("syslog-ng process crashed with signal {}".format(ret_code))

def set_start_parameters(self, stderr, debug, trace, verbose, startup_debug, no_caps, config_path, persist_path, pid_path, control_socket_path):
self.__stderr = stderr
Expand Down

0 comments on commit a750a3b

Please sign in to comment.