Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci][fluentd] add test.sh #794

Merged
merged 1 commit into from
Jul 29, 2021
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
11 changes: 11 additions & 0 deletions mackerel-plugin-fluentd/rule-workers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// TODO: add -extended_metrics
// default graphs
fluentd.buffer_total_queued_size.worker0.stdout_output >=0
fluentd.buffer_total_queued_size.worker1.stdout_output >=0
fluentd.buffer_total_queued_size.worker2.stdout_output >=0
fluentd.retry_count.worker0.stdout_output >=0
fluentd.retry_count.worker1.stdout_output >=0
fluentd.retry_count.worker2.stdout_output >=0
fluentd.buffer_queue_length.worker0.stdout_output >=0
fluentd.buffer_queue_length.worker1.stdout_output >=0
fluentd.buffer_queue_length.worker2.stdout_output >=0
38 changes: 38 additions & 0 deletions mackerel-plugin-fluentd/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

prog=$(basename "$0")
if ! [ -S /var/run/docker.sock ]
then
echo "$prog: there are no running docker" >&2
exit 2
fi

cd "$(dirname "$0")" || exit
PATH=$(pwd):$PATH
plugin=$(basename "$(pwd)")
if ! which "$plugin" >/dev/null
then
echo "$prog: $plugin is not installed" >&2
exit 2
fi

image=fluent/fluentd:v1.13-1
port0=24230
port1=24231
port2=24232
rule="rule-workers.txt"

docker run -d \
--name "test-$plugin" \
-p "$port0:$port0" \
-p "$port1:$port1" \
-p "$port2:$port2" \
-v "$(pwd)/testdata:/fluentd/etc:ro" "$image" -c /fluentd/etc/fluentd-workers.conf
trap 'docker stop test-$plugin; docker rm test-$plugin; exit' 1 2 3 15
sleep 10

$plugin -port "$port0" -workers 3 | graphite-metric-test -f "$rule"
status=$?
docker stop "test-$plugin"
docker rm "test-$plugin"
exit $status
20 changes: 20 additions & 0 deletions mackerel-plugin-fluentd/testdata/fluentd-workers.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<system>
workers 3
</system>

<source>
@type forward
@id forward_input
tag test.data
</source>

<match test.**>
@type stdout
@id stdout_output
</match>

<source>
@type monitor_agent
bind 0.0.0.0
port 24230
</source>