[NET-10733] fix generation of xds resources (#21603)

fix generation of xds resources
This commit is contained in:
John Maguire 2024-08-14 15:00:00 -04:00 committed by GitHub
parent a570858a35
commit 8555404662
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -445,25 +445,25 @@ func getConnectProxyTransparentProxyGoldenTestCases() []goldenTestCase {
} }
func getConnectProxyDiscoChainTests(enterprise bool) []goldenTestCase { func getConnectProxyDiscoChainTests(enterprise bool) []goldenTestCase {
return []goldenTestCase{ cases := []goldenTestCase{
{ {
name: "connect-proxy-with-chain", name: "connect-proxy-with-chain",
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshotDiscoveryChain(t, "simple", false, nil, nil) return proxycfg.TestConfigSnapshotDiscoveryChain(t, "simple", enterprise, nil, nil)
}, },
alsoRunTestForV2: true, alsoRunTestForV2: true,
}, },
{ {
name: "connect-proxy-with-chain-external-sni", name: "connect-proxy-with-chain-external-sni",
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshotDiscoveryChain(t, "external-sni", false, nil, nil) return proxycfg.TestConfigSnapshotDiscoveryChain(t, "external-sni", enterprise, nil, nil)
}, },
alsoRunTestForV2: true, alsoRunTestForV2: true,
}, },
{ {
name: "connect-proxy-with-chain-and-failover", name: "connect-proxy-with-chain-and-failover",
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshotDiscoveryChain(t, "failover", false, nil, nil) return proxycfg.TestConfigSnapshotDiscoveryChain(t, "failover", enterprise, nil, nil)
}, },
alsoRunTestForV2: true, alsoRunTestForV2: true,
}, },
@ -487,10 +487,9 @@ func getConnectProxyDiscoChainTests(enterprise bool) []goldenTestCase {
name: "custom-upstream-default-chain", name: "custom-upstream-default-chain",
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshotDiscoveryChain(t, "default", enterprise, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshotDiscoveryChain(t, "default", enterprise, func(ns *structs.NodeService) {
ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = customAppClusterJSON(t, customClusterJSONOptions{
customAppClusterJSON(t, customClusterJSONOptions{ Name: "myservice",
Name: "myservice", })
})
}, nil) }, nil)
}, },
// TODO(proxystate): requires custom cluster work // TODO(proxystate): requires custom cluster work
@ -602,10 +601,9 @@ func getConnectProxyDiscoChainTests(enterprise bool) []goldenTestCase {
name: "connect-proxy-with-default-chain-and-custom-cluster", name: "connect-proxy-with-default-chain-and-custom-cluster",
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshotDiscoveryChain(t, "default", enterprise, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshotDiscoveryChain(t, "default", enterprise, func(ns *structs.NodeService) {
ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = customAppClusterJSON(t, customClusterJSONOptions{
customAppClusterJSON(t, customClusterJSONOptions{ Name: "myservice",
Name: "myservice", })
})
}, nil) }, nil)
}, },
// TODO(proxystate): requires custom cluster work // TODO(proxystate): requires custom cluster work
@ -667,10 +665,9 @@ func getConnectProxyDiscoChainTests(enterprise bool) []goldenTestCase {
uid := proxycfg.NewUpstreamID(&ns.Proxy.Upstreams[i]) uid := proxycfg.NewUpstreamID(&ns.Proxy.Upstreams[i])
ns.Proxy.Upstreams[i].Config["envoy_listener_json"] = ns.Proxy.Upstreams[i].Config["envoy_listener_json"] = customListenerJSON(t, customListenerJSONOptions{
customListenerJSON(t, customListenerJSONOptions{ Name: uid.EnvoyID() + ":custom-upstream",
Name: uid.EnvoyID() + ":custom-upstream", })
})
} }
}, nil) }, nil)
}, },
@ -731,6 +728,14 @@ func getConnectProxyDiscoChainTests(enterprise bool) []goldenTestCase {
alsoRunTestForV2: true, alsoRunTestForV2: true,
}, },
} }
if enterprise {
for i := range cases {
cases[i].name = "enterprise-" + cases[i].name
}
}
return cases
} }
func getMeshGatewayGoldenTestCases() []goldenTestCase { func getMeshGatewayGoldenTestCases() []goldenTestCase {
@ -896,6 +901,7 @@ func getMeshGatewayGoldenTestCases() []goldenTestCase {
}, },
} }
} }
func getMeshGatewayPeeringGoldenTestCases() []goldenTestCase { func getMeshGatewayPeeringGoldenTestCases() []goldenTestCase {
return []goldenTestCase{ return []goldenTestCase{
{ {
@ -1426,7 +1432,6 @@ func getAPIGatewayGoldenTestCases(t *testing.T) []goldenTestCase {
}, },
}, },
} }
}, []structs.BoundRoute{ }, []structs.BoundRoute{
&structs.TCPRouteConfigEntry{ &structs.TCPRouteConfigEntry{
Name: "tcp-route", Name: "tcp-route",
@ -1596,7 +1601,8 @@ func getAPIGatewayGoldenTestCases(t *testing.T) []goldenTestCase {
{Kind: structs.HTTPRoute, Name: "backend-route"}, {Kind: structs.HTTPRoute, Name: "backend-route"},
{Kind: structs.HTTPRoute, Name: "frontend-route"}, {Kind: structs.HTTPRoute, Name: "frontend-route"},
{Kind: structs.HTTPRoute, Name: "generic-route"}, {Kind: structs.HTTPRoute, Name: "generic-route"},
}}, },
},
} }
}, },
[]structs.BoundRoute{ []structs.BoundRoute{
@ -1735,10 +1741,9 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
name: "custom-upstream-default-chain", name: "custom-upstream-default-chain",
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshotDiscoveryChain(t, "default", enterprise, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshotDiscoveryChain(t, "default", enterprise, func(ns *structs.NodeService) {
ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = customAppClusterJSON(t, customClusterJSONOptions{
customAppClusterJSON(t, customClusterJSONOptions{ Name: "myservice",
Name: "myservice", })
})
}, nil) }, nil)
}, },
// TODO(proxystate): requires custom cluster work // TODO(proxystate): requires custom cluster work
@ -1748,10 +1753,9 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
name: "custom-local-app", name: "custom-local-app",
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) {
ns.Proxy.Config["envoy_local_cluster_json"] = ns.Proxy.Config["envoy_local_cluster_json"] = customAppClusterJSON(t, customClusterJSONOptions{
customAppClusterJSON(t, customClusterJSONOptions{ Name: "mylocal",
Name: "mylocal", })
})
}, nil) }, nil)
}, },
// TODO(proxystate): requires custom cluster work // TODO(proxystate): requires custom cluster work
@ -1761,10 +1765,9 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
name: "custom-upstream", name: "custom-upstream",
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) {
ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = customAppClusterJSON(t, customClusterJSONOptions{
customAppClusterJSON(t, customClusterJSONOptions{ Name: "myservice",
Name: "myservice", })
})
}, nil) }, nil)
}, },
// TODO(proxystate): requires custom cluster work // TODO(proxystate): requires custom cluster work
@ -1775,12 +1778,11 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
overrideGoldenName: "custom-upstream", // should be the same overrideGoldenName: "custom-upstream", // should be the same
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) {
ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = customAppClusterJSON(t, customClusterJSONOptions{
customAppClusterJSON(t, customClusterJSONOptions{ Name: "myservice",
Name: "myservice", // Attempt to override the TLS context should be ignored
// Attempt to override the TLS context should be ignored TLSContext: `"allowRenegotiation": false`,
TLSContext: `"allowRenegotiation": false`, })
})
}, nil) }, nil)
}, },
// TODO(proxystate): requires custom cluster work // TODO(proxystate): requires custom cluster work
@ -1791,7 +1793,6 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) {
for i := range ns.Proxy.Upstreams { for i := range ns.Proxy.Upstreams {
switch ns.Proxy.Upstreams[i].DestinationName { switch ns.Proxy.Upstreams[i].DestinationName {
case "db": case "db":
if ns.Proxy.Upstreams[i].Config == nil { if ns.Proxy.Upstreams[i].Config == nil {
@ -1803,10 +1804,9 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
// Triggers an override with the presence of the escape hatch listener // Triggers an override with the presence of the escape hatch listener
ns.Proxy.Upstreams[i].DestinationType = structs.UpstreamDestTypePreparedQuery ns.Proxy.Upstreams[i].DestinationType = structs.UpstreamDestTypePreparedQuery
ns.Proxy.Upstreams[i].Config["envoy_cluster_json"] = ns.Proxy.Upstreams[i].Config["envoy_cluster_json"] = customClusterJSON(t, customClusterJSONOptions{
customClusterJSON(t, customClusterJSONOptions{ Name: uid.EnvoyID() + ":custom-upstream",
Name: uid.EnvoyID() + ":custom-upstream", })
})
// Also test that http2 options are triggered. // Also test that http2 options are triggered.
// A separate upstream without an override is required to test // A separate upstream without an override is required to test
@ -1936,10 +1936,9 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
name: "connect-proxy-with-default-chain-and-custom-cluster", name: "connect-proxy-with-default-chain-and-custom-cluster",
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshotDiscoveryChain(t, "default", enterprise, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshotDiscoveryChain(t, "default", enterprise, func(ns *structs.NodeService) {
ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = ns.Proxy.Upstreams[0].Config["envoy_cluster_json"] = customAppClusterJSON(t, customClusterJSONOptions{
customAppClusterJSON(t, customClusterJSONOptions{ Name: "myservice",
Name: "myservice", })
})
}, nil) }, nil)
}, },
// TODO(proxystate): requires custom cluster work // TODO(proxystate): requires custom cluster work
@ -1949,10 +1948,9 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
name: "custom-public-listener", name: "custom-public-listener",
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) {
ns.Proxy.Config["envoy_public_listener_json"] = ns.Proxy.Config["envoy_public_listener_json"] = customListenerJSON(t, customListenerJSONOptions{
customListenerJSON(t, customListenerJSONOptions{ Name: "custom-public-listen",
Name: "custom-public-listen", })
})
}, nil) }, nil)
}, },
}, },
@ -1961,10 +1959,9 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) {
ns.Proxy.Config["protocol"] = "http" ns.Proxy.Config["protocol"] = "http"
ns.Proxy.Config["envoy_public_listener_json"] = ns.Proxy.Config["envoy_public_listener_json"] = customHTTPListenerJSON(t, customHTTPListenerJSONOptions{
customHTTPListenerJSON(t, customHTTPListenerJSONOptions{ Name: "custom-public-listen",
Name: "custom-public-listen", })
})
}, nil) }, nil)
}, },
}, },
@ -1973,11 +1970,10 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) {
ns.Proxy.Config["protocol"] = "http" ns.Proxy.Config["protocol"] = "http"
ns.Proxy.Config["envoy_public_listener_json"] = ns.Proxy.Config["envoy_public_listener_json"] = customHTTPListenerJSON(t, customHTTPListenerJSONOptions{
customHTTPListenerJSON(t, customHTTPListenerJSONOptions{ Name: "custom-public-listen",
Name: "custom-public-listen", HTTPConnectionManagerName: httpConnectionManagerNewName,
HTTPConnectionManagerName: httpConnectionManagerNewName, })
})
}, nil) }, nil)
}, },
}, },
@ -1986,10 +1982,9 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) {
ns.Proxy.Config["protocol"] = "http" ns.Proxy.Config["protocol"] = "http"
ns.Proxy.Config["envoy_public_listener_json"] = ns.Proxy.Config["envoy_public_listener_json"] = customListenerJSON(t, customListenerJSONOptions{
customListenerJSON(t, customListenerJSONOptions{ Name: "custom-public-listen",
Name: "custom-public-listen", })
})
}, nil) }, nil)
}, },
}, },
@ -1998,12 +1993,11 @@ func getCustomConfigurationGoldenTestCases(enterprise bool) []goldenTestCase {
overrideGoldenName: "custom-public-listener", // should be the same overrideGoldenName: "custom-public-listener", // should be the same
create: func(t testinf.T) *proxycfg.ConfigSnapshot { create: func(t testinf.T) *proxycfg.ConfigSnapshot {
return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) { return proxycfg.TestConfigSnapshot(t, func(ns *structs.NodeService) {
ns.Proxy.Config["envoy_public_listener_json"] = ns.Proxy.Config["envoy_public_listener_json"] = customListenerJSON(t, customListenerJSONOptions{
customListenerJSON(t, customListenerJSONOptions{ Name: "custom-public-listen",
Name: "custom-public-listen", // Attempt to override the TLS context should be ignored
// Attempt to override the TLS context should be ignored TLSContext: `"allowRenegotiation": false`,
TLSContext: `"allowRenegotiation": false`, })
})
}, nil) }, nil)
}, },
}, },