From 7b2c4460ffdd1f29b5dc1c69324dcf5be41840c1 Mon Sep 17 00:00:00 2001 From: cskh Date: Fri, 14 Oct 2022 20:23:07 -0400 Subject: [PATCH] fix unit test --- agent/xds/clusters_test.go | 66 ++++++++----------- ...rvice-max-connections.envoy-1-20-x.golden} | 0 ...rvice-max-connections.envoy-1-20-x.golden} | 0 ...rvice-max-connections.envoy-1-20-x.golden} | 0 4 files changed, 29 insertions(+), 37 deletions(-) rename agent/xds/testdata/clusters/{ingress-with-defaults-service-max-connections.latest.golden => ingress-with-defaults-service-max-connections.envoy-1-20-x.golden} (100%) rename agent/xds/testdata/clusters/{ingress-with-overwrite-defaults-service-max-connections.latest.golden => ingress-with-overwrite-defaults-service-max-connections.envoy-1-20-x.golden} (100%) rename agent/xds/testdata/clusters/{ingress-with-service-max-connections.latest.golden => ingress-with-service-max-connections.envoy-1-20-x.golden} (100%) diff --git a/agent/xds/clusters_test.go b/agent/xds/clusters_test.go index 8bbb0958a043b..f0b37768f348f 100644 --- a/agent/xds/clusters_test.go +++ b/agent/xds/clusters_test.go @@ -407,49 +407,41 @@ func TestClustersFromSnapshot(t *testing.T) { }, }, { - name: "ingress-with-service-max-connections", - create: func(t testinf.T) *proxycfg.ConfigSnapshot { - return proxycfg.TestConfigSnapshotIngressGateway(t, true, "tcp", - "simple", nil, - func(entry *structs.IngressGatewayConfigEntry) { - entry.Listeners[0].Services[0].MaxConnections = 4096 - }, nil) - }, - }, - { - name: "ingress-with-defaults-service-max-connections", - create: func(t testinf.T) *proxycfg.ConfigSnapshot { - return proxycfg.TestConfigSnapshotIngressGateway(t, true, "tcp", - "simple", nil, - func(entry *structs.IngressGatewayConfigEntry) { - entry.Defaults = &structs.IngressServiceConfig{ - MaxConnections: 2048, - MaxPendingRequests: 512, - MaxConcurrentRequests: 4096, - } - }, nil) + name: "ingress-with-service-max-connections", + create: proxycfg.TestConfigSnapshotIngress, + setup: func(snap *proxycfg.ConfigSnapshot) { + key := proxycfg.IngressListenerKey{ + Protocol: "tcp", + Port: 9191, + } + snap.IngressGateway.Listeners[key].Services[0].MaxConnections = 4096 }, }, { - name: "ingress-with-overwrite-defaults-service-max-connections", - create: func(t testinf.T) *proxycfg.ConfigSnapshot { - return proxycfg.TestConfigSnapshotIngressGateway(t, true, "tcp", - "simple", nil, - func(entry *structs.IngressGatewayConfigEntry) { - entry.Defaults = &structs.IngressServiceConfig{ - MaxConnections: 2048, - MaxPendingRequests: 512, - } - entry.Listeners[0].Services[0].MaxConnections = 4096 - entry.Listeners[0].Services[0].MaxPendingRequests = 2048 - }, nil) + name: "ingress-with-defaults-service-max-connections", + create: proxycfg.TestConfigSnapshotIngress, + setup: func(snap *proxycfg.ConfigSnapshot) { + snap.IngressGateway.Defaults = structs.IngressServiceConfig{ + MaxConnections: 2048, + MaxPendingRequests: 512, + MaxConcurrentRequests: 4096, + } }, }, { - name: "ingress-with-chain-external-sni", - create: func(t testinf.T) *proxycfg.ConfigSnapshot { - return proxycfg.TestConfigSnapshotIngressGateway(t, true, "tcp", - "external-sni", nil, nil, nil) + name: "ingress-with-overwrite-defaults-service-max-connections", + create: proxycfg.TestConfigSnapshotIngress, + setup: func(snap *proxycfg.ConfigSnapshot) { + snap.IngressGateway.Defaults = structs.IngressServiceConfig{ + MaxConnections: 2048, + MaxPendingRequests: 512, + } + key := proxycfg.IngressListenerKey{ + Protocol: "tcp", + Port: 9191, + } + snap.IngressGateway.Listeners[key].Services[0].MaxConnections = 4096 + snap.IngressGateway.Listeners[key].Services[0].MaxPendingRequests = 2048 }, }, { diff --git a/agent/xds/testdata/clusters/ingress-with-defaults-service-max-connections.latest.golden b/agent/xds/testdata/clusters/ingress-with-defaults-service-max-connections.envoy-1-20-x.golden similarity index 100% rename from agent/xds/testdata/clusters/ingress-with-defaults-service-max-connections.latest.golden rename to agent/xds/testdata/clusters/ingress-with-defaults-service-max-connections.envoy-1-20-x.golden diff --git a/agent/xds/testdata/clusters/ingress-with-overwrite-defaults-service-max-connections.latest.golden b/agent/xds/testdata/clusters/ingress-with-overwrite-defaults-service-max-connections.envoy-1-20-x.golden similarity index 100% rename from agent/xds/testdata/clusters/ingress-with-overwrite-defaults-service-max-connections.latest.golden rename to agent/xds/testdata/clusters/ingress-with-overwrite-defaults-service-max-connections.envoy-1-20-x.golden diff --git a/agent/xds/testdata/clusters/ingress-with-service-max-connections.latest.golden b/agent/xds/testdata/clusters/ingress-with-service-max-connections.envoy-1-20-x.golden similarity index 100% rename from agent/xds/testdata/clusters/ingress-with-service-max-connections.latest.golden rename to agent/xds/testdata/clusters/ingress-with-service-max-connections.envoy-1-20-x.golden