From 58f068f53a493bcd4b48e17709ac69b94f7de8c8 Mon Sep 17 00:00:00 2001 From: "R.B. Boyer" Date: Mon, 22 Feb 2021 14:02:08 -0600 Subject: [PATCH] [1.8.x] test: remove warnings and ensure the expose checks envoy test actually runs (#9804) --- .../{service_s1.hcl => s1.hcl} | 0 .../{service_s2.hcl => s2.hcl} | 0 .../connect/envoy/case-expose-checks/setup.sh | 2 -- test/integration/connect/envoy/helpers.bash | 26 ++++++++++++++++++- test/integration/connect/envoy/main_test.go | 1 + 5 files changed, 26 insertions(+), 3 deletions(-) rename test/integration/connect/envoy/case-expose-checks/{service_s1.hcl => s1.hcl} (100%) rename test/integration/connect/envoy/case-expose-checks/{service_s2.hcl => s2.hcl} (100%) diff --git a/test/integration/connect/envoy/case-expose-checks/service_s1.hcl b/test/integration/connect/envoy/case-expose-checks/s1.hcl similarity index 100% rename from test/integration/connect/envoy/case-expose-checks/service_s1.hcl rename to test/integration/connect/envoy/case-expose-checks/s1.hcl diff --git a/test/integration/connect/envoy/case-expose-checks/service_s2.hcl b/test/integration/connect/envoy/case-expose-checks/s2.hcl similarity index 100% rename from test/integration/connect/envoy/case-expose-checks/service_s2.hcl rename to test/integration/connect/envoy/case-expose-checks/s2.hcl diff --git a/test/integration/connect/envoy/case-expose-checks/setup.sh b/test/integration/connect/envoy/case-expose-checks/setup.sh index e8321972b3..a74435b3b1 100644 --- a/test/integration/connect/envoy/case-expose-checks/setup.sh +++ b/test/integration/connect/envoy/case-expose-checks/setup.sh @@ -2,7 +2,5 @@ set -eEuo pipefail -register_services primary - gen_envoy_bootstrap s1 19000 primary gen_envoy_bootstrap s2 19001 primary diff --git a/test/integration/connect/envoy/helpers.bash b/test/integration/connect/envoy/helpers.bash index 7288f6f622..8b61c3fdf7 100755 --- a/test/integration/connect/envoy/helpers.bash +++ b/test/integration/connect/envoy/helpers.bash @@ -161,6 +161,26 @@ function assert_envoy_expose_checks_listener_count { BODY=$(get_envoy_expose_checks_listener_once $HOSTPORT) echo "BODY = $BODY" + if [[ "$ENVOY_VERSION" =~ ^1\.1[012]\. ]]; then + CHAINS=$(echo "$BODY" | jq '.listener.filter_chains | length') + echo "CHAINS = $CHAINS (expect 1)" + [ "${CHAINS:-0}" -eq 1 ] + + RANGES=$(echo "$BODY" | jq '.listener.filter_chains[0].filter_chain_match.source_prefix_ranges | length') + echo "RANGES = $RANGES (expect 3)" + # note: if IPv6 is not supported in the kernel per + # agent/xds:kernelSupportsIPv6() then this will only be 2 + [ "${RANGES:-0}" -eq 3 ] + + HCM=$(echo "$BODY" | jq '.listener.filter_chains[0].filters[0]') + HCM_NAME=$(echo "$HCM" | jq -r '.name') + HCM_PATH=$(echo "$HCM" | jq -r '.config.route_config.virtual_hosts[0].routes[0].match.path') + echo "HCM = $HCM" + [ "${HCM_NAME:-}" == "envoy.http_connection_manager" ] + [ "${HCM_PATH:-}" == "${EXPECT_PATH}" ] + return 0 + fi + CHAINS=$(echo "$BODY" | jq '.active_state.listener.filter_chains | length') echo "CHAINS = $CHAINS (expect 1)" [ "${CHAINS:-0}" -eq 1 ] @@ -183,7 +203,11 @@ function get_envoy_expose_checks_listener_once { local HOSTPORT=$1 run curl -s -f $HOSTPORT/config_dump [ "$status" -eq 0 ] - echo "$output" | jq --raw-output '.configs[] | select(.["@type"] == "type.googleapis.com/envoy.admin.v3.ListenersConfigDump") | .dynamic_listeners[] | select(.name | startswith("exposed_path_"))' + if [[ "$ENVOY_VERSION" =~ ^1\.1[012]\. ]]; then + echo "$output" | jq --raw-output '.configs[] | select(.["@type"] == "type.googleapis.com/envoy.admin.v2alpha.ListenersConfigDump") | .dynamic_active_listeners[] | select(.listener.name | startswith("exposed_path_"))' + else + echo "$output" | jq --raw-output '.configs[] | select(.["@type"] == "type.googleapis.com/envoy.admin.v3.ListenersConfigDump") | .dynamic_listeners[] | select(.name | startswith("exposed_path_"))' + fi } function get_envoy_listener_filters { diff --git a/test/integration/connect/envoy/main_test.go b/test/integration/connect/envoy/main_test.go index 38cb553d4a..ff8b8693dc 100644 --- a/test/integration/connect/envoy/main_test.go +++ b/test/integration/connect/envoy/main_test.go @@ -26,6 +26,7 @@ func TestEnvoy(t *testing.T) { "case-cfg-splitter-features", "case-consul-exec", "case-dogstatsd-udp", + "case-expose-checks", "case-gateways-local", "case-gateways-remote", "case-gateway-without-services",