Skip to content

Commit

Permalink
Add outlier_detection check to integration test
Browse files Browse the repository at this point in the history
Fix decoding of time.Duration types.
  • Loading branch information
dnephin committed May 5, 2020
1 parent f823167 commit 0861a27
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
13 changes: 12 additions & 1 deletion agent/xds/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 7 additions & 1 deletion test/integration/connect/envoy/case-centralconf/s1.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ services {
{
destination_name = "s2"
local_bind_port = 5000
config {
passive_health_check {
interval = "22s"
max_failures = 4
}
}
}
]
}
}
}
}
}
20 changes: 20 additions & 0 deletions test/integration/connect/envoy/case-centralconf/verify.bats
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,23 @@ load helpers
must_match_in_prometheus_response localhost:1234 \
'[\{,]envoy_http_conn_manager_prefix="upstream_s2_http"[,}]'
}

function get_envoy_cluster_config {
local HOSTPORT=$1
local CLUSTER_NAME=$2
run retry_default curl -s -f $HOSTPORT/config_dump
[ "$status" -eq 0 ]
echo "$output" | jq --raw-output "
.configs[1].dynamic_active_clusters[]
| select(.cluster.name|startswith(\"${CLUSTER_NAME}\"))
| .cluster
"
}

@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" ]
}

0 comments on commit 0861a27

Please sign in to comment.