Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: consolidate envoy Cluster defaults #1782

Merged
merged 1 commit into from
Oct 24, 2019

Conversation

jpeach
Copy link
Contributor

@jpeach jpeach commented Oct 23, 2019

Many tests need to specify default fields for envoy Cluster structs
so that struct equality tests can succeed. Specifying these defaults
in many places is fragile and tends to make it harder to see the
field values that actually matter to the tests. Consolidating the
defaults into a handful of helpers reduces the overally clutter.
We still need a couple of duplicates of the helper so that we can
avoid package dependency cycles.

This updates #1375.

Signed-off-by: James Peach jpeach@vmware.com

@davecheney
Copy link
Contributor

reviewing now ...

Copy link
Contributor

@davecheney davecheney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for working on this, I like the improvements you made in this version.

// Cluster creates new v2.Cluster from dag.Cluster.
func Cluster(c *dag.Cluster) *v2.Cluster {
cl := cluster(c)
service := c.Upstream
cluster := clusterDefaults()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the clean up that lets cluster be a local variable. 👍

@@ -43,18 +58,15 @@ func routeCluster(cluster string) *envoy_api_v2_route.Route_Route {
}

func cluster(name, servicename, statName string) *v2.Cluster {
return &v2.Cluster{
return DefaultCluster(&v2.Cluster{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really nice cleanup.

Many tests need to specify default fields for envoy `Cluster` structs
so that struct equality tests can succeed. Specifying these defaults
in many places is fragile and tends to make it harder to see the
field values that actually matter to the tests.  Consolidating the
defaults into a handful of helpers reduces the overally clutter.
We still need a couple of duplicates of the helper so that we can
avoid package dependency cycles.

This updates projectcontour#1375.

Signed-off-by: James Peach <jpeach@vmware.com>
@jpeach jpeach force-pushed the consolidate-cluster-defaults branch from f363090 to a906a74 Compare October 24, 2019 20:17
@jpeach jpeach merged commit bae8971 into projectcontour:master Oct 24, 2019
@jpeach jpeach deleted the consolidate-cluster-defaults branch October 24, 2019 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants