|
|
|
@ -274,7 +274,7 @@ public class XdsNameResolverTest {
|
|
|
|
.authorities(
|
|
|
|
.authorities(
|
|
|
|
ImmutableMap.of(targetAuthority, AuthorityInfo.create(
|
|
|
|
ImmutableMap.of(targetAuthority, AuthorityInfo.create(
|
|
|
|
"xdstp://" + targetAuthority + "/envoy.config.listener.v3.Listener/%s?foo=1&bar=2",
|
|
|
|
"xdstp://" + targetAuthority + "/envoy.config.listener.v3.Listener/%s?foo=1&bar=2",
|
|
|
|
ImmutableList.<ServerInfo>of(ServerInfo.create(
|
|
|
|
ImmutableList.of(ServerInfo.create(
|
|
|
|
"td.googleapis.com", InsecureChannelCredentials.create(), true)))))
|
|
|
|
"td.googleapis.com", InsecureChannelCredentials.create(), true)))))
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
expectedLdsResourceName = "xdstp://xds.authority.com/envoy.config.listener.v3.Listener/"
|
|
|
|
expectedLdsResourceName = "xdstp://xds.authority.com/envoy.config.listener.v3.Listener/"
|
|
|
|
@ -299,12 +299,12 @@ public class XdsNameResolverTest {
|
|
|
|
public void resolving_ldsResourceUpdateRdsName() {
|
|
|
|
public void resolving_ldsResourceUpdateRdsName() {
|
|
|
|
Route route1 = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
Route route1 = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
Route route2 = Route.forAction(RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
Route route2 = Route.forAction(RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(20L), null),
|
|
|
|
cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(20L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
|
|
|
|
|
|
|
|
resolver.start(mockListener);
|
|
|
|
resolver.start(mockListener);
|
|
|
|
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
|
|
|
|
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
|
|
|
|
@ -313,7 +313,7 @@ public class XdsNameResolverTest {
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
|
|
|
|
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
|
|
|
|
Collections.singletonList(route1),
|
|
|
|
Collections.singletonList(route1),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost));
|
|
|
|
xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
assertServiceConfigForLoadBalancingConfig(
|
|
|
|
assertServiceConfigForLoadBalancingConfig(
|
|
|
|
@ -329,7 +329,7 @@ public class XdsNameResolverTest {
|
|
|
|
virtualHost =
|
|
|
|
virtualHost =
|
|
|
|
VirtualHost.create("virtualhost-alter", Collections.singletonList(AUTHORITY),
|
|
|
|
VirtualHost.create("virtualhost-alter", Collections.singletonList(AUTHORITY),
|
|
|
|
Collections.singletonList(route2),
|
|
|
|
Collections.singletonList(route2),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
xdsClient.deliverRdsUpdate(alternativeRdsResource, Collections.singletonList(virtualHost));
|
|
|
|
xdsClient.deliverRdsUpdate(alternativeRdsResource, Collections.singletonList(virtualHost));
|
|
|
|
// Two new service config updates triggered:
|
|
|
|
// Two new service config updates triggered:
|
|
|
|
// - with load balancing config being able to select cluster1 and cluster2
|
|
|
|
// - with load balancing config being able to select cluster1 and cluster2
|
|
|
|
@ -357,8 +357,8 @@ public class XdsNameResolverTest {
|
|
|
|
public void resolving_ldsResourceRevokedAndAddedBack() {
|
|
|
|
public void resolving_ldsResourceRevokedAndAddedBack() {
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
|
|
|
|
|
|
|
|
resolver.start(mockListener);
|
|
|
|
resolver.start(mockListener);
|
|
|
|
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
|
|
|
|
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
|
|
|
|
@ -367,7 +367,7 @@ public class XdsNameResolverTest {
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
|
|
|
|
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
|
|
|
|
Collections.singletonList(route),
|
|
|
|
Collections.singletonList(route),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost));
|
|
|
|
xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
assertServiceConfigForLoadBalancingConfig(
|
|
|
|
assertServiceConfigForLoadBalancingConfig(
|
|
|
|
@ -396,8 +396,8 @@ public class XdsNameResolverTest {
|
|
|
|
public void resolving_rdsResourceRevokedAndAddedBack() {
|
|
|
|
public void resolving_rdsResourceRevokedAndAddedBack() {
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
|
|
|
|
|
|
|
|
resolver.start(mockListener);
|
|
|
|
resolver.start(mockListener);
|
|
|
|
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
|
|
|
|
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
|
|
|
|
@ -406,7 +406,7 @@ public class XdsNameResolverTest {
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
|
|
|
|
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
|
|
|
|
Collections.singletonList(route),
|
|
|
|
Collections.singletonList(route),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost));
|
|
|
|
xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
assertServiceConfigForLoadBalancingConfig(
|
|
|
|
assertServiceConfigForLoadBalancingConfig(
|
|
|
|
@ -473,12 +473,12 @@ public class XdsNameResolverTest {
|
|
|
|
public void resolving_matchingVirtualHostNotFound_matchingOverrideAuthority() {
|
|
|
|
public void resolving_matchingVirtualHostNotFound_matchingOverrideAuthority() {
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost.create("virtualhost", Collections.singletonList("random"),
|
|
|
|
VirtualHost.create("virtualhost", Collections.singletonList("random"),
|
|
|
|
Collections.singletonList(route),
|
|
|
|
Collections.singletonList(route),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
|
|
|
|
|
|
|
|
resolver = new XdsNameResolver(null, AUTHORITY, "random",
|
|
|
|
resolver = new XdsNameResolver(null, AUTHORITY, "random",
|
|
|
|
serviceConfigParser, syncContext, scheduler,
|
|
|
|
serviceConfigParser, syncContext, scheduler,
|
|
|
|
@ -496,12 +496,12 @@ public class XdsNameResolverTest {
|
|
|
|
public void resolving_matchingVirtualHostNotFound_notMatchingOverrideAuthority() {
|
|
|
|
public void resolving_matchingVirtualHostNotFound_notMatchingOverrideAuthority() {
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
|
|
|
|
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
|
|
|
|
Collections.singletonList(route),
|
|
|
|
Collections.singletonList(route),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
|
|
|
|
|
|
|
|
resolver = new XdsNameResolver(null, AUTHORITY, "random",
|
|
|
|
resolver = new XdsNameResolver(null, AUTHORITY, "random",
|
|
|
|
serviceConfigParser, syncContext, scheduler,
|
|
|
|
serviceConfigParser, syncContext, scheduler,
|
|
|
|
@ -543,19 +543,19 @@ public class XdsNameResolverTest {
|
|
|
|
private List<VirtualHost> buildUnmatchedVirtualHosts() {
|
|
|
|
private List<VirtualHost> buildUnmatchedVirtualHosts() {
|
|
|
|
Route route1 = Route.forAction(RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
Route route1 = Route.forAction(RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
Route route2 = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
Route route2 = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
return Arrays.asList(
|
|
|
|
return Arrays.asList(
|
|
|
|
VirtualHost.create("virtualhost-foo", Collections.singletonList("hello.googleapis.com"),
|
|
|
|
VirtualHost.create("virtualhost-foo", Collections.singletonList("hello.googleapis.com"),
|
|
|
|
Collections.singletonList(route1),
|
|
|
|
Collections.singletonList(route1),
|
|
|
|
ImmutableMap.<String, FilterConfig>of()),
|
|
|
|
ImmutableMap.of()),
|
|
|
|
VirtualHost.create("virtualhost-bar", Collections.singletonList("hi.googleapis.com"),
|
|
|
|
VirtualHost.create("virtualhost-bar", Collections.singletonList("hi.googleapis.com"),
|
|
|
|
Collections.singletonList(route2),
|
|
|
|
Collections.singletonList(route2),
|
|
|
|
ImmutableMap.<String, FilterConfig>of()));
|
|
|
|
ImmutableMap.of()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@ -564,11 +564,11 @@ public class XdsNameResolverTest {
|
|
|
|
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
|
|
|
|
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1, Collections.<HashPolicy>emptyList(), null, null), // per-route timeout unset
|
|
|
|
cluster1, Collections.emptyList(), null, null), // per-route timeout unset
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
VirtualHost virtualHost = VirtualHost.create("does not matter",
|
|
|
|
VirtualHost virtualHost = VirtualHost.create("does not matter",
|
|
|
|
Collections.singletonList(AUTHORITY), Collections.singletonList(route),
|
|
|
|
Collections.singletonList(AUTHORITY), Collections.singletonList(route),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
xdsClient.deliverLdsUpdate(0L, Collections.singletonList(virtualHost));
|
|
|
|
xdsClient.deliverLdsUpdate(0L, Collections.singletonList(virtualHost));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
@ -582,11 +582,11 @@ public class XdsNameResolverTest {
|
|
|
|
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
|
|
|
|
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1, Collections.<HashPolicy>emptyList(), null, null), // per-route timeout unset
|
|
|
|
cluster1, Collections.emptyList(), null, null), // per-route timeout unset
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
VirtualHost virtualHost = VirtualHost.create("does not matter",
|
|
|
|
VirtualHost virtualHost = VirtualHost.create("does not matter",
|
|
|
|
Collections.singletonList(AUTHORITY), Collections.singletonList(route),
|
|
|
|
Collections.singletonList(AUTHORITY), Collections.singletonList(route),
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
xdsClient.deliverLdsUpdate(TimeUnit.SECONDS.toNanos(5L),
|
|
|
|
xdsClient.deliverLdsUpdate(TimeUnit.SECONDS.toNanos(5L),
|
|
|
|
Collections.singletonList(virtualHost));
|
|
|
|
Collections.singletonList(virtualHost));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
@ -612,10 +612,10 @@ public class XdsNameResolverTest {
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1,
|
|
|
|
cluster1,
|
|
|
|
Collections.<HashPolicy>emptyList(),
|
|
|
|
Collections.emptyList(),
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
retryPolicy),
|
|
|
|
retryPolicy),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
@ -668,12 +668,12 @@ public class XdsNameResolverTest {
|
|
|
|
Arrays.asList(
|
|
|
|
Arrays.asList(
|
|
|
|
Route.forNonForwardingAction(
|
|
|
|
Route.forNonForwardingAction(
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
ImmutableMap.<String, FilterConfig>of()),
|
|
|
|
ImmutableMap.of()),
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(cluster2, Collections.<HashPolicy>emptyList(),
|
|
|
|
RouteAction.forCluster(cluster2, Collections.emptyList(),
|
|
|
|
TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
assertThat(result.getAddresses()).isEmpty();
|
|
|
|
assertThat(result.getAddresses()).isEmpty();
|
|
|
|
@ -709,7 +709,7 @@ public class XdsNameResolverTest {
|
|
|
|
HashPolicy.forHeader(false, "custom-key", null, null)),
|
|
|
|
HashPolicy.forHeader(false, "custom-key", null, null)),
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
InternalConfigSelector configSelector =
|
|
|
|
InternalConfigSelector configSelector =
|
|
|
|
resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
@ -743,7 +743,7 @@ public class XdsNameResolverTest {
|
|
|
|
HashPolicy.forHeader(false, "custom-key", Pattern.compile("value"), "val")),
|
|
|
|
HashPolicy.forHeader(false, "custom-key", Pattern.compile("value"), "val")),
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
InternalConfigSelector configSelector =
|
|
|
|
InternalConfigSelector configSelector =
|
|
|
|
resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
@ -782,7 +782,7 @@ public class XdsNameResolverTest {
|
|
|
|
Collections.singletonList(HashPolicy.forChannelId(false)),
|
|
|
|
Collections.singletonList(HashPolicy.forChannelId(false)),
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
InternalConfigSelector configSelector =
|
|
|
|
InternalConfigSelector configSelector =
|
|
|
|
resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
@ -795,7 +795,7 @@ public class XdsNameResolverTest {
|
|
|
|
|
|
|
|
|
|
|
|
// Second call, with no custom header.
|
|
|
|
// Second call, with no custom header.
|
|
|
|
startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
Collections.<String, String>emptyMap(),
|
|
|
|
Collections.emptyMap(),
|
|
|
|
CallOptions.DEFAULT);
|
|
|
|
CallOptions.DEFAULT);
|
|
|
|
long hash2 = testCall.callOptions.getOption(XdsNameResolver.RPC_HASH_KEY);
|
|
|
|
long hash2 = testCall.callOptions.getOption(XdsNameResolver.RPC_HASH_KEY);
|
|
|
|
|
|
|
|
|
|
|
|
@ -817,14 +817,14 @@ public class XdsNameResolverTest {
|
|
|
|
Collections.singletonList(HashPolicy.forChannelId(false)),
|
|
|
|
Collections.singletonList(HashPolicy.forChannelId(false)),
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
configSelector = resolutionResultCaptor.getValue().getAttributes().get(
|
|
|
|
configSelector = resolutionResultCaptor.getValue().getAttributes().get(
|
|
|
|
InternalConfigSelector.KEY);
|
|
|
|
InternalConfigSelector.KEY);
|
|
|
|
|
|
|
|
|
|
|
|
// Third call, with no custom header.
|
|
|
|
// Third call, with no custom header.
|
|
|
|
startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
Collections.<String, String>emptyMap(),
|
|
|
|
Collections.emptyMap(),
|
|
|
|
CallOptions.DEFAULT);
|
|
|
|
CallOptions.DEFAULT);
|
|
|
|
long hash3 = testCall.callOptions.getOption(XdsNameResolver.RPC_HASH_KEY);
|
|
|
|
long hash3 = testCall.callOptions.getOption(XdsNameResolver.RPC_HASH_KEY);
|
|
|
|
|
|
|
|
|
|
|
|
@ -846,15 +846,15 @@ public class XdsNameResolverTest {
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
"another-cluster", Collections.<HashPolicy>emptyList(),
|
|
|
|
"another-cluster", Collections.emptyList(),
|
|
|
|
TimeUnit.SECONDS.toNanos(20L), null),
|
|
|
|
TimeUnit.SECONDS.toNanos(20L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of()),
|
|
|
|
ImmutableMap.of()),
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
// Updated service config still contains cluster1 while it is removed resource. New calls no
|
|
|
|
// Updated service config still contains cluster1 while it is removed resource. New calls no
|
|
|
|
@ -886,15 +886,15 @@ public class XdsNameResolverTest {
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
"another-cluster", Collections.<HashPolicy>emptyList(),
|
|
|
|
"another-cluster", Collections.emptyList(),
|
|
|
|
TimeUnit.SECONDS.toNanos(20L), null),
|
|
|
|
TimeUnit.SECONDS.toNanos(20L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of()),
|
|
|
|
ImmutableMap.of()),
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
// Two consecutive service config updates: one for removing clcuster1,
|
|
|
|
// Two consecutive service config updates: one for removing clcuster1,
|
|
|
|
// one for adding "another=cluster".
|
|
|
|
// one for adding "another=cluster".
|
|
|
|
verify(mockListener, times(2)).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener, times(2)).onResult(resolutionResultCaptor.capture());
|
|
|
|
@ -922,15 +922,15 @@ public class XdsNameResolverTest {
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
"another-cluster", Collections.<HashPolicy>emptyList(),
|
|
|
|
"another-cluster", Collections.emptyList(),
|
|
|
|
TimeUnit.SECONDS.toNanos(20L), null),
|
|
|
|
TimeUnit.SECONDS.toNanos(20L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of()),
|
|
|
|
ImmutableMap.of()),
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster2, Collections.<HashPolicy>emptyList(),
|
|
|
|
cluster2, Collections.emptyList(),
|
|
|
|
TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
|
|
|
|
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
@ -943,15 +943,15 @@ public class XdsNameResolverTest {
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
"another-cluster", Collections.<HashPolicy>emptyList(),
|
|
|
|
"another-cluster", Collections.emptyList(),
|
|
|
|
TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of()),
|
|
|
|
ImmutableMap.of()),
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster2, Collections.<HashPolicy>emptyList(),
|
|
|
|
cluster2, Collections.emptyList(),
|
|
|
|
TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
TimeUnit.SECONDS.toNanos(15L), null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verifyNoMoreInteractions(mockListener); // no cluster added/deleted
|
|
|
|
verifyNoMoreInteractions(mockListener); // no cluster added/deleted
|
|
|
|
assertCallSelectClusterResult(call1, configSelector, "another-cluster", 15.0);
|
|
|
|
assertCallSelectClusterResult(call1, configSelector, "another-cluster", 15.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -966,23 +966,23 @@ public class XdsNameResolverTest {
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
xdsClient.deliverLdsUpdate(
|
|
|
|
xdsClient.deliverLdsUpdate(
|
|
|
|
Arrays.asList(
|
|
|
|
Arrays.asList(
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of()),
|
|
|
|
ImmutableMap.of()),
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
testCall.deliverErrorStatus();
|
|
|
|
testCall.deliverErrorStatus();
|
|
|
|
verifyNoMoreInteractions(mockListener);
|
|
|
|
verifyNoMoreInteractions(mockListener);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -999,13 +999,13 @@ public class XdsNameResolverTest {
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forWeightedClusters(
|
|
|
|
RouteAction.forWeightedClusters(
|
|
|
|
Arrays.asList(
|
|
|
|
Arrays.asList(
|
|
|
|
ClusterWeight.create(cluster1, 20, ImmutableMap.<String, FilterConfig>of()),
|
|
|
|
ClusterWeight.create(cluster1, 20, ImmutableMap.of()),
|
|
|
|
ClusterWeight.create(
|
|
|
|
ClusterWeight.create(
|
|
|
|
cluster2, 80, ImmutableMap.<String, FilterConfig>of())),
|
|
|
|
cluster2, 80, ImmutableMap.of())),
|
|
|
|
Collections.<HashPolicy>emptyList(),
|
|
|
|
Collections.emptyList(),
|
|
|
|
TimeUnit.SECONDS.toNanos(20L),
|
|
|
|
TimeUnit.SECONDS.toNanos(20L),
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
assertThat(result.getAddresses()).isEmpty();
|
|
|
|
assertThat(result.getAddresses()).isEmpty();
|
|
|
|
@ -1031,10 +1031,10 @@ public class XdsNameResolverTest {
|
|
|
|
"rls-plugin-foo",
|
|
|
|
"rls-plugin-foo",
|
|
|
|
RlsPluginConfig.create(
|
|
|
|
RlsPluginConfig.create(
|
|
|
|
ImmutableMap.of("lookupService", "rls-cbt.googleapis.com"))),
|
|
|
|
ImmutableMap.of("lookupService", "rls-cbt.googleapis.com"))),
|
|
|
|
Collections.<HashPolicy>emptyList(),
|
|
|
|
Collections.emptyList(),
|
|
|
|
TimeUnit.SECONDS.toNanos(20L),
|
|
|
|
TimeUnit.SECONDS.toNanos(20L),
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
assertThat(result.getAddresses()).isEmpty();
|
|
|
|
assertThat(result.getAddresses()).isEmpty();
|
|
|
|
@ -1078,11 +1078,11 @@ public class XdsNameResolverTest {
|
|
|
|
RlsPluginConfig.create(
|
|
|
|
RlsPluginConfig.create(
|
|
|
|
// changed
|
|
|
|
// changed
|
|
|
|
ImmutableMap.of("lookupService", "rls-cbt-2.googleapis.com"))),
|
|
|
|
ImmutableMap.of("lookupService", "rls-cbt-2.googleapis.com"))),
|
|
|
|
Collections.<HashPolicy>emptyList(),
|
|
|
|
Collections.emptyList(),
|
|
|
|
// changed
|
|
|
|
// changed
|
|
|
|
TimeUnit.SECONDS.toNanos(30L),
|
|
|
|
TimeUnit.SECONDS.toNanos(30L),
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener, times(2)).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener, times(2)).onResult(resolutionResultCaptor.capture());
|
|
|
|
ResolutionResult result2 = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result2 = resolutionResultCaptor.getValue();
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@ -1136,7 +1136,7 @@ public class XdsNameResolverTest {
|
|
|
|
ClientInterceptor interceptor = result.getInterceptor();
|
|
|
|
ClientInterceptor interceptor = result.getInterceptor();
|
|
|
|
ClientCall<Void, Void> clientCall = interceptor.interceptCall(
|
|
|
|
ClientCall<Void, Void> clientCall = interceptor.interceptCall(
|
|
|
|
call.methodDescriptor, CallOptions.DEFAULT, channel);
|
|
|
|
call.methodDescriptor, CallOptions.DEFAULT, channel);
|
|
|
|
clientCall.start(new NoopClientCallListener<Void>(), new Metadata());
|
|
|
|
clientCall.start(new NoopClientCallListener<>(), new Metadata());
|
|
|
|
assertThat(testCall.callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY))
|
|
|
|
assertThat(testCall.callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY))
|
|
|
|
.isEqualTo("cluster:" + expectedCluster);
|
|
|
|
.isEqualTo("cluster:" + expectedCluster);
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@ -1164,7 +1164,7 @@ public class XdsNameResolverTest {
|
|
|
|
ClientInterceptor interceptor = result.getInterceptor();
|
|
|
|
ClientInterceptor interceptor = result.getInterceptor();
|
|
|
|
ClientCall<Void, Void> clientCall = interceptor.interceptCall(
|
|
|
|
ClientCall<Void, Void> clientCall = interceptor.interceptCall(
|
|
|
|
call.methodDescriptor, CallOptions.DEFAULT, channel);
|
|
|
|
call.methodDescriptor, CallOptions.DEFAULT, channel);
|
|
|
|
clientCall.start(new NoopClientCallListener<Void>(), new Metadata());
|
|
|
|
clientCall.start(new NoopClientCallListener<>(), new Metadata());
|
|
|
|
assertThat(testCall.callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY))
|
|
|
|
assertThat(testCall.callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY))
|
|
|
|
.isEqualTo("cluster_specifier_plugin:" + expectedPluginName);
|
|
|
|
.isEqualTo("cluster_specifier_plugin:" + expectedPluginName);
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@ -1186,15 +1186,15 @@ public class XdsNameResolverTest {
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of()),
|
|
|
|
ImmutableMap.of()),
|
|
|
|
Route.forAction(
|
|
|
|
Route.forAction(
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
|
|
|
|
RouteAction.forCluster(
|
|
|
|
RouteAction.forCluster(
|
|
|
|
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
ImmutableMap.<String, FilterConfig>of())));
|
|
|
|
ImmutableMap.of())));
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
verify(mockListener).onResult(resolutionResultCaptor.capture());
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
assertThat(result.getAddresses()).isEmpty();
|
|
|
|
assertThat(result.getAddresses()).isEmpty();
|
|
|
|
@ -1329,7 +1329,7 @@ public class XdsNameResolverTest {
|
|
|
|
4, ImmutableList.of(Code.UNAVAILABLE, Code.CANCELLED), Durations.fromMillis(100),
|
|
|
|
4, ImmutableList.of(Code.UNAVAILABLE, Code.CANCELLED), Durations.fromMillis(100),
|
|
|
|
Durations.fromMillis(200), null);
|
|
|
|
Durations.fromMillis(200), null);
|
|
|
|
RetryPolicy retryPolicyWithEmptyStatusCodes = RetryPolicy.create(
|
|
|
|
RetryPolicy retryPolicyWithEmptyStatusCodes = RetryPolicy.create(
|
|
|
|
4, ImmutableList.<Code>of(), Durations.fromMillis(100), Durations.fromMillis(200), null);
|
|
|
|
4, ImmutableList.of(), Durations.fromMillis(100), Durations.fromMillis(200), null);
|
|
|
|
|
|
|
|
|
|
|
|
// timeout only
|
|
|
|
// timeout only
|
|
|
|
String expectedServiceConfigJson = "{\n"
|
|
|
|
String expectedServiceConfigJson = "{\n"
|
|
|
|
@ -1451,13 +1451,13 @@ public class XdsNameResolverTest {
|
|
|
|
List<Route> routes = Collections.emptyList();
|
|
|
|
List<Route> routes = Collections.emptyList();
|
|
|
|
VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com",
|
|
|
|
VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com",
|
|
|
|
Arrays.asList("a.googleapis.com", "b.googleapis.com"), routes,
|
|
|
|
Arrays.asList("a.googleapis.com", "b.googleapis.com"), routes,
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com",
|
|
|
|
VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com",
|
|
|
|
Collections.singletonList("*.googleapis.com"), routes,
|
|
|
|
Collections.singletonList("*.googleapis.com"), routes,
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
VirtualHost vHost3 = VirtualHost.create("virtualhost03.googleapis.com",
|
|
|
|
VirtualHost vHost3 = VirtualHost.create("virtualhost03.googleapis.com",
|
|
|
|
Collections.singletonList("*"), routes,
|
|
|
|
Collections.singletonList("*"), routes,
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2, vHost3);
|
|
|
|
List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2, vHost3);
|
|
|
|
assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname))
|
|
|
|
assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname))
|
|
|
|
.isEqualTo(vHost1);
|
|
|
|
.isEqualTo(vHost1);
|
|
|
|
@ -1469,13 +1469,13 @@ public class XdsNameResolverTest {
|
|
|
|
List<Route> routes = Collections.emptyList();
|
|
|
|
List<Route> routes = Collections.emptyList();
|
|
|
|
VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com",
|
|
|
|
VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com",
|
|
|
|
Arrays.asList("*.googleapis.com", "b.googleapis.com"), routes,
|
|
|
|
Arrays.asList("*.googleapis.com", "b.googleapis.com"), routes,
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com",
|
|
|
|
VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com",
|
|
|
|
Collections.singletonList("a.googleapis.*"), routes,
|
|
|
|
Collections.singletonList("a.googleapis.*"), routes,
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
VirtualHost vHost3 = VirtualHost.create("virtualhost03.googleapis.com",
|
|
|
|
VirtualHost vHost3 = VirtualHost.create("virtualhost03.googleapis.com",
|
|
|
|
Collections.singletonList("*"), routes,
|
|
|
|
Collections.singletonList("*"), routes,
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2, vHost3);
|
|
|
|
List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2, vHost3);
|
|
|
|
assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname))
|
|
|
|
assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname))
|
|
|
|
.isEqualTo(vHost1);
|
|
|
|
.isEqualTo(vHost1);
|
|
|
|
@ -1487,13 +1487,13 @@ public class XdsNameResolverTest {
|
|
|
|
List<Route> routes = Collections.emptyList();
|
|
|
|
List<Route> routes = Collections.emptyList();
|
|
|
|
VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com",
|
|
|
|
VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com",
|
|
|
|
Collections.singletonList("*"), routes,
|
|
|
|
Collections.singletonList("*"), routes,
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com",
|
|
|
|
VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com",
|
|
|
|
Collections.singletonList("b.googleapis.com"), routes,
|
|
|
|
Collections.singletonList("b.googleapis.com"), routes,
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2);
|
|
|
|
List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2);
|
|
|
|
assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname))
|
|
|
|
assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname))
|
|
|
|
.isEqualTo(vHost1);;
|
|
|
|
.isEqualTo(vHost1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@ -1513,7 +1513,7 @@ public class XdsNameResolverTest {
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
// no header abort key provided in metadata, rpc should succeed
|
|
|
|
// no header abort key provided in metadata, rpc should succeed
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcSucceeded(observer);
|
|
|
|
verifyRpcSucceeded(observer);
|
|
|
|
// header abort http status key provided, rpc should fail
|
|
|
|
// header abort http status key provided, rpc should fail
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
@ -1582,7 +1582,7 @@ public class XdsNameResolverTest {
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcFailed(
|
|
|
|
verifyRpcFailed(
|
|
|
|
observer,
|
|
|
|
observer,
|
|
|
|
Status.UNAUTHENTICATED.withDescription(
|
|
|
|
Status.UNAUTHENTICATED.withDescription(
|
|
|
|
@ -1600,7 +1600,7 @@ public class XdsNameResolverTest {
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcSucceeded(observer);
|
|
|
|
verifyRpcSucceeded(observer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1619,7 +1619,7 @@ public class XdsNameResolverTest {
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
// no header delay key provided in metadata, rpc should succeed immediately
|
|
|
|
// no header delay key provided in metadata, rpc should succeed immediately
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcSucceeded(observer);
|
|
|
|
verifyRpcSucceeded(observer);
|
|
|
|
// header delay key provided, rpc should be delayed
|
|
|
|
// header delay key provided, rpc should be delayed
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
@ -1659,7 +1659,7 @@ public class XdsNameResolverTest {
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcDelayed(observer, 5000L);
|
|
|
|
verifyRpcDelayed(observer, 5000L);
|
|
|
|
|
|
|
|
|
|
|
|
// fixed delay, fix rate = 40%
|
|
|
|
// fixed delay, fix rate = 40%
|
|
|
|
@ -1672,7 +1672,7 @@ public class XdsNameResolverTest {
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcSucceeded(observer);
|
|
|
|
verifyRpcSucceeded(observer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1694,15 +1694,15 @@ public class XdsNameResolverTest {
|
|
|
|
// Send two calls, then the first call should delayed and the second call should not be delayed
|
|
|
|
// Send two calls, then the first call should delayed and the second call should not be delayed
|
|
|
|
// because maxActiveFaults is exceeded.
|
|
|
|
// because maxActiveFaults is exceeded.
|
|
|
|
ClientCall.Listener<Void> observer1 = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
ClientCall.Listener<Void> observer1 = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
assertThat(testCall).isNull();
|
|
|
|
assertThat(testCall).isNull();
|
|
|
|
ClientCall.Listener<Void> observer2 = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
ClientCall.Listener<Void> observer2 = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcSucceeded(observer2);
|
|
|
|
verifyRpcSucceeded(observer2);
|
|
|
|
verifyRpcDelayed(observer1, 5000L);
|
|
|
|
verifyRpcDelayed(observer1, 5000L);
|
|
|
|
// Once all calls are finished, new call should be delayed.
|
|
|
|
// Once all calls are finished, new call should be delayed.
|
|
|
|
ClientCall.Listener<Void> observer3 = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
ClientCall.Listener<Void> observer3 = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcDelayed(observer3, 5000L);
|
|
|
|
verifyRpcDelayed(observer3, 5000L);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1728,7 +1728,7 @@ public class XdsNameResolverTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT.withDeadline(
|
|
|
|
configSelector, Collections.emptyMap(), CallOptions.DEFAULT.withDeadline(
|
|
|
|
Deadline.after(4000, TimeUnit.NANOSECONDS, fakeTicker)));
|
|
|
|
Deadline.after(4000, TimeUnit.NANOSECONDS, fakeTicker)));
|
|
|
|
assertThat(testCall).isNull();
|
|
|
|
assertThat(testCall).isNull();
|
|
|
|
verifyRpcDelayedThenAborted(observer, 4000L, Status.DEADLINE_EXCEEDED.withDescription(
|
|
|
|
verifyRpcDelayedThenAborted(observer, 4000L, Status.DEADLINE_EXCEEDED.withDescription(
|
|
|
|
@ -1753,7 +1753,7 @@ public class XdsNameResolverTest {
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcDelayedThenAborted(
|
|
|
|
verifyRpcDelayedThenAborted(
|
|
|
|
observer, 5000L,
|
|
|
|
observer, 5000L,
|
|
|
|
Status.UNAUTHENTICATED.withDescription(
|
|
|
|
Status.UNAUTHENTICATED.withDescription(
|
|
|
|
@ -1782,7 +1782,7 @@ public class XdsNameResolverTest {
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcFailed(
|
|
|
|
verifyRpcFailed(
|
|
|
|
observer, Status.INTERNAL.withDescription("RPC terminated due to fault injection"));
|
|
|
|
observer, Status.INTERNAL.withDescription("RPC terminated due to fault injection"));
|
|
|
|
|
|
|
|
|
|
|
|
@ -1797,7 +1797,7 @@ public class XdsNameResolverTest {
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcFailed(
|
|
|
|
verifyRpcFailed(
|
|
|
|
observer, Status.UNKNOWN.withDescription("RPC terminated due to fault injection"));
|
|
|
|
observer, Status.UNKNOWN.withDescription("RPC terminated due to fault injection"));
|
|
|
|
|
|
|
|
|
|
|
|
@ -1814,7 +1814,7 @@ public class XdsNameResolverTest {
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
result = resolutionResultCaptor.getValue();
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
|
|
|
|
Collections.<String, String>emptyMap(), CallOptions.DEFAULT);
|
|
|
|
Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcFailed(
|
|
|
|
verifyRpcFailed(
|
|
|
|
observer, Status.UNAVAILABLE.withDescription("RPC terminated due to fault injection"));
|
|
|
|
observer, Status.UNAVAILABLE.withDescription("RPC terminated due to fault injection"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1843,7 +1843,7 @@ public class XdsNameResolverTest {
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
ResolutionResult result = resolutionResultCaptor.getValue();
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
|
|
|
|
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT);;
|
|
|
|
configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
|
|
|
|
verifyRpcFailed(
|
|
|
|
verifyRpcFailed(
|
|
|
|
observer, Status.UNKNOWN.withDescription("RPC terminated due to fault injection"));
|
|
|
|
observer, Status.UNKNOWN.withDescription("RPC terminated due to fault injection"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1904,7 +1904,7 @@ public class XdsNameResolverTest {
|
|
|
|
RouteMatch routeMatch1 =
|
|
|
|
RouteMatch routeMatch1 =
|
|
|
|
RouteMatch.create(
|
|
|
|
RouteMatch.create(
|
|
|
|
PathMatcher.fromPath("/FooService/barMethod", true),
|
|
|
|
PathMatcher.fromPath("/FooService/barMethod", true),
|
|
|
|
Collections.<HeaderMatcher>emptyList(), null);
|
|
|
|
Collections.emptyList(), null);
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch1, "/FooService/barMethod", headers, random))
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch1, "/FooService/barMethod", headers, random))
|
|
|
|
.isTrue();
|
|
|
|
.isTrue();
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch1, "/FooService/bazMethod", headers, random))
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch1, "/FooService/bazMethod", headers, random))
|
|
|
|
@ -1913,7 +1913,7 @@ public class XdsNameResolverTest {
|
|
|
|
RouteMatch routeMatch2 =
|
|
|
|
RouteMatch routeMatch2 =
|
|
|
|
RouteMatch.create(
|
|
|
|
RouteMatch.create(
|
|
|
|
PathMatcher.fromPrefix("/FooService/", true),
|
|
|
|
PathMatcher.fromPrefix("/FooService/", true),
|
|
|
|
Collections.<HeaderMatcher>emptyList(), null);
|
|
|
|
Collections.emptyList(), null);
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch2, "/FooService/barMethod", headers, random))
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch2, "/FooService/barMethod", headers, random))
|
|
|
|
.isTrue();
|
|
|
|
.isTrue();
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch2, "/FooService/bazMethod", headers, random))
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch2, "/FooService/bazMethod", headers, random))
|
|
|
|
@ -1924,7 +1924,7 @@ public class XdsNameResolverTest {
|
|
|
|
RouteMatch routeMatch3 =
|
|
|
|
RouteMatch routeMatch3 =
|
|
|
|
RouteMatch.create(
|
|
|
|
RouteMatch.create(
|
|
|
|
PathMatcher.fromRegEx(Pattern.compile(".*Foo.*")),
|
|
|
|
PathMatcher.fromRegEx(Pattern.compile(".*Foo.*")),
|
|
|
|
Collections.<HeaderMatcher>emptyList(), null);
|
|
|
|
Collections.emptyList(), null);
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch3, "/FooService/barMethod", headers, random))
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch3, "/FooService/barMethod", headers, random))
|
|
|
|
.isTrue();
|
|
|
|
.isTrue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1937,14 +1937,14 @@ public class XdsNameResolverTest {
|
|
|
|
RouteMatch routeMatch1 =
|
|
|
|
RouteMatch routeMatch1 =
|
|
|
|
RouteMatch.create(
|
|
|
|
RouteMatch.create(
|
|
|
|
PathMatcher.fromPath("/FooService/barMethod", false),
|
|
|
|
PathMatcher.fromPath("/FooService/barMethod", false),
|
|
|
|
Collections.<HeaderMatcher>emptyList(), null);
|
|
|
|
Collections.emptyList(), null);
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch1, "/fooservice/barmethod", headers, random))
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch1, "/fooservice/barmethod", headers, random))
|
|
|
|
.isTrue();
|
|
|
|
.isTrue();
|
|
|
|
|
|
|
|
|
|
|
|
RouteMatch routeMatch2 =
|
|
|
|
RouteMatch routeMatch2 =
|
|
|
|
RouteMatch.create(
|
|
|
|
RouteMatch.create(
|
|
|
|
PathMatcher.fromPrefix("/FooService", false),
|
|
|
|
PathMatcher.fromPrefix("/FooService", false),
|
|
|
|
Collections.<HeaderMatcher>emptyList(), null);
|
|
|
|
Collections.emptyList(), null);
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch2, "/fooservice/barmethod", headers, random))
|
|
|
|
assertThat(XdsNameResolver.matchRoute(routeMatch2, "/fooservice/barmethod", headers, random))
|
|
|
|
.isTrue();
|
|
|
|
.isTrue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -2122,7 +2122,7 @@ public class XdsNameResolverTest {
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost virtualHost =
|
|
|
|
VirtualHost.create(
|
|
|
|
VirtualHost.create(
|
|
|
|
"virtual-host", Collections.singletonList(expectedLdsResourceName), routes,
|
|
|
|
"virtual-host", Collections.singletonList(expectedLdsResourceName), routes,
|
|
|
|
ImmutableMap.<String, FilterConfig>of());
|
|
|
|
ImmutableMap.of());
|
|
|
|
ldsWatcher.onChanged(LdsUpdate.forApiListener(HttpConnectionManager.forVirtualHosts(
|
|
|
|
ldsWatcher.onChanged(LdsUpdate.forApiListener(HttpConnectionManager.forVirtualHosts(
|
|
|
|
0L, Collections.singletonList(virtualHost), null)));
|
|
|
|
0L, Collections.singletonList(virtualHost), null)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -2140,28 +2140,28 @@ public class XdsNameResolverTest {
|
|
|
|
new NamedFilterConfig(FAULT_FILTER_INSTANCE_NAME, httpFilterFaultConfig),
|
|
|
|
new NamedFilterConfig(FAULT_FILTER_INSTANCE_NAME, httpFilterFaultConfig),
|
|
|
|
new NamedFilterConfig(ROUTER_FILTER_INSTANCE_NAME, RouterFilter.ROUTER_CONFIG));
|
|
|
|
new NamedFilterConfig(ROUTER_FILTER_INSTANCE_NAME, RouterFilter.ROUTER_CONFIG));
|
|
|
|
ImmutableMap<String, FilterConfig> overrideConfig = weightedClusterFaultConfig == null
|
|
|
|
ImmutableMap<String, FilterConfig> overrideConfig = weightedClusterFaultConfig == null
|
|
|
|
? ImmutableMap.<String, FilterConfig>of()
|
|
|
|
? ImmutableMap.of()
|
|
|
|
: ImmutableMap.<String, FilterConfig>of(
|
|
|
|
: ImmutableMap.of(
|
|
|
|
FAULT_FILTER_INSTANCE_NAME, weightedClusterFaultConfig);
|
|
|
|
FAULT_FILTER_INSTANCE_NAME, weightedClusterFaultConfig);
|
|
|
|
ClusterWeight clusterWeight =
|
|
|
|
ClusterWeight clusterWeight =
|
|
|
|
ClusterWeight.create(
|
|
|
|
ClusterWeight.create(
|
|
|
|
cluster, 100,
|
|
|
|
cluster, 100,
|
|
|
|
overrideConfig);
|
|
|
|
overrideConfig);
|
|
|
|
overrideConfig = routeFaultConfig == null
|
|
|
|
overrideConfig = routeFaultConfig == null
|
|
|
|
? ImmutableMap.<String, FilterConfig>of()
|
|
|
|
? ImmutableMap.of()
|
|
|
|
: ImmutableMap.<String, FilterConfig>of(FAULT_FILTER_INSTANCE_NAME, routeFaultConfig);
|
|
|
|
: ImmutableMap.of(FAULT_FILTER_INSTANCE_NAME, routeFaultConfig);
|
|
|
|
Route route = Route.forAction(
|
|
|
|
Route route = Route.forAction(
|
|
|
|
RouteMatch.create(
|
|
|
|
RouteMatch.create(
|
|
|
|
PathMatcher.fromPrefix("/", false), Collections.<HeaderMatcher>emptyList(), null),
|
|
|
|
PathMatcher.fromPrefix("/", false), Collections.emptyList(), null),
|
|
|
|
RouteAction.forWeightedClusters(
|
|
|
|
RouteAction.forWeightedClusters(
|
|
|
|
Collections.singletonList(clusterWeight),
|
|
|
|
Collections.singletonList(clusterWeight),
|
|
|
|
Collections.<HashPolicy>emptyList(),
|
|
|
|
Collections.emptyList(),
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
overrideConfig);
|
|
|
|
overrideConfig);
|
|
|
|
overrideConfig = virtualHostFaultConfig == null
|
|
|
|
overrideConfig = virtualHostFaultConfig == null
|
|
|
|
? ImmutableMap.<String, FilterConfig>of()
|
|
|
|
? ImmutableMap.of()
|
|
|
|
: ImmutableMap.<String, FilterConfig>of(
|
|
|
|
: ImmutableMap.of(
|
|
|
|
FAULT_FILTER_INSTANCE_NAME, virtualHostFaultConfig);
|
|
|
|
FAULT_FILTER_INSTANCE_NAME, virtualHostFaultConfig);
|
|
|
|
VirtualHost virtualHost = VirtualHost.create(
|
|
|
|
VirtualHost virtualHost = VirtualHost.create(
|
|
|
|
"virtual-host",
|
|
|
|
"virtual-host",
|
|
|
|
@ -2201,26 +2201,26 @@ public class XdsNameResolverTest {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImmutableMap<String, FilterConfig> overrideConfig = weightedClusterFaultConfig == null
|
|
|
|
ImmutableMap<String, FilterConfig> overrideConfig = weightedClusterFaultConfig == null
|
|
|
|
? ImmutableMap.<String, FilterConfig>of()
|
|
|
|
? ImmutableMap.of()
|
|
|
|
: ImmutableMap.<String, FilterConfig>of(
|
|
|
|
: ImmutableMap.of(
|
|
|
|
FAULT_FILTER_INSTANCE_NAME, weightedClusterFaultConfig);
|
|
|
|
FAULT_FILTER_INSTANCE_NAME, weightedClusterFaultConfig);
|
|
|
|
ClusterWeight clusterWeight =
|
|
|
|
ClusterWeight clusterWeight =
|
|
|
|
ClusterWeight.create(cluster1, 100, overrideConfig);
|
|
|
|
ClusterWeight.create(cluster1, 100, overrideConfig);
|
|
|
|
overrideConfig = routFaultConfig == null
|
|
|
|
overrideConfig = routFaultConfig == null
|
|
|
|
? ImmutableMap.<String, FilterConfig>of()
|
|
|
|
? ImmutableMap.of()
|
|
|
|
: ImmutableMap.<String, FilterConfig>of(FAULT_FILTER_INSTANCE_NAME, routFaultConfig);
|
|
|
|
: ImmutableMap.of(FAULT_FILTER_INSTANCE_NAME, routFaultConfig);
|
|
|
|
Route route = Route.forAction(
|
|
|
|
Route route = Route.forAction(
|
|
|
|
RouteMatch.create(
|
|
|
|
RouteMatch.create(
|
|
|
|
PathMatcher.fromPrefix("/", false), Collections.<HeaderMatcher>emptyList(), null),
|
|
|
|
PathMatcher.fromPrefix("/", false), Collections.emptyList(), null),
|
|
|
|
RouteAction.forWeightedClusters(
|
|
|
|
RouteAction.forWeightedClusters(
|
|
|
|
Collections.singletonList(clusterWeight),
|
|
|
|
Collections.singletonList(clusterWeight),
|
|
|
|
Collections.<HashPolicy>emptyList(),
|
|
|
|
Collections.emptyList(),
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null),
|
|
|
|
null),
|
|
|
|
overrideConfig);
|
|
|
|
overrideConfig);
|
|
|
|
overrideConfig = virtualHostFaultConfig == null
|
|
|
|
overrideConfig = virtualHostFaultConfig == null
|
|
|
|
? ImmutableMap.<String, FilterConfig>of()
|
|
|
|
? ImmutableMap.of()
|
|
|
|
: ImmutableMap.<String, FilterConfig>of(
|
|
|
|
: ImmutableMap.of(
|
|
|
|
FAULT_FILTER_INSTANCE_NAME, virtualHostFaultConfig);
|
|
|
|
FAULT_FILTER_INSTANCE_NAME, virtualHostFaultConfig);
|
|
|
|
VirtualHost virtualHost = VirtualHost.create(
|
|
|
|
VirtualHost virtualHost = VirtualHost.create(
|
|
|
|
"virtual-host",
|
|
|
|
"virtual-host",
|
|
|
|
|