Add integration test check

pull/9042/head
Yong Wen Chua 4 years ago
parent 58b553704a
commit ec8fecbf61
No known key found for this signature in database
GPG Key ID: 2D68945D154B53AD

@ -9,4 +9,9 @@ config_entries {
}
]
}
bootstrap {
kind = "service-defaults"
name = "s4"
protocol = "http"
}
}

@ -31,3 +31,7 @@ load helpers
@test "terminating-gateway is used for the upstream connection" {
assert_envoy_metric_at_least 127.0.0.1:20000 "s4.default.primary.*cx_total" 1
}
@test "terminating-gateway adds the Host header for connection to s3" {
assert_expected_fortio_host_header "localhost:8382" localhost 5000
}

@ -835,3 +835,33 @@ function assert_expected_fortio_name_pattern {
return 1
fi
}
function get_upstream_fortio_host_header {
local HOST=$1
local PORT=$2
local PREFIX=$3
local DEBUG_HEADER_VALUE="${4:-""}"
local extra_args
if [[ -n "${DEBUG_HEADER_VALUE}" ]]; then
extra_args="-H x-test-debug:${DEBUG_HEADER_VALUE}"
fi
run retry_default curl -v -s -f -H"Host: ${HOST}" $extra_args \
"localhost:${PORT}${PREFIX}/debug"
[ "$status" == 0 ]
echo "$output" | grep -E "^Host: "
}
function assert_expected_fortio_host_header {
local EXPECT_HOST=$1
local HOST=${2:-"localhost"}
local PORT=${3:-5000}
local URL_PREFIX=${4:-""}
local DEBUG_HEADER_VALUE="${5:-""}"
GOT=$(get_upstream_fortio_host_header ${HOST} ${PORT} "${URL_PREFIX}" "${DEBUG_HEADER_VALUE}")
if [ "$GOT" != "Host: ${EXPECT_HOST}" ]; then
echo "expected Host header: $EXPECT_HOST, actual Host header: $GOT" 1>&2
return 1
fi
}

Loading…
Cancel
Save