Search in sources :

Example 6 with EurekaClientConfigBean

use of org.springframework.cloud.netflix.eureka.EurekaClientConfigBean 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));
}
Also used : EurekaInstanceConfigBean(org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean) SpringClientFactory(org.springframework.cloud.netflix.ribbon.SpringClientFactory) ILoadBalancer(com.netflix.loadbalancer.ILoadBalancer) DiscoveryEnabledServer(com.netflix.niws.loadbalancer.DiscoveryEnabledServer) ZoneAwareLoadBalancer(com.netflix.loadbalancer.ZoneAwareLoadBalancer) EurekaClientConfigBean(org.springframework.cloud.netflix.eureka.EurekaClientConfigBean) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with EurekaClientConfigBean

use of org.springframework.cloud.netflix.eureka.EurekaClientConfigBean in project spring-cloud-netflix by spring-cloud.

the class EurekaRibbonClientConfigurationTests method testDefaultZone.

@Test
public void testDefaultZone() {
    EurekaClientConfigBean client = new EurekaClientConfigBean();
    EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
    EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(client, "myService", configBean, false);
    preprocessor.preprocess();
    assertEquals("defaultZone", ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
Also used : EurekaInstanceConfigBean(org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean) EurekaClientConfigBean(org.springframework.cloud.netflix.eureka.EurekaClientConfigBean) Test(org.junit.Test)

Example 8 with EurekaClientConfigBean

use of org.springframework.cloud.netflix.eureka.EurekaClientConfigBean in project spring-cloud-netflix by spring-cloud.

the class EurekaRibbonClientConfigurationTests method testApproximateZone.

@Test
public void testApproximateZone() {
    EurekaClientConfigBean client = new EurekaClientConfigBean();
    EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
    configBean.setHostname("this.is.a.test.com");
    EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(client, "myService", configBean, true);
    preprocessor.preprocess();
    assertEquals("is.a.test.com", ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
Also used : EurekaInstanceConfigBean(org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean) EurekaClientConfigBean(org.springframework.cloud.netflix.eureka.EurekaClientConfigBean) Test(org.junit.Test)

Example 9 with EurekaClientConfigBean

use of org.springframework.cloud.netflix.eureka.EurekaClientConfigBean in project spring-cloud-netflix by spring-cloud.

the class EurekaRibbonClientConfigurationTests method testExplicitZone.

@Test
public void testExplicitZone() {
    EurekaClientConfigBean client = new EurekaClientConfigBean();
    EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
    configBean.getMetadataMap().put("zone", "myZone");
    EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(client, "myService", configBean, false);
    preprocessor.preprocess();
    assertEquals("myZone", ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
Also used : EurekaInstanceConfigBean(org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean) EurekaClientConfigBean(org.springframework.cloud.netflix.eureka.EurekaClientConfigBean) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 EurekaClientConfigBean (org.springframework.cloud.netflix.eureka.EurekaClientConfigBean)9 EurekaInstanceConfigBean (org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean)8 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)4 InetUtils (org.springframework.cloud.commons.util.InetUtils)3 InetUtilsProperties (org.springframework.cloud.commons.util.InetUtilsProperties)3 CloudEurekaClient (org.springframework.cloud.netflix.eureka.CloudEurekaClient)3 InstanceInfo (com.netflix.appinfo.InstanceInfo)2 Map (java.util.Map)2 DynamicStringProperty (com.netflix.config.DynamicStringProperty)1 EurekaClientConfig (com.netflix.discovery.EurekaClientConfig)1 EurekaServerConfig (com.netflix.eureka.EurekaServerConfig)1 PeerAwareInstanceRegistry (com.netflix.eureka.registry.PeerAwareInstanceRegistry)1 ServerCodecs (com.netflix.eureka.resources.ServerCodecs)1 ILoadBalancer (com.netflix.loadbalancer.ILoadBalancer)1 ZoneAwareLoadBalancer (com.netflix.loadbalancer.ZoneAwareLoadBalancer)1 DiscoveryEnabledServer (com.netflix.niws.loadbalancer.DiscoveryEnabledServer)1 List (java.util.List)1 Ignore (org.junit.Ignore)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1