11package pl.allegro.tech.servicemesh.envoycontrol
22
3- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.AGGREGATE_CLUSTER_NAME
4- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.CLUSTER_NAME1
5- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.CLUSTER_NAME2
6- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.DEFAULT_DISCOVERY_SERVICE_NAME
7- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.DEFAULT_SERVICE_NAME
8- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.EGRESS_HOST
9- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.EGRESS_PORT
10- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.INGRESS_HOST
11- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.INGRESS_PORT
12- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.MAIN_CLUSTER_NAME
13- import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.SECONDARY_CLUSTER_NAME
143import io.envoyproxy.controlplane.cache.SnapshotResources
154import io.envoyproxy.envoy.config.cluster.v3.Cluster
165import io.envoyproxy.envoy.config.core.v3.Metadata
@@ -31,7 +20,6 @@ import pl.allegro.tech.servicemesh.envoycontrol.groups.Outgoing
3120import pl.allegro.tech.servicemesh.envoycontrol.groups.ProxySettings
3221import pl.allegro.tech.servicemesh.envoycontrol.groups.ServicesGroup
3322import pl.allegro.tech.servicemesh.envoycontrol.groups.with
34- import pl.allegro.tech.servicemesh.envoycontrol.snapshot.ClusterWeights
3523import pl.allegro.tech.servicemesh.envoycontrol.snapshot.EnvoySnapshotFactory
3624import pl.allegro.tech.servicemesh.envoycontrol.snapshot.GlobalSnapshot
3725import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotProperties
@@ -45,6 +33,18 @@ import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes.EnvoyEg
4533import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes.EnvoyIngressRoutesFactory
4634import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes.ServiceTagMetadataGenerator
4735import pl.allegro.tech.servicemesh.envoycontrol.snapshot.serviceDependencies
36+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.AGGREGATE_CLUSTER_NAME
37+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.CLUSTER_NAME1
38+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.CLUSTER_NAME2
39+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.DEFAULT_CLUSTER_WEIGHTS
40+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.DEFAULT_DISCOVERY_SERVICE_NAME
41+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.DEFAULT_SERVICE_NAME
42+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.EGRESS_HOST
43+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.EGRESS_PORT
44+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.INGRESS_HOST
45+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.INGRESS_PORT
46+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.MAIN_CLUSTER_NAME
47+ import pl.allegro.tech.servicemesh.envoycontrol.utils.TestData.SECONDARY_CLUSTER_NAME
4848import pl.allegro.tech.servicemesh.envoycontrol.utils.createCluster
4949import pl.allegro.tech.servicemesh.envoycontrol.utils.createClusterConfigurations
5050import pl.allegro.tech.servicemesh.envoycontrol.utils.createLoadAssignments
@@ -57,15 +57,9 @@ class EnvoySnapshotFactoryTest {
5757 const val FORCE_TRAFFIC_ZONE = " dc2"
5858 }
5959
60- private val defaultClusterWeights = ClusterWeights ().apply {
61- mainClusterWeight = 50
62- secondaryClusterWeight = 50
63- }
64-
6560 private val snapshotPropertiesWithWeights = SnapshotProperties ().also {
66- it.dynamicListeners.enabled = false
6761 it.loadBalancing.trafficSplitting.serviceByWeightsProperties = mapOf (
68- DEFAULT_SERVICE_NAME to defaultClusterWeights
62+ DEFAULT_SERVICE_NAME to DEFAULT_CLUSTER_WEIGHTS
6963 )
7064 it.loadBalancing.trafficSplitting.zoneName = FORCE_TRAFFIC_ZONE
7165 }
@@ -273,9 +267,8 @@ class EnvoySnapshotFactoryTest {
273267 fun `should not create traffic splitting configuration when zone condition isn't complied` () {
274268 // given
275269 val defaultProperties = SnapshotProperties ().also {
276- it.dynamicListeners.enabled = false
277270 it.loadBalancing.trafficSplitting.serviceByWeightsProperties = mapOf (
278- DEFAULT_SERVICE_NAME to defaultClusterWeights
271+ DEFAULT_SERVICE_NAME to DEFAULT_CLUSTER_WEIGHTS
279272 )
280273 it.loadBalancing.trafficSplitting.zoneName = " not-matching-dc"
281274 }
@@ -318,7 +311,8 @@ class EnvoySnapshotFactoryTest {
318311
319312 // then
320313 assertThat(snapshot.clusters().resources())
321- .containsKeys(MAIN_CLUSTER_NAME ,
314+ .containsKeys(
315+ MAIN_CLUSTER_NAME ,
322316 SECONDARY_CLUSTER_NAME ,
323317 AGGREGATE_CLUSTER_NAME ,
324318 CLUSTER_NAME2 ,
0 commit comments