|
|
@ -22,7 +22,16 @@ func TestConfigSnapshotTransparentProxy(t testing.T) *ConfigSnapshot { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
google = structs.NewServiceName("google", nil) |
|
|
|
google = structs.NewServiceName("google", nil) |
|
|
|
googleUID = NewUpstreamIDFromServiceName(google) |
|
|
|
googleUID = NewUpstreamIDFromServiceName(google) |
|
|
|
googleChain = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", nil, nil) |
|
|
|
googleChain = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", func(req *discoverychain.CompileRequest) { |
|
|
|
|
|
|
|
req.AutoVirtualIPs = []string{"240.0.0.1"} |
|
|
|
|
|
|
|
req.ManualVirtualIPs = []string{"10.0.0.1"} |
|
|
|
|
|
|
|
}, nil) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
googleV2 = structs.NewServiceName("google-v2", nil) |
|
|
|
|
|
|
|
googleUIDV2 = NewUpstreamIDFromServiceName(googleV2) |
|
|
|
|
|
|
|
googleChainV2 = discoverychain.TestCompileConfigEntries(t, "google-v2", "default", "default", "dc1", connect.TestClusterID+".consul", func(req *discoverychain.CompileRequest) { |
|
|
|
|
|
|
|
req.ManualVirtualIPs = []string{"10.10.10.10"} |
|
|
|
|
|
|
|
}, nil) |
|
|
|
|
|
|
|
|
|
|
|
noEndpoints = structs.NewServiceName("no-endpoints", nil) |
|
|
|
noEndpoints = structs.NewServiceName("no-endpoints", nil) |
|
|
|
noEndpointsUID = NewUpstreamIDFromServiceName(noEndpoints) |
|
|
|
noEndpointsUID = NewUpstreamIDFromServiceName(noEndpoints) |
|
|
@ -59,6 +68,12 @@ func TestConfigSnapshotTransparentProxy(t testing.T) *ConfigSnapshot { |
|
|
|
Chain: googleChain, |
|
|
|
Chain: googleChain, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CorrelationID: "discovery-chain:" + googleUIDV2.String(), |
|
|
|
|
|
|
|
Result: &structs.DiscoveryChainResponse{ |
|
|
|
|
|
|
|
Chain: googleChainV2, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
CorrelationID: "discovery-chain:" + noEndpointsUID.String(), |
|
|
|
CorrelationID: "discovery-chain:" + noEndpointsUID.String(), |
|
|
|
Result: &structs.DiscoveryChainResponse{ |
|
|
|
Result: &structs.DiscoveryChainResponse{ |
|
|
@ -78,10 +93,6 @@ func TestConfigSnapshotTransparentProxy(t testing.T) *ConfigSnapshot { |
|
|
|
Service: "google", |
|
|
|
Service: "google", |
|
|
|
Address: "9.9.9.9", |
|
|
|
Address: "9.9.9.9", |
|
|
|
Port: 9090, |
|
|
|
Port: 9090, |
|
|
|
TaggedAddresses: map[string]structs.ServiceAddress{ |
|
|
|
|
|
|
|
"virtual": {Address: "10.0.0.1"}, |
|
|
|
|
|
|
|
structs.TaggedAddressVirtualIP: {Address: "240.0.0.1"}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -100,9 +111,6 @@ func TestConfigSnapshotTransparentProxy(t testing.T) *ConfigSnapshot { |
|
|
|
}, |
|
|
|
}, |
|
|
|
Service: &structs.NodeService{ |
|
|
|
Service: &structs.NodeService{ |
|
|
|
Service: "google-v2", |
|
|
|
Service: "google-v2", |
|
|
|
TaggedAddresses: map[string]structs.ServiceAddress{ |
|
|
|
|
|
|
|
"virtual": {Address: "10.10.10.10"}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -255,7 +263,9 @@ func TestConfigSnapshotTransparentProxyCatalogDestinationsOnly(t testing.T) *Con |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
google = structs.NewServiceName("google", nil) |
|
|
|
google = structs.NewServiceName("google", nil) |
|
|
|
googleUID = NewUpstreamIDFromServiceName(google) |
|
|
|
googleUID = NewUpstreamIDFromServiceName(google) |
|
|
|
googleChain = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", nil, nil) |
|
|
|
googleChain = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", func(req *discoverychain.CompileRequest) { |
|
|
|
|
|
|
|
req.ManualVirtualIPs = []string{"10.0.0.1"} |
|
|
|
|
|
|
|
}, nil) |
|
|
|
|
|
|
|
|
|
|
|
noEndpoints = structs.NewServiceName("no-endpoints", nil) |
|
|
|
noEndpoints = structs.NewServiceName("no-endpoints", nil) |
|
|
|
noEndpointsUID = NewUpstreamIDFromServiceName(noEndpoints) |
|
|
|
noEndpointsUID = NewUpstreamIDFromServiceName(noEndpoints) |
|
|
@ -315,9 +325,6 @@ func TestConfigSnapshotTransparentProxyCatalogDestinationsOnly(t testing.T) *Con |
|
|
|
Service: "google", |
|
|
|
Service: "google", |
|
|
|
Address: "9.9.9.9", |
|
|
|
Address: "9.9.9.9", |
|
|
|
Port: 9090, |
|
|
|
Port: 9090, |
|
|
|
TaggedAddresses: map[string]structs.ServiceAddress{ |
|
|
|
|
|
|
|
"virtual": {Address: "10.0.0.1"}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -352,7 +359,9 @@ func TestConfigSnapshotTransparentProxyDialDirectly(t testing.T) *ConfigSnapshot |
|
|
|
|
|
|
|
|
|
|
|
mongo = structs.NewServiceName("mongo", nil) |
|
|
|
mongo = structs.NewServiceName("mongo", nil) |
|
|
|
mongoUID = NewUpstreamIDFromServiceName(mongo) |
|
|
|
mongoUID = NewUpstreamIDFromServiceName(mongo) |
|
|
|
mongoChain = discoverychain.TestCompileConfigEntries(t, "mongo", "default", "default", "dc1", connect.TestClusterID+".consul", nil, set) |
|
|
|
mongoChain = discoverychain.TestCompileConfigEntries(t, "mongo", "default", "default", "dc1", connect.TestClusterID+".consul", func(req *discoverychain.CompileRequest) { |
|
|
|
|
|
|
|
req.ManualVirtualIPs = []string{"6.6.6.6"} |
|
|
|
|
|
|
|
}, set) |
|
|
|
|
|
|
|
|
|
|
|
db = structs.NewServiceName("db", nil) |
|
|
|
db = structs.NewServiceName("db", nil) |
|
|
|
) |
|
|
|
) |
|
|
@ -404,9 +413,6 @@ func TestConfigSnapshotTransparentProxyDialDirectly(t testing.T) *ConfigSnapshot |
|
|
|
Service: "mongo", |
|
|
|
Service: "mongo", |
|
|
|
Address: "10.10.10.10", |
|
|
|
Address: "10.10.10.10", |
|
|
|
Port: 27017, |
|
|
|
Port: 27017, |
|
|
|
TaggedAddresses: map[string]structs.ServiceAddress{ |
|
|
|
|
|
|
|
"virtual": {Address: "6.6.6.6"}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Proxy: structs.ConnectProxyConfig{ |
|
|
|
Proxy: structs.ConnectProxyConfig{ |
|
|
|
TransparentProxy: structs.TransparentProxyConfig{ |
|
|
|
TransparentProxy: structs.TransparentProxyConfig{ |
|
|
|
DialedDirectly: true, |
|
|
|
DialedDirectly: true, |
|
|
@ -422,9 +428,6 @@ func TestConfigSnapshotTransparentProxyDialDirectly(t testing.T) *ConfigSnapshot |
|
|
|
Service: "mongo", |
|
|
|
Service: "mongo", |
|
|
|
Address: "10.10.10.12", |
|
|
|
Address: "10.10.10.12", |
|
|
|
Port: 27017, |
|
|
|
Port: 27017, |
|
|
|
TaggedAddresses: map[string]structs.ServiceAddress{ |
|
|
|
|
|
|
|
"virtual": {Address: "6.6.6.6"}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Proxy: structs.ConnectProxyConfig{ |
|
|
|
Proxy: structs.ConnectProxyConfig{ |
|
|
|
TransparentProxy: structs.TransparentProxyConfig{ |
|
|
|
TransparentProxy: structs.TransparentProxyConfig{ |
|
|
|
DialedDirectly: true, |
|
|
|
DialedDirectly: true, |
|
|
@ -477,7 +480,10 @@ func TestConfigSnapshotTransparentProxyResolverRedirectUpstream(t testing.T) *Co |
|
|
|
|
|
|
|
|
|
|
|
google = structs.NewServiceName("google", nil) |
|
|
|
google = structs.NewServiceName("google", nil) |
|
|
|
googleUID = NewUpstreamIDFromServiceName(google) |
|
|
|
googleUID = NewUpstreamIDFromServiceName(google) |
|
|
|
googleChain = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", nil, nil) |
|
|
|
googleChain = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", func(req *discoverychain.CompileRequest) { |
|
|
|
|
|
|
|
req.AutoVirtualIPs = []string{"240.0.0.1"} |
|
|
|
|
|
|
|
req.ManualVirtualIPs = []string{"10.0.0.1"} |
|
|
|
|
|
|
|
}, nil) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
return TestConfigSnapshot(t, func(ns *structs.NodeService) { |
|
|
|
return TestConfigSnapshot(t, func(ns *structs.NodeService) { |
|
|
@ -517,10 +523,6 @@ func TestConfigSnapshotTransparentProxyResolverRedirectUpstream(t testing.T) *Co |
|
|
|
Service: "google", |
|
|
|
Service: "google", |
|
|
|
Address: "9.9.9.9", |
|
|
|
Address: "9.9.9.9", |
|
|
|
Port: 9090, |
|
|
|
Port: 9090, |
|
|
|
TaggedAddresses: map[string]structs.ServiceAddress{ |
|
|
|
|
|
|
|
"virtual": {Address: "10.0.0.1"}, |
|
|
|
|
|
|
|
structs.TaggedAddressVirtualIP: {Address: "240.0.0.1"}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -535,11 +537,15 @@ func TestConfigSnapshotTransparentProxyTerminatingGatewayCatalogDestinationsOnly |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
google = structs.NewServiceName("google", nil) |
|
|
|
google = structs.NewServiceName("google", nil) |
|
|
|
googleUID = NewUpstreamIDFromServiceName(google) |
|
|
|
googleUID = NewUpstreamIDFromServiceName(google) |
|
|
|
googleChain = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", nil, nil) |
|
|
|
googleChain = discoverychain.TestCompileConfigEntries(t, "google", "default", "default", "dc1", connect.TestClusterID+".consul", func(req *discoverychain.CompileRequest) { |
|
|
|
|
|
|
|
req.ManualVirtualIPs = []string{"10.0.0.1"} |
|
|
|
|
|
|
|
}, nil) |
|
|
|
|
|
|
|
|
|
|
|
kafka = structs.NewServiceName("kafka", nil) |
|
|
|
kafka = structs.NewServiceName("kafka", nil) |
|
|
|
kafkaUID = NewUpstreamIDFromServiceName(kafka) |
|
|
|
kafkaUID = NewUpstreamIDFromServiceName(kafka) |
|
|
|
kafkaChain = discoverychain.TestCompileConfigEntries(t, "kafka", "default", "default", "dc1", connect.TestClusterID+".consul", nil, nil) |
|
|
|
kafkaChain = discoverychain.TestCompileConfigEntries(t, "kafka", "default", "default", "dc1", connect.TestClusterID+".consul", func(req *discoverychain.CompileRequest) { |
|
|
|
|
|
|
|
req.ManualVirtualIPs = []string{"10.0.0.2"} |
|
|
|
|
|
|
|
}, nil) |
|
|
|
|
|
|
|
|
|
|
|
db = structs.NewServiceName("db", nil) |
|
|
|
db = structs.NewServiceName("db", nil) |
|
|
|
) |
|
|
|
) |
|
|
@ -557,8 +563,6 @@ func TestConfigSnapshotTransparentProxyTerminatingGatewayCatalogDestinationsOnly |
|
|
|
Address: "9.9.9.9", |
|
|
|
Address: "9.9.9.9", |
|
|
|
Port: 9090, |
|
|
|
Port: 9090, |
|
|
|
TaggedAddresses: map[string]structs.ServiceAddress{ |
|
|
|
TaggedAddresses: map[string]structs.ServiceAddress{ |
|
|
|
structs.ServiceGatewayVirtualIPTag(google): {Address: "10.0.0.1"}, |
|
|
|
|
|
|
|
structs.ServiceGatewayVirtualIPTag(kafka): {Address: "10.0.0.2"}, |
|
|
|
|
|
|
|
"virtual": {Address: "6.6.6.6"}, |
|
|
|
"virtual": {Address: "6.6.6.6"}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|