-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filter: add E2E test for implicit and with NOT
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
tests/light/functional_tests/filters/test_multiple_filters.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env python | ||
############################################################################# | ||
# Copyright (c) 2024 Attila Szakacs | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 2 as published | ||
# by the Free Software Foundation, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# As an additional exemption you are allowed to compile & link against the | ||
# OpenSSL libraries as published by the OpenSSL project. See the file | ||
# COPYING for details. | ||
# | ||
############################################################################# | ||
|
||
from src.syslog_ng_config.renderer import render_statement | ||
|
||
|
||
def test_multiple_filters_implicit_and(config, syslog_ng): | ||
file_true = config.create_file_destination(file_name="dest-true.log", template="\"$MSG\\n\"") | ||
file_false = config.create_file_destination(file_name="dest-false.log", template="\"$MSG\\n\"") | ||
|
||
preamble = f""" | ||
@version: {config.get_version()} | ||
options {{ stats(level(1)); }}; | ||
source genmsg {{ | ||
example-msg-generator(num(1) template("MESSAGE")); | ||
example-msg-generator(num(1) template("foobar")); | ||
}}; | ||
filter f_filter {{ | ||
not program("xyz"); | ||
message("MESSAGE"); | ||
}}; | ||
destination dest_true {{ | ||
{render_statement(file_true)}; | ||
}}; | ||
destination dest_false {{ | ||
{render_statement(file_false)}; | ||
}}; | ||
log {{ | ||
source(genmsg); | ||
if {{ | ||
filter(f_filter); | ||
destination(dest_true); | ||
}} else {{ | ||
destination(dest_false); | ||
}}; | ||
}}; | ||
""" | ||
config.set_raw_config(preamble) | ||
syslog_ng.start(config) | ||
|
||
assert file_true.get_stats()["processed"] == 1 | ||
assert file_false.get_stats()["processed"] == 1 | ||
|
||
assert "MESSAGE" in file_true.read_log() | ||
assert "foobar" in file_false.read_log() |