use of com.netflix.appinfo.AmazonInfo in project eureka by Netflix.
the class InstanceRegionCheckerTest method testDefaultOverride.
@Test
public void testDefaultOverride() throws Exception {
ConfigurationManager.getConfigInstance().setProperty("eureka.us-east-1.availabilityZones", "abc,def");
PropertyBasedAzToRegionMapper azToRegionMapper = new PropertyBasedAzToRegionMapper(new DefaultEurekaClientConfig());
InstanceRegionChecker checker = new InstanceRegionChecker(azToRegionMapper, "us-east-1");
azToRegionMapper.setRegionsToFetch(new String[] { "us-east-1" });
AmazonInfo dcInfo = AmazonInfo.Builder.newBuilder().addMetadata(AmazonInfo.MetaDataKey.availabilityZone, "def").build();
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("app").setDataCenterInfo(dcInfo).build();
String instanceRegion = checker.getInstanceRegion(instanceInfo);
Assert.assertEquals("Invalid instance region.", "us-east-1", instanceRegion);
}
use of com.netflix.appinfo.AmazonInfo in project eureka by Netflix.
the class InstanceRegionCheckerTest method testNotMappedAZNotFollowingFormat.
@Test
public void testNotMappedAZNotFollowingFormat() throws Exception {
ConfigurationManager.getConfigInstance().setProperty("eureka.us-east-1.availabilityZones", "abc,def");
PropertyBasedAzToRegionMapper azToRegionMapper = new PropertyBasedAzToRegionMapper(new DefaultEurekaClientConfig());
InstanceRegionChecker checker = new InstanceRegionChecker(azToRegionMapper, "us-east-1");
azToRegionMapper.setRegionsToFetch(new String[] { "us-east-1" });
AmazonInfo dcInfo = AmazonInfo.Builder.newBuilder().addMetadata(AmazonInfo.MetaDataKey.availabilityZone, "us-east-x").build();
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("abc").setDataCenterInfo(dcInfo).build();
String instanceRegion = checker.getInstanceRegion(instanceInfo);
Assert.assertNull("Invalid instance region.", instanceRegion);
}
use of com.netflix.appinfo.AmazonInfo in project eureka by Netflix.
the class InstanceRegionCheckerTest method testNotMappedAZ.
@Test
public void testNotMappedAZ() throws Exception {
ConfigurationManager.getConfigInstance().setProperty("eureka.us-east-1.availabilityZones", "abc,def");
PropertyBasedAzToRegionMapper azToRegionMapper = new PropertyBasedAzToRegionMapper(new DefaultEurekaClientConfig());
InstanceRegionChecker checker = new InstanceRegionChecker(azToRegionMapper, "us-east-1");
azToRegionMapper.setRegionsToFetch(new String[] { "us-east-1" });
AmazonInfo dcInfo = AmazonInfo.Builder.newBuilder().addMetadata(AmazonInfo.MetaDataKey.availabilityZone, "us-east-1x").build();
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("abc").setDataCenterInfo(dcInfo).build();
String instanceRegion = checker.getInstanceRegion(instanceInfo);
Assert.assertEquals("Invalid instance region.", "us-east-1", instanceRegion);
}
use of com.netflix.appinfo.AmazonInfo in project eureka by Netflix.
the class InstanceRegionCheckerTest method testInstanceWithNoAZ.
@Test
public void testInstanceWithNoAZ() throws Exception {
ConfigurationManager.getConfigInstance().setProperty("eureka.us-east-1.availabilityZones", "abc,def");
PropertyBasedAzToRegionMapper azToRegionMapper = new PropertyBasedAzToRegionMapper(new DefaultEurekaClientConfig());
InstanceRegionChecker checker = new InstanceRegionChecker(azToRegionMapper, "us-east-1");
azToRegionMapper.setRegionsToFetch(new String[] { "us-east-1" });
AmazonInfo dcInfo = AmazonInfo.Builder.newBuilder().addMetadata(AmazonInfo.MetaDataKey.availabilityZone, "").build();
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("app").setDataCenterInfo(dcInfo).build();
String instanceRegion = checker.getInstanceRegion(instanceInfo);
Assert.assertNull("Invalid instance region.", instanceRegion);
}
use of com.netflix.appinfo.AmazonInfo in project eureka by Netflix.
the class BackUpRegistryTest method createLocalInstance.
private InstanceInfo createLocalInstance(String instanceHostName) {
InstanceInfo.Builder instanceBuilder = InstanceInfo.Builder.newBuilder();
instanceBuilder.setAppName(LOCAL_REGION_APP_NAME);
instanceBuilder.setVIPAddress(ALL_REGIONS_VIP_ADDR);
instanceBuilder.setHostName(instanceHostName);
instanceBuilder.setIPAddr("10.10.101.1");
AmazonInfo amazonInfo = getAmazonInfo(null, instanceHostName);
instanceBuilder.setDataCenterInfo(amazonInfo);
instanceBuilder.setMetadata(amazonInfo.getMetadata());
return instanceBuilder.build();
}
Aggregations