Skip to content

Commit d843bd4

Browse files
committed
tests: integration: out_stdout: cover routes with a single input and output
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
1 parent c0962ef commit d843bd4

3 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
service:
2+
flush: 1
3+
grace: 1
4+
log_level: debug
5+
http_server: on
6+
http_port: ${FLUENT_BIT_HTTP_MONITORING_PORT}
7+
8+
pipeline:
9+
inputs:
10+
- name: dummy
11+
alias: single_pair_dummy
12+
tag: single.pair
13+
dummy: '{"message":"single pair record","topic":"topic1"}'
14+
samples: 1
15+
routes:
16+
logs:
17+
- name: single_pair_topic1
18+
condition:
19+
op: and
20+
rules:
21+
- field: $topic
22+
op: eq
23+
value: topic1
24+
to:
25+
outputs:
26+
- single_pair_stdout
27+
28+
outputs:
29+
- name: stdout
30+
alias: single_pair_stdout
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
service:
2+
flush: 1
3+
grace: 1
4+
log_level: debug
5+
http_server: on
6+
http_port: ${FLUENT_BIT_HTTP_MONITORING_PORT}
7+
8+
pipeline:
9+
inputs:
10+
- name: dummy
11+
alias: single_pair_dummy
12+
tag: single.pair
13+
dummy: '{"message":"single pair record","topic":"topic2"}'
14+
samples: 1
15+
routes:
16+
logs:
17+
- name: single_pair_topic1
18+
condition:
19+
op: and
20+
rules:
21+
- field: $topic
22+
op: eq
23+
value: topic1
24+
to:
25+
outputs:
26+
- single_pair_stdout
27+
28+
outputs:
29+
- name: stdout
30+
alias: single_pair_stdout

‎tests/integration/scenarios/out_stdout/tests/test_out_stdout_001.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import os
3+
import time
34
from pathlib import Path
45

56
import pytest
@@ -347,3 +348,28 @@ def test_out_stdout_conditional_routing_corner_cases(mode, label, config_file):
347348
)
348349
assert _stdout_lines_for_tag(log_text, f"{mode}_default_topic1") == []
349350
assert _stdout_lines_for_tag(log_text, f"{mode}_miss_topic1") == []
351+
352+
353+
def test_out_stdout_single_pair_conditional_route_matches():
354+
"""With one input and one output, a matching route still delivers."""
355+
service = Service("out_stdout_single_pair_conditional_match.yaml")
356+
service.start()
357+
log_text = service.wait_for_log_contains("[0] single_pair_topic1:", timeout=10)
358+
service.stop()
359+
360+
assert "connected input 'single_pair_dummy' route 'single_pair_topic1'" in log_text
361+
assert "\"message\"=>\"single pair record\"" in log_text
362+
363+
364+
def test_out_stdout_single_pair_conditional_route_drops_unmatched():
365+
"""With one input and one output, records matching no route are not delivered."""
366+
service = Service("out_stdout_single_pair_conditional_miss.yaml")
367+
service.start()
368+
service.wait_for_log_contains(
369+
"connected input 'single_pair_dummy' route 'single_pair_topic1'", timeout=10)
370+
# several flushes for the sample to reach the output if it were routed
371+
time.sleep(4)
372+
log_text = service.read_log()
373+
service.stop()
374+
375+
assert "single pair record" not in log_text

0 commit comments

Comments
 (0)