Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/flb_router.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,12 @@ int flb_router_io_set(struct flb_config *config)
in_count = mk_list_size(&config->inputs);
out_count = mk_list_size(&config->outputs);

/* Mostly used for command line tests */
if (in_count == 1 && out_count == 1) {
/*
* Mostly used for command line tests. Inputs with routes are connected by
* the router configuration below.
*/
if (in_count == 1 && out_count == 1 &&
cfl_list_is_empty(&config->input_routes)) {
i_ins = mk_list_entry_first(&config->inputs, struct flb_input_instance, _head);
o_ins = mk_list_entry_first(&config->outputs, struct flb_output_instance, _head);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
service:
flush: 1
grace: 1
log_level: debug
http_server: on
http_port: ${FLUENT_BIT_HTTP_MONITORING_PORT}

pipeline:
inputs:
- name: dummy
alias: single_pair_dummy
tag: single.pair
dummy: '{"message":"single pair record","topic":"topic1"}'
samples: 1
routes:
logs:
- name: single_pair_topic1
condition:
op: and
rules:
- field: $topic
op: eq
value: topic1
to:
outputs:
- single_pair_stdout

outputs:
- name: stdout
alias: single_pair_stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
service:
flush: 1
grace: 1
log_level: debug
http_server: on
http_port: ${FLUENT_BIT_HTTP_MONITORING_PORT}

pipeline:
inputs:
- name: dummy
alias: single_pair_dummy
tag: single.pair
dummy: '{"message":"single pair record","topic":"topic2"}'
samples: 1
routes:
logs:
- name: single_pair_topic1
condition:
op: and
rules:
- field: $topic
op: eq
value: topic1
to:
outputs:
- single_pair_stdout

outputs:
- name: stdout
alias: single_pair_stdout
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import time
from pathlib import Path

import pytest
Expand Down Expand Up @@ -347,3 +348,28 @@ def test_out_stdout_conditional_routing_corner_cases(mode, label, config_file):
)
assert _stdout_lines_for_tag(log_text, f"{mode}_default_topic1") == []
assert _stdout_lines_for_tag(log_text, f"{mode}_miss_topic1") == []


def test_out_stdout_single_pair_conditional_route_matches():
"""With one input and one output, a matching route still delivers."""
service = Service("out_stdout_single_pair_conditional_match.yaml")
service.start()
log_text = service.wait_for_log_contains("[0] single_pair_topic1:", timeout=10)
service.stop()

assert "connected input 'single_pair_dummy' route 'single_pair_topic1'" in log_text
assert "\"message\"=>\"single pair record\"" in log_text


def test_out_stdout_single_pair_conditional_route_drops_unmatched():
"""With one input and one output, records matching no route are not delivered."""
service = Service("out_stdout_single_pair_conditional_miss.yaml")
service.start()
service.wait_for_log_contains(
"connected input 'single_pair_dummy' route 'single_pair_topic1'", timeout=10)
# several flushes for the sample to reach the output if it were routed
time.sleep(4)
log_text = service.read_log()
service.stop()

assert "single pair record" not in log_text
Loading