Search in sources :

Example 1 with RlsPluginConfig

use of io.grpc.xds.RouteLookupServiceClusterSpecifierPlugin.RlsPluginConfig in project grpc-java by grpc.

the class RouteLookupServiceClusterSpecifierPluginTest method parseConfigWithAllFieldsGiven.

@Test
public void parseConfigWithAllFieldsGiven() {
    RouteLookupConfig routeLookupConfig = RouteLookupConfig.newBuilder().addGrpcKeybuilders(GrpcKeyBuilder.newBuilder().addNames(Name.newBuilder().setService("service1").setMethod("method1")).addNames(Name.newBuilder().setService("service2").setMethod("method2")).addHeaders(NameMatcher.newBuilder().setKey("key1").addNames("v1").setRequiredMatch(true)).setExtraKeys(ExtraKeys.newBuilder().setHost("host1").setService("service1").setMethod("method1")).putConstantKeys("key2", "value2")).setLookupService("rls-cbt.googleapis.com").setLookupServiceTimeout(Durations.fromMillis(1234)).setMaxAge(Durations.fromMillis(56789)).setStaleAge(Durations.fromMillis(1000)).setCacheSizeBytes(5000).addValidTargets("valid-target").setDefaultTarget("default-target").build();
    RouteLookupClusterSpecifier specifier = RouteLookupClusterSpecifier.newBuilder().setRouteLookupConfig(routeLookupConfig).build();
    RlsPluginConfig config = RouteLookupServiceClusterSpecifierPlugin.INSTANCE.parsePlugin(Any.pack(specifier)).config;
    assertThat(config.typeUrl()).isEqualTo("type.googleapis.com/grpc.lookup.v1.RouteLookupClusterSpecifier");
    assertThat(config.config()).isEqualTo(ImmutableMap.builder().put("grpcKeybuilders", ImmutableList.of(ImmutableMap.of("names", ImmutableList.of(ImmutableMap.of("service", "service1", "method", "method1"), ImmutableMap.of("service", "service2", "method", "method2")), "headers", ImmutableList.of(ImmutableMap.of("key", "key1", "names", ImmutableList.of("v1"), "requiredMatch", true)), "extraKeys", ImmutableMap.of("host", "host1", "service", "service1", "method", "method1"), "constantKeys", ImmutableMap.of("key2", "value2")))).put("lookupService", "rls-cbt.googleapis.com").put("lookupServiceTimeout", "1.234s").put("maxAge", "56.789s").put("staleAge", "1s").put("cacheSizeBytes", "5000").put("validTargets", ImmutableList.of("valid-target")).put("defaultTarget", "default-target").build());
}
Also used : RouteLookupClusterSpecifier(io.grpc.lookup.v1.RouteLookupClusterSpecifier) RouteLookupConfig(io.grpc.lookup.v1.RouteLookupConfig) RlsPluginConfig(io.grpc.xds.RouteLookupServiceClusterSpecifierPlugin.RlsPluginConfig) Test(org.junit.Test)

Example 2 with RlsPluginConfig

use of io.grpc.xds.RouteLookupServiceClusterSpecifierPlugin.RlsPluginConfig in project grpc-java by grpc.

the class RouteLookupServiceClusterSpecifierPluginTest method parseConfigWithOptionalFieldsUnspecified.

@Test
public void parseConfigWithOptionalFieldsUnspecified() {
    RouteLookupConfig routeLookupConfig = RouteLookupConfig.newBuilder().addGrpcKeybuilders(GrpcKeyBuilder.newBuilder().addNames(Name.newBuilder().setService("service1")).addNames(Name.newBuilder().setService("service2")).addHeaders(NameMatcher.newBuilder().setKey("key1").addNames("v1").setRequiredMatch(true))).setLookupService("rls-cbt.googleapis.com").setLookupServiceTimeout(Durations.fromMillis(1234)).setCacheSizeBytes(5000).addValidTargets("valid-target").build();
    RouteLookupClusterSpecifier specifier = RouteLookupClusterSpecifier.newBuilder().setRouteLookupConfig(routeLookupConfig).build();
    RlsPluginConfig config = RouteLookupServiceClusterSpecifierPlugin.INSTANCE.parsePlugin(Any.pack(specifier)).config;
    assertThat(config.typeUrl()).isEqualTo("type.googleapis.com/grpc.lookup.v1.RouteLookupClusterSpecifier");
    assertThat(config.config()).isEqualTo(ImmutableMap.builder().put("grpcKeybuilders", ImmutableList.of(ImmutableMap.of("names", ImmutableList.of(ImmutableMap.of("service", "service1"), ImmutableMap.of("service", "service2")), "headers", ImmutableList.of(ImmutableMap.of("key", "key1", "names", ImmutableList.of("v1"), "requiredMatch", true))))).put("lookupService", "rls-cbt.googleapis.com").put("lookupServiceTimeout", "1.234s").put("cacheSizeBytes", "5000").put("validTargets", ImmutableList.of("valid-target")).build());
}
Also used : RouteLookupClusterSpecifier(io.grpc.lookup.v1.RouteLookupClusterSpecifier) RouteLookupConfig(io.grpc.lookup.v1.RouteLookupConfig) RlsPluginConfig(io.grpc.xds.RouteLookupServiceClusterSpecifierPlugin.RlsPluginConfig) Test(org.junit.Test)

Aggregations

RouteLookupClusterSpecifier (io.grpc.lookup.v1.RouteLookupClusterSpecifier)2 RouteLookupConfig (io.grpc.lookup.v1.RouteLookupConfig)2 RlsPluginConfig (io.grpc.xds.RouteLookupServiceClusterSpecifierPlugin.RlsPluginConfig)2 Test (org.junit.Test)2