From a185259fc3ba19836333ac5d3d0a356122bb9e8a Mon Sep 17 00:00:00 2001 From: Gael Pasgrimaud Date: Mon, 18 Nov 2019 15:52:31 +0100 Subject: [PATCH 1/5] broken test --- Makefile | 4 +++- tests_fluentbit/Makefile | 6 ++++++ tests_fluentbit/docker-compose.yml | 18 ++++++++++++++++++ tests_fluentbit/tests.py | 12 ++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests_fluentbit/Makefile create mode 100644 tests_fluentbit/docker-compose.yml create mode 100644 tests_fluentbit/tests.py diff --git a/Makefile b/Makefile index 4b58b22..7ea24fe 100644 --- a/Makefile +++ b/Makefile @@ -45,4 +45,6 @@ build: deb/td-agent-bit_${FLUENTBIT_VERSION}_amd64.deb down: tests: - @echo "no functionnal tests" + docker-compose -f tests_fluentbit/docker-compose.yml up -d fluentd + docker-compose -f tests_fluentbit/docker-compose.yml run test + docker-compose -f tests_fluentbit/docker-compose.yml logs fluentd diff --git a/tests_fluentbit/Makefile b/tests_fluentbit/Makefile new file mode 100644 index 0000000..94fe2c6 --- /dev/null +++ b/tests_fluentbit/Makefile @@ -0,0 +1,6 @@ +/tmp/venv: + python3 -m venv /tmp/venv + /tmp/venv/bin/pip install fluent-logger + +tests: /tmp/venv + /tmp/venv/bin/python tests.py diff --git a/tests_fluentbit/docker-compose.yml b/tests_fluentbit/docker-compose.yml new file mode 100644 index 0000000..71316d2 --- /dev/null +++ b/tests_fluentbit/docker-compose.yml @@ -0,0 +1,18 @@ +--- + +version: "3" + +services: + fluentd: + image: bearstech/fluentbit:latest + volumes: + - ../:/tests_fluentbit + + test: + image: bearstech/python-dev:3 + working_dir: /tests_fluentbit + volumes: + - ../:/tests_fluentbit + command: make -C tests_fluentbit tests + depends_on: + - fluentd diff --git a/tests_fluentbit/tests.py b/tests_fluentbit/tests.py new file mode 100644 index 0000000..ff07457 --- /dev/null +++ b/tests_fluentbit/tests.py @@ -0,0 +1,12 @@ +from fluent import sender + + +logger = sender.FluentSender('app', host='fluentd', port=24224) +print('Sender:', logger) + +res = logger.emit('follow', {'from': 'userA', 'to': 'userB'}) +print('Result:', res) +if not res: + raise RuntimeError(logger.last_error) + +logger.close() From ce0e640746d769e23758952e4ffac451e7597eec Mon Sep 17 00:00:00 2001 From: Mathieu Lecarme Date: Mon, 18 Nov 2019 17:14:11 +0100 Subject: [PATCH 2/5] Fluentbit logs stuff to STDOUT. --- td-agent-bit.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/td-agent-bit.conf b/td-agent-bit.conf index 36aacf2..f09ff76 100644 --- a/td-agent-bit.conf +++ b/td-agent-bit.conf @@ -22,6 +22,8 @@ # By default 'info' is set, that means it includes 'error' and 'warning'. Log_Level info + Log_File /proc/1/fd/1 + # Parsers_File # ============ # Specify an optional 'Parsers' configuration file From 2feef0dc41f94b35dea15bc340562c1dc88ed71f Mon Sep 17 00:00:00 2001 From: Gael Pasgrimaud Date: Mon, 18 Nov 2019 17:28:01 +0100 Subject: [PATCH 3/5] use Forward everywhere --- tests_fluentbit/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests_fluentbit/tests.py b/tests_fluentbit/tests.py index ff07457..27d07ca 100644 --- a/tests_fluentbit/tests.py +++ b/tests_fluentbit/tests.py @@ -1,10 +1,10 @@ from fluent import sender -logger = sender.FluentSender('app', host='fluentd', port=24224) +logger = sender.FluentSender('Forward', host='fluentd', port=24224) print('Sender:', logger) -res = logger.emit('follow', {'from': 'userA', 'to': 'userB'}) +res = logger.emit('Forward', {'from': 'userA', 'to': 'userB'}) print('Result:', res) if not res: raise RuntimeError(logger.last_error) From e610351396418ac6edbc472ff8c5b43da5769fe4 Mon Sep 17 00:00:00 2001 From: Gael Pasgrimaud Date: Mon, 18 Nov 2019 18:20:14 +0100 Subject: [PATCH 4/5] do not need test in context --- .dockerignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..49dfe59 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +tests_* From 8587d28f3f6969241b5325ddea31438a50c0d914 Mon Sep 17 00:00:00 2001 From: Wilfried OLLIVIER Date: Tue, 3 Aug 2021 17:12:12 +0200 Subject: [PATCH 5/5] Fix: tests --- td-agent-bit.conf | 8 +++++--- tests_fluentbit/tests.py | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/td-agent-bit.conf b/td-agent-bit.conf index f09ff76..aa00f55 100644 --- a/td-agent-bit.conf +++ b/td-agent-bit.conf @@ -20,7 +20,7 @@ # - trace # # By default 'info' is set, that means it includes 'error' and 'warning'. - Log_Level info + Log_Level trace Log_File /proc/1/fd/1 @@ -32,7 +32,9 @@ [INPUT] Name Forward Port 24224 + Bind 0.0.0.0 [OUTPUT] - Name stdout - Match * + Name file + Path /proc/1/fd/1 + Match app.* diff --git a/tests_fluentbit/tests.py b/tests_fluentbit/tests.py index 27d07ca..e842311 100644 --- a/tests_fluentbit/tests.py +++ b/tests_fluentbit/tests.py @@ -1,11 +1,11 @@ from fluent import sender -logger = sender.FluentSender('Forward', host='fluentd', port=24224) -print('Sender:', logger) +logger = sender.FluentSender("app", host="fluentd", port=24224) +print("Sender:", logger) -res = logger.emit('Forward', {'from': 'userA', 'to': 'userB'}) -print('Result:', res) +res = logger.emit("test", {"from": "userA", "to": "userB"}) +print("Result:", res) if not res: raise RuntimeError(logger.last_error)