Skip to content

Commit

Permalink
Backport of Refactor xDS tests into release/1.15.x (#16741)
Browse files Browse the repository at this point in the history
* backport of commit ed4a98f

* add merge function

---------

Co-authored-by: Eric <eric@haberkorn.co>
  • Loading branch information
1 parent 83d26bc commit 9d636aa
Show file tree
Hide file tree
Showing 25 changed files with 791 additions and 633 deletions.
4 changes: 2 additions & 2 deletions agent/agent_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestAgent_Services_ExternalConnectProxy(t *testing.T) {
Port: 5000,
Proxy: structs.ConnectProxyConfig{
DestinationServiceName: "db",
Upstreams: structs.TestUpstreams(t),
Upstreams: structs.TestUpstreams(t, false),
},
}
a.State.AddServiceWithChecks(srv1, nil, "", false)
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestAgent_Services_Sidecar(t *testing.T) {
LocallyRegisteredAsSidecar: true,
Proxy: structs.ConnectProxyConfig{
DestinationServiceName: "db",
Upstreams: structs.TestUpstreams(t),
Upstreams: structs.TestUpstreams(t, false),
Mode: structs.ProxyModeTransparent,
TransparentProxy: structs.TransparentProxyConfig{
OutboundListenerPort: 10101,
Expand Down
2 changes: 1 addition & 1 deletion agent/proxycfg/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestManager_BasicLifecycle(t *testing.T) {
})
}

upstreams := structs.TestUpstreams(t)
upstreams := structs.TestUpstreams(t, false)
for i := range upstreams {
upstreams[i].DestinationNamespace = structs.IntentionDefaultNamespace
upstreams[i].DestinationPartition = api.PartitionDefaultName
Expand Down
14 changes: 7 additions & 7 deletions agent/proxycfg/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func TestGatewayServiceGroupBarDC1(t testing.T) structs.CheckServiceNodes {
},
Proxy: structs.ConnectProxyConfig{
DestinationServiceName: "bar",
Upstreams: structs.TestUpstreams(t),
Upstreams: structs.TestUpstreams(t, false),
},
},
},
Expand All @@ -573,7 +573,7 @@ func TestGatewayServiceGroupBarDC1(t testing.T) structs.CheckServiceNodes {
},
Proxy: structs.ConnectProxyConfig{
DestinationServiceName: "bar",
Upstreams: structs.TestUpstreams(t),
Upstreams: structs.TestUpstreams(t, false),
},
},
},
Expand All @@ -594,7 +594,7 @@ func TestGatewayServiceGroupBarDC1(t testing.T) structs.CheckServiceNodes {
},
Proxy: structs.ConnectProxyConfig{
DestinationServiceName: "bar",
Upstreams: structs.TestUpstreams(t),
Upstreams: structs.TestUpstreams(t, false),
},
},
},
Expand All @@ -620,7 +620,7 @@ func TestGatewayServiceGroupFooDC1(t testing.T) structs.CheckServiceNodes {
},
Proxy: structs.ConnectProxyConfig{
DestinationServiceName: "foo",
Upstreams: structs.TestUpstreams(t),
Upstreams: structs.TestUpstreams(t, false),
},
},
},
Expand All @@ -641,7 +641,7 @@ func TestGatewayServiceGroupFooDC1(t testing.T) structs.CheckServiceNodes {
},
Proxy: structs.ConnectProxyConfig{
DestinationServiceName: "foo",
Upstreams: structs.TestUpstreams(t),
Upstreams: structs.TestUpstreams(t, false),
},
},
},
Expand All @@ -662,7 +662,7 @@ func TestGatewayServiceGroupFooDC1(t testing.T) structs.CheckServiceNodes {
},
Proxy: structs.ConnectProxyConfig{
DestinationServiceName: "foo",
Upstreams: structs.TestUpstreams(t),
Upstreams: structs.TestUpstreams(t, false),
},
},
},
Expand All @@ -683,7 +683,7 @@ func TestGatewayServiceGroupFooDC1(t testing.T) structs.CheckServiceNodes {
},
Proxy: structs.ConnectProxyConfig{
DestinationServiceName: "foo",
Upstreams: structs.TestUpstreams(t),
Upstreams: structs.TestUpstreams(t, false),
},
},
Checks: structs.HealthChecks{
Expand Down
2 changes: 1 addition & 1 deletion agent/proxycfg/testing_api_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestConfigSnapshotAPIGateway(
})
}

upstreams := structs.TestUpstreams(t)
upstreams := structs.TestUpstreams(t, false)

baseEvents = testSpliceEvents(baseEvents, setupTestVariationConfigEntriesAndSnapshot(
t, variation, upstreams, additionalEntries...,
Expand Down
14 changes: 11 additions & 3 deletions agent/proxycfg/testing_connect_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/mitchellh/go-testing-interface"
"github.com/stretchr/testify/assert"

"github.com/hashicorp/consul/acl"
"github.com/hashicorp/consul/agent/connect"
"github.com/hashicorp/consul/agent/consul/discoverychain"
"github.com/hashicorp/consul/agent/structs"
Expand All @@ -23,7 +24,7 @@ func TestConfigSnapshot(t testing.T, nsFn func(ns *structs.NodeService), extraUp
assert.True(t, dbChain.Default)

var (
upstreams = structs.TestUpstreams(t)
upstreams = structs.TestUpstreams(t, false)
dbUpstream = upstreams[0]
geoUpstream = upstreams[1]

Expand Down Expand Up @@ -93,19 +94,25 @@ func TestConfigSnapshot(t testing.T, nsFn func(ns *structs.NodeService), extraUp
func TestConfigSnapshotDiscoveryChain(
t testing.T,
variation string,
enterprise bool,
nsFn func(ns *structs.NodeService),
extraUpdates []UpdateEvent,
additionalEntries ...structs.ConfigEntry,
) *ConfigSnapshot {
roots, leaf := TestCerts(t)

var entMeta acl.EnterpriseMeta
if enterprise {
entMeta = acl.NewEnterpriseMetaWithPartition("ap1", "ns1")
}

var (
upstreams = structs.TestUpstreams(t)
upstreams = structs.TestUpstreams(t, enterprise)
geoUpstream = upstreams[1]

geoUID = NewUpstreamID(&geoUpstream)

webSN = structs.ServiceIDString("web", nil)
webSN = structs.ServiceIDString("web", &entMeta)
)

baseEvents := testSpliceEvents([]UpdateEvent{
Expand Down Expand Up @@ -157,6 +164,7 @@ func TestConfigSnapshotDiscoveryChain(
},
Meta: nil,
TaggedAddresses: nil,
EnterpriseMeta: entMeta,
}, nsFn, nil, testSpliceEvents(baseEvents, extraUpdates))
}

Expand Down
2 changes: 1 addition & 1 deletion agent/proxycfg/testing_ingress_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestConfigSnapshotIngressGateway(
},
}})

upstreams := structs.TestUpstreams(t)
upstreams := structs.TestUpstreams(t, false)
upstreams = structs.Upstreams{upstreams[0]} // just keep 'db'

baseEvents = testSpliceEvents(baseEvents, setupTestVariationConfigEntriesAndSnapshot(
Expand Down
Loading

0 comments on commit 9d636aa

Please sign in to comment.