diff --git a/test/integration/connect/envoy/case-dogstatsd-udp/verify.bats b/test/integration/connect/envoy/case-dogstatsd-udp/verify.bats index 463f146b2b..55b0ad7684 100644 --- a/test/integration/connect/envoy/case-dogstatsd-udp/verify.bats +++ b/test/integration/connect/envoy/case-dogstatsd-udp/verify.bats @@ -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" { diff --git a/test/integration/connect/envoy/case-statsd-udp/verify.bats b/test/integration/connect/envoy/case-statsd-udp/verify.bats index 05d37614a3..f32f54e505 100644 --- a/test/integration/connect/envoy/case-statsd-udp/verify.bats +++ b/test/integration/connect/envoy/case-statsd-udp/verify.bats @@ -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" { diff --git a/test/integration/connect/envoy/case-zipkin/verify.bats b/test/integration/connect/envoy/case-zipkin/verify.bats index 98f11056ef..d771d52363 100644 --- a/test/integration/connect/envoy/case-zipkin/verify.bats +++ b/test/integration/connect/envoy/case-zipkin/verify.bats @@ -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" { diff --git a/test/integration/connect/envoy/helpers.bash b/test/integration/connect/envoy/helpers.bash index 6e9d13914a..ddf5d93ef1 100755 --- a/test/integration/connect/envoy/helpers.bash +++ b/test/integration/connect/envoy/helpers.bash @@ -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