Skip to content

Commit

Permalink
light: fix bytes/protobuf testcases
Browse files Browse the repository at this point in the history
With the $MSG as a macro gone, $MSG became a typed value, so it does matter
what we set it to. Since setting it to a bytes/protobuf value means
that its not a string anymore, we can't render it as a part of a template
unless we explicitly ask for the right type hint.

This is what this patch changes in the broken testcases.

Signed-off-by: Balazs Scheidler <[email protected]>
  • Loading branch information
bazsi committed Dec 31, 2024
1 parent ea72bbb commit 1871070
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/light/functional_tests/filterx/test_filterx.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
from src.syslog_ng_config.renderer import render_statement


def create_config(config, filterx_expr_1, filterx_expr_2=None, msg="foobar"):
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'")
def create_config(config, filterx_expr_1, filterx_expr_2=None, msg="foobar", template="'$MSG\n'"):
file_true = config.create_file_destination(file_name="dest-true.log", template=template)
file_false = config.create_file_destination(file_name="dest-false.log", template=template)

preamble = f"""
@version: {config.get_version()}
Expand Down Expand Up @@ -118,6 +118,7 @@ def test_otel_logrecord_bytes_setter_getter(config, syslog_ng):
$olr = otel_logrecord();
$olr.trace_id = ${values.bytes};
$MSG = $olr.trace_id; """,
template="""bytes('$MSG\n')""",
)
syslog_ng.start(config)

Expand Down Expand Up @@ -218,6 +219,7 @@ def test_otel_logrecord_body_bytes_setter_getter(config, syslog_ng):
$olr = otel_logrecord();
$olr.body = ${values.bytes};
$MSG = $olr.body; """,
template="""bytes('$MSG\n')""",
)
syslog_ng.start(config)

Expand All @@ -227,11 +229,13 @@ def test_otel_logrecord_body_bytes_setter_getter(config, syslog_ng):


def test_otel_logrecord_body_protobuf_setter_getter(config, syslog_ng):
# NOTE: protobuf is converted to bytes
(file_true, file_false) = create_config(
config, """
$olr = otel_logrecord();
$olr.body = ${values.protobuf};
$MSG = $olr.body; """,
template="""bytes('$MSG\n')""",
)
syslog_ng.start(config)

Expand Down

0 comments on commit 1871070

Please sign in to comment.