use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project spring-cloud-netflix by spring-cloud.
the class DomainExtractingServerListTests method testDomainExtractingServerDontApproximateZone.
@Test
public void testDomainExtractingServerDontApproximateZone() {
DomainExtractingServerList serverList = getDomainExtractingServerList(new DefaultClientConfigImpl(), false);
List<DiscoveryEnabledServer> servers = serverList.getInitialListOfServers();
assertNotNull("servers was null", servers);
assertEquals("servers was not size 1", 1, servers.size());
DomainExtractingServer des = assertDomainExtractingServer(servers, null);
assertEquals("hostPort was wrong", HOST_NAME + ":" + PORT, des.getHostPort());
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project spring-cloud-netflix by spring-cloud.
the class EurekaRibbonClientConfigurationTests method basicConfigurationCreatedForLoadBalancer.
@Test
@Ignore
public void basicConfigurationCreatedForLoadBalancer() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
client.getAvailabilityZones().put(client.getRegion(), "foo");
SpringClientFactory clientFactory = new SpringClientFactory();
EurekaRibbonClientConfiguration clientPreprocessor = new EurekaRibbonClientConfiguration(client, "service", configBean, false);
clientPreprocessor.preprocess();
ILoadBalancer balancer = clientFactory.getLoadBalancer("service");
assertNotNull(balancer);
@SuppressWarnings("unchecked") ZoneAwareLoadBalancer<DiscoveryEnabledServer> aware = (ZoneAwareLoadBalancer<DiscoveryEnabledServer>) balancer;
assertTrue(aware.getServerListImpl() instanceof DomainExtractingServerList);
assertEquals("foo", ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project zuul by Netflix.
the class DiscoveryResultTest method serverStatsCacheForSameServer.
@Test
public void serverStatsCacheForSameServer() {
final InstanceInfo instanceInfo = Builder.newBuilder().setAppName("serverstats-cache").setHostName("serverstats-cache").setPort(7777).build();
final DiscoveryEnabledServer server = new DiscoveryEnabledServer(instanceInfo, false);
final DiscoveryEnabledServer serverSecure = new DiscoveryEnabledServer(instanceInfo, true);
final DynamicServerListLoadBalancer<Server> lb = new DynamicServerListLoadBalancer<>(new DefaultClientConfigImpl());
final DiscoveryResult result = new DiscoveryResult(server, lb.getLoadBalancerStats());
final DiscoveryResult result1 = new DiscoveryResult(serverSecure, lb.getLoadBalancerStats());
Truth.assertThat(result.getServerStats()).isSameInstanceAs(result1.getServerStats());
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project zuul by Netflix.
the class DiscoveryResultTest method securePortMustCheckInstanceInfo.
@Test
public void securePortMustCheckInstanceInfo() {
final InstanceInfo instanceInfo = Builder.newBuilder().setAppName("secure-port").setHostName("secure-port").setPort(7777).enablePort(PortType.SECURE, false).build();
final InstanceInfo secureEnabled = Builder.newBuilder().setAppName("secure-port").setHostName("secure-port").setPort(7777).enablePort(PortType.SECURE, true).build();
final DiscoveryEnabledServer server = new DiscoveryEnabledServer(instanceInfo, true);
final DiscoveryEnabledServer secureServer = new DiscoveryEnabledServer(secureEnabled, true);
final DynamicServerListLoadBalancer<Server> lb = new DynamicServerListLoadBalancer<>(new DefaultClientConfigImpl());
final DiscoveryResult result = new DiscoveryResult(server, lb.getLoadBalancerStats());
final DiscoveryResult secure = new DiscoveryResult(secureServer, lb.getLoadBalancerStats());
Truth.assertThat(result.isSecurePortEnabled()).isFalse();
Truth.assertThat(secure.isSecurePortEnabled()).isTrue();
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project zuul by Netflix.
the class DiscoveryResultTest method ipAddrV4FromInstanceInfo.
@Test
public void ipAddrV4FromInstanceInfo() {
final String ipAddr = "100.1.0.1";
final InstanceInfo instanceInfo = Builder.newBuilder().setAppName("ipAddrv4").setHostName("ipAddrv4").setIPAddr(ipAddr).setPort(7777).build();
final DiscoveryEnabledServer server = new DiscoveryEnabledServer(instanceInfo, false);
final DynamicServerListLoadBalancer<Server> lb = new DynamicServerListLoadBalancer<>(new DefaultClientConfigImpl());
final DiscoveryResult result = new DiscoveryResult(server, lb.getLoadBalancerStats());
Truth.assertThat(result.getIPAddr()).isEqualTo(Optional.of(ipAddr));
}
Aggregations