Skip to content

Commit

Permalink
extend defaults test and fix connectTimeout bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wardviaene committed Feb 28, 2022
1 parent 5b7c6e4 commit 486eb23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/envoy/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (c *Cluster) createCluster(params ClusterParams) *api.Cluster {
connectTimeout = time.Duration(params.ConnectTimeout) * time.Second
} else { // set default if defined
if c.DefaultsParams.ConnectTimeout > 0 {
connectTimeout = time.Duration(params.ConnectTimeout) * time.Second
connectTimeout = time.Duration(c.DefaultsParams.ConnectTimeout) * time.Second
}
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/envoy/xds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ func TestRuleWithDefaults(t *testing.T) {
return
}
x := NewXDS(s, "", "")
ObjectFileNames := []string{"test-cluster-connection-timeout.yaml", "test-cluster-1.yaml", "test-defaults.yaml"}
ObjectFileNames := []string{"test-cluster-connection-timeout.yaml", "test-cluster-1.yaml", "test-defaults.yaml", "test-prefixrewrite.yaml"}
for _, filename := range ObjectFileNames {
newItems, err := x.putObject(filename)
if err != nil {
Expand All @@ -1456,6 +1456,9 @@ func TestRuleWithDefaults(t *testing.T) {
if cluster.Name == "test-cluster" && cluster.ConnectTimeout.Seconds != 15 {
t.Errorf("Cluster Connect timeout is not 15 (got %d)", cluster.ConnectTimeout.Seconds)
}
if cluster.Name == "test-prefixrewrite" && cluster.ConnectTimeout.Seconds != 15 {
t.Errorf("Cluster Connect timeout is not 15 (got %d)", cluster.ConnectTimeout.Seconds)
}
}
if len(checks) != 2 {
t.Errorf("Clusters not found")
Expand Down

0 comments on commit 486eb23

Please sign in to comment.