File tree Expand file tree Collapse file tree 3 files changed +19
-9
lines changed Expand file tree Collapse file tree 3 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 6
6
# The configuration file is validated using the logstash --config.test_and_exit command in a docker container.
7
7
#
8
8
9
- set -eux
9
+ set -eu
10
10
11
11
LOGSTASH_VERSION=8.14.1
12
12
13
- docker run --rm -it \
13
+ docker run \
14
+ --rm \
14
15
--volume " $( pwd) " /postfix.grok:/etc/logstash/patterns.d/postfix.grok \
15
16
--volume " $( pwd) " /50-filter-postfix.conf:/usr/share/logstash/pipeline/50-filter-postfix.conf \
16
17
logstash:" $LOGSTASH_VERSION " \
Original file line number Diff line number Diff line change 6
6
# The patterns are tested by running the test suite (in test/test.rb and test/*.yaml)
7
7
# against the patterns in the postfix.grok file in a docker container.
8
8
#
9
- set -eux
9
+ set -eu
10
10
11
11
DOCKERIMAGE=" postfix-grok-patterns-runtests"
12
12
VOLUMEPATH=" /runtests"
@@ -18,4 +18,9 @@ FROM ruby:slim
18
18
RUN gem install jls-grok minitest
19
19
EOF
20
20
21
- docker run --volume " $( pwd) " :" ${VOLUMEPATH} " --workdir ${VOLUMEPATH} ${DOCKERIMAGE} sh -c " ruby test/test.rb"
21
+ docker run \
22
+ --rm \
23
+ --volume " $( pwd) " :" ${VOLUMEPATH} " \
24
+ --workdir ${VOLUMEPATH} \
25
+ ${DOCKERIMAGE} \
26
+ sh -c " ruby test/test.rb"
Original file line number Diff line number Diff line change 7
7
# sends a test logline through the pipeline and checks the results.
8
8
#
9
9
10
- set -eux
10
+ set -eu
11
11
12
12
LOGSTASH_VERSION=8.14.1
13
13
14
14
INPUT=$( mktemp tmp.logstash.in.XXXXX)
15
15
OUTPUT=$( mktemp tmp.logstash.out.XXXXX)
16
16
PIPELINE=$( mktemp tmp.logstash.pipeline.XXXXX)
17
17
18
+ perform_cleanup () {
19
+ echo Cleaning up
20
+ test -n " CONTAINER_ID" && docker stop --time 1 " $CONTAINER_ID " > /dev/null
21
+ rm -f " $INPUT " " $OUTPUT " " $PIPELINE "
22
+ }
23
+ trap perform_cleanup INT TERM
24
+
18
25
echo Preparing input data
19
26
echo " postfix/smtp[123]: 7EE668039: to=<[email protected] >, relay=127.0.0.1[127.0.0.1]:2525, delay=3.6, delays=0.2/0.02/0.04/3.3, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 153053D)" > " $INPUT "
20
27
@@ -61,8 +68,6 @@ until test -s "$OUTPUT"; do
61
68
done
62
69
echo
63
70
64
- docker stop --time 1 " $CONTAINER_ID " > /dev/null
65
-
66
71
if test " $( jq .tags[0] " $OUTPUT " ) " = ' "_grok_postfix_success"' ; then
67
72
echo Grok processing successful!
68
73
jq . " $OUTPUT "
72
77
exit 1
73
78
fi
74
79
75
- echo Cleaning up
76
- rm -f " $INPUT " " $OUTPUT " " $PIPELINE "
80
+ perform_cleanup
77
81
78
82
echo Done
You can’t perform that action at this time.
0 commit comments