Browse Source

Merge pull request #3895 from TimWolla/haproxy-test

Update haproxy test to use curl's --resolve option
yosifkit 7 years ago
parent
commit
052e491f37
2 changed files with 15 additions and 10 deletions
  1. 7 6
      test/tests/haproxy-basics/haproxy.cfg
  2. 8 4
      test/tests/haproxy-basics/run.sh

+ 7 - 6
test/tests/haproxy-basics/haproxy.cfg

@@ -1,12 +1,13 @@
 defaults
-	mode http
+	mode tcp
 	timeout connect 5000ms
 	timeout client 50000ms
 	timeout server 50000ms
 frontend http-in
 	bind *:80
-	default_backend google
-backend google
-	server google0 www.google.com
-	# this doesn't work on HAProxy 1.4 :(
-	#http-request replace-header Host .* www.google.com
+	default_backend example
+frontend https-in
+	bind *:443
+	default_backend example
+backend example
+	server example0 example.com

+ 8 - 4
test/tests/haproxy-basics/run.sh

@@ -8,7 +8,7 @@ dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
 
 image="$1"
 
-clientImage='buildpack-deps:jessie-curl'
+clientImage='buildpack-deps:stretch-curl'
 
 # Create an instance of the container-under-test
 serverImage="$("$dir/../image-name.sh" librarytest/haproxy-basics "$image")"
@@ -23,6 +23,9 @@ _request() {
 	local method="$1"
 	shift
 
+	local proto="$1"
+	shift
+
 	local url="${1#/}"
 	shift
 
@@ -33,10 +36,11 @@ _request() {
 	fi
 
 	docker run --rm --link "$cid":haproxy "$clientImage" \
-		curl -fs -X"$method" --header 'Host: www.google.com' "$@" "http://haproxy/$url"
+		curl -fsSL -X"$method" --connect-to '::haproxy:' "$@" "$proto://example.com/$url"
 }
 
 . "$dir/../../retry.sh" '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]'
 
-# Check that we can request / (which is proxying google.com)
-[[ "$(_request GET '/')" == *Google* ]]
+# Check that we can request / (which is proxying example.com)
+_request GET http '/' | grep -q '<h1>Example Domain</h1>'
+_request GET https '/' | grep -q '<h1>Example Domain</h1>'