Browse Source

Merge pull request #1847 from infosiftr/logstash-basics

Add simple new "logstash-basics" test; fix "logstash:5" by adding appropriate "LS_SETTINGS_DIR"
Tianon Gravi 9 năm trước cách đây
mục cha
commit
f19697b25a
3 tập tin đã thay đổi với 86 bổ sung6 xóa
  1. 6 6
      library/logstash
  2. 3 0
      test/config.sh
  3. 77 0
      test/tests/logstash-basics/run.sh

+ 6 - 6
library/logstash

@@ -5,25 +5,25 @@ Maintainers: Tianon Gravi <[email protected]> (@tianon),
 GitRepo: https://github.com/docker-library/logstash.git
 
 Tags: 1.5.6-1, 1.5.6, 1.5, 1
-GitCommit: fde2012d6c14d14fa52c359eaca8b2429e9ec98a
+GitCommit: bb4f8b0d3f3e92a04dfbfee1d2b94196f64bd78c
 Directory: 1.5
 
 Tags: 2.0.0-1, 2.0.0, 2.0
-GitCommit: fde2012d6c14d14fa52c359eaca8b2429e9ec98a
+GitCommit: bb4f8b0d3f3e92a04dfbfee1d2b94196f64bd78c
 Directory: 2.0
 
 Tags: 2.1.3-1, 2.1.3, 2.1
-GitCommit: fde2012d6c14d14fa52c359eaca8b2429e9ec98a
+GitCommit: bb4f8b0d3f3e92a04dfbfee1d2b94196f64bd78c
 Directory: 2.1
 
 Tags: 2.2.4-1, 2.2.4, 2.2
-GitCommit: fde2012d6c14d14fa52c359eaca8b2429e9ec98a
+GitCommit: bb4f8b0d3f3e92a04dfbfee1d2b94196f64bd78c
 Directory: 2.2
 
 Tags: 2.3.3-1, 2.3.3, 2.3, 2, latest
-GitCommit: e9bb2f47349073290ca82a4355eea156839b0ea5
+GitCommit: bb4f8b0d3f3e92a04dfbfee1d2b94196f64bd78c
 Directory: 2.3
 
 Tags: 5.0.0-alpha3-1, 5.0.0-alpha3, 5.0.0, 5.0, 5
-GitCommit: 110f40d8444f4b5b5eaa012e8bfa9a25a41cfa12
+GitCommit: bb4f8b0d3f3e92a04dfbfee1d2b94196f64bd78c
 Directory: 5.0

+ 3 - 0
test/config.sh

@@ -86,6 +86,9 @@ imageTests+=(
 	[julia]='
 		julia-hello-world
 	'
+	[logstash]='
+		logstash-basics
+	'
 	[memcached]='
 	'
 	[mongo]='

+ 77 - 0
test/tests/logstash-basics/run.sh

@@ -0,0 +1,77 @@
+#!/bin/bash
+
+[ "$DEBUG" ] && set -x
+
+set -eo pipefail
+
+dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+image="$1"
+
+# Use the image being tested as our client image since it should already have curl
+clientImage="$image"
+
+# input via HTTP (default port 0.0.0.0:8080)
+# output via stdout, newline-delimited nothing-but-the-message
+config='
+	input {
+		http {
+		}
+	}
+	output {
+		stdout {
+			codec => line {
+				format => "%{message}"
+			}
+		}
+	}
+'
+
+# Create an instance of the container-under-test
+cid="$(docker run -d "$image" -e "$config")"
+trap "docker rm -vf $cid > /dev/null" EXIT
+
+_request() {
+	# https://github.com/docker/docker/issues/14203#issuecomment-129865960 (DOCKER_FIX)
+	docker run --rm --link "$cid":logstash \
+		-e DOCKER_FIX='                                        ' \
+		"$clientImage" curl -fs "$@" "http://logstash:8080"
+}
+
+_trimmed() {
+	_request "$@" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g'
+}
+
+_req-comp() {
+	local expected="$1"; shift
+	response="$(_trimmed "$@")"
+	[ "$response" = "$expected" ]
+}
+
+_req-exit() {
+	local expectedRet="$1"; shift
+	[ "$(_request "$@" --output /dev/null || echo "$?")" = "$expectedRet" ]
+}
+
+_req-msg() {
+	local msg="$1"; shift
+	_req-comp 'ok' --data "$msg"
+	# use "retry.sh" to give logstash just a tiny bit of time to actually print the message to stdout
+	. "$dir/../../retry.sh" --tries 3 --sleep 0.5 '
+		logLine="$(docker logs --tail=1 "$cid")";
+		[ "$logLine" = "$msg" ];
+	'
+}
+
+# Make sure our container is listening
+. "$dir/../../retry.sh" '! _req-exit 7' # "Failed to connect to host."
+
+for msg in \
+	'hi' \
+	"hello $RANDOM world" \
+	"hello $RANDOM world" \
+	"hello $RANDOM world" \
+	'bye' \
+; do
+	_req-msg "$msg"
+done