integ test: fix retry upstream test (#16246)

This commit is contained in:
cskh 2023-02-13 15:16:56 -05:00 committed by GitHub
parent 58af8acab9
commit 3cace09d59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 12 deletions

View File

@ -20,12 +20,7 @@ load helpers
}
@test "s1 upstream should be able to connect to s2" {
run retry_default curl -s -f -d hello localhost:5000
echo "OUTPUT: $output"
[ "$status" == 0 ]
[ "$output" == "hello" ]
retry_default assert_upstream_message 5000
}
@test "s1 proxy should be sending metrics to statsd" {

View File

@ -20,9 +20,7 @@ load helpers
}
@test "s1 upstream should be able to connect to s2" {
run retry_default curl -s -f -d hello localhost:5000
[ "$status" == 0 ]
[ "$output" == "hello" ]
retry_default assert_upstream_message 5000
}
@test "s1 proxy should be sending metrics to statsd" {

View File

@ -28,9 +28,7 @@ load helpers
}
@test "s1 upstream should be able to connect to s2" {
run retry_default curl -s -f -d hello localhost:5000
[ "$status" == "0" ]
[ "$output" == "hello" ]
retry_default assert_upstream_message 5000
}
@test "s1 proxy should send trace spans to zipkin/jaeger" {

View File

@ -46,6 +46,25 @@ function retry_long {
retry 30 1 "$@"
}
# assert_upstream_message asserts both the returned code
# and message from upstream service
function assert_upstream_message {
local HOSTPORT=$1
run curl -s -d hello localhost:$HOSTPORT
if [ "$status" -ne 0 ]; then
echo "Command failed"
return 1
fi
if (echo $output | grep 'hello'); then
return 0
fi
echo "expected message not found in $output"
return 1
}
function is_set {
# Arguments:
# $1 - string value to check its truthiness