Browse Source

Add outlier_detection check to integration test

Fix decoding of time.Duration types.
pull/7713/head
Daniel Nephin 5 years ago
parent
commit
5655d7f34e
  1. 13
      agent/xds/config.go
  2. 2
      agent/xds/config_test.go
  3. 2
      test/integration/connect/envoy/case-centralconf/s1.hcl
  4. 4
      test/integration/connect/envoy/case-upstream-config/s1.hcl
  5. 0
      test/integration/connect/envoy/case-upstream-config/s2.hcl
  6. 0
      test/integration/connect/envoy/case-upstream-config/setup.sh
  7. 10
      test/integration/connect/envoy/case-upstream-config/verify.bats
  8. 4
      test/integration/connect/envoy/helpers.bash

13
agent/xds/config.go

@ -193,7 +193,18 @@ func (p PassiveHealthCheck) AsOutlierDetection() *envoycluster.OutlierDetection
func ParseUpstreamConfigNoDefaults(m map[string]interface{}) (UpstreamConfig, error) {
var cfg UpstreamConfig
err := mapstructure.WeakDecode(m, &cfg)
config := &mapstructure.DecoderConfig{
DecodeHook: mapstructure.StringToTimeDurationHookFunc(),
Result: &cfg,
WeaklyTypedInput: true,
}
decoder, err := mapstructure.NewDecoder(config)
if err != nil {
return cfg, err
}
err = decoder.Decode(m)
return cfg, err
}

2
agent/xds/config_test.go

@ -249,7 +249,7 @@ func TestParseUpstreamConfig(t *testing.T) {
name: "passive health check map",
input: map[string]interface{}{
"passive_health_check": map[string]interface{}{
"interval": 22 * time.Second,
"interval": "22s",
"max_failures": 7,
},
},

2
test/integration/connect/envoy/case-centralconf/s1.hcl

@ -13,4 +13,4 @@ services {
}
}
}
}
}

4
test/integration/connect/envoy/case-upstream-connection-limits/s1.hcl → test/integration/connect/envoy/case-upstream-config/s1.hcl

@ -14,6 +14,10 @@ services {
max_pending_requests = 4
max_concurrent_requests = 5
}
passive_health_check {
interval = "22s"
max_failures = 4
}
}
}
]

0
test/integration/connect/envoy/case-upstream-connection-limits/s2.hcl → test/integration/connect/envoy/case-upstream-config/s2.hcl

0
test/integration/connect/envoy/case-upstream-connection-limits/setup.sh → test/integration/connect/envoy/case-upstream-config/setup.sh

10
test/integration/connect/envoy/case-upstream-connection-limits/verify.bats → test/integration/connect/envoy/case-upstream-config/verify.bats

@ -27,7 +27,7 @@ load helpers
}
@test "s1 proxy should have been configured with max_connections on the cluster" {
CLUSTER_THRESHOLD=$(get_envoy_cluster_threshold localhost:19000 s2.default.primary)
CLUSTER_THRESHOLD=$(get_envoy_cluster_config localhost:19000 s2.default.primary | jq '.circuit_breakers.thresholds[0]')
echo $CLUSTER_THRESHOLD
MAX_CONNS=$(echo $CLUSTER_THRESHOLD | jq --raw-output '.max_connections')
@ -42,3 +42,11 @@ load helpers
[ "$MAX_PENDING_REQS" = "4" ]
[ "$MAX_REQS" = "5" ]
}
@test "s1 proxy should have been configured with passive_health_check" {
CLUSTER_CONFIG=$(get_envoy_cluster_config localhost:19000 s2.default.primary)
echo $CLUSTER_CONFIG
[ "$(echo $CLUSTER_CONFIG | jq --raw-output '.outlier_detection.consecutive_5xx')" = "4" ]
[ "$(echo $CLUSTER_CONFIG | jq --raw-output '.outlier_detection.interval')" = "22s" ]
}

4
test/integration/connect/envoy/helpers.bash

@ -156,7 +156,7 @@ function get_envoy_listener_filters {
echo "$output" | jq --raw-output "$QUERY"
}
function get_envoy_cluster_threshold {
function get_envoy_cluster_config {
local HOSTPORT=$1
local CLUSTER_NAME=$2
run retry_default curl -s -f $HOSTPORT/config_dump
@ -164,7 +164,7 @@ function get_envoy_cluster_threshold {
echo "$output" | jq --raw-output "
.configs[1].dynamic_active_clusters[]
| select(.cluster.name|startswith(\"${CLUSTER_NAME}\"))
| .cluster.circuit_breakers.thresholds[0]
| .cluster
"
}

Loading…
Cancel
Save