use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class AwsInstanceRegistryTest method testOverridesWithAsgEnabledThenDisabled.
@Test
public void testOverridesWithAsgEnabledThenDisabled() {
// Regular registration first
InstanceInfo myInstance = createLocalUpInstanceWithAsg(LOCAL_REGION_INSTANCE_1_HOSTNAME);
registerInstanceLocally(myInstance);
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.UP);
// Now we disable the ASG and we should expect OUT_OF_SERVICE status.
((AwsInstanceRegistry) registry).getAwsAsgUtil().setStatus(myInstance.getASGName(), false);
myInstance = createLocalUpInstanceWithAsg(LOCAL_REGION_INSTANCE_1_HOSTNAME);
registerInstanceLocally(myInstance);
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.OUT_OF_SERVICE);
// Now we re-enable the ASG and we should expect UP status.
((AwsInstanceRegistry) registry).getAwsAsgUtil().setStatus(myInstance.getASGName(), true);
myInstance = createLocalUpInstanceWithAsg(LOCAL_REGION_INSTANCE_1_HOSTNAME);
registerInstanceLocally(myInstance);
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.UP);
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class InstanceRegistryTest method testStatusOverrideWithExistingLeaseOutOfService.
@Test
public void testStatusOverrideWithExistingLeaseOutOfService() throws Exception {
// Without an override we expect to get the existing OUT_OF_SERVICE lease when we re-register with UP.
// First, we are "out of service".
InstanceInfo myInstance = createLocalOutOfServiceInstance(LOCAL_REGION_INSTANCE_1_HOSTNAME);
registerInstanceLocally(myInstance);
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.OUT_OF_SERVICE);
// Then, we re-register with "UP".
InstanceInfo sameInstance = createLocalInstance(LOCAL_REGION_INSTANCE_1_HOSTNAME);
registry.register(sameInstance, 10000000, false);
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.OUT_OF_SERVICE);
// Let's try again. We shouldn't see a difference.
sameInstance = createLocalInstance(LOCAL_REGION_INSTANCE_1_HOSTNAME);
registry.register(sameInstance, 10000000, false);
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.OUT_OF_SERVICE);
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class InstanceRegistryTest method testStatusOverrideSetAndRemoval.
@Test
public void testStatusOverrideSetAndRemoval() throws Exception {
// Regular registration first
InstanceInfo myInstance = createLocalInstance(LOCAL_REGION_INSTANCE_1_HOSTNAME);
registerInstanceLocally(myInstance);
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.UP);
// Override status
boolean statusResult = registry.statusUpdate(LOCAL_REGION_APP_NAME, myInstance.getId(), InstanceStatus.OUT_OF_SERVICE, "0", false);
assertThat("Couldn't override instance status", statusResult, is(true));
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.OUT_OF_SERVICE);
// Register again with status UP (this is what health check is doing)
registry.register(createLocalInstance(LOCAL_REGION_INSTANCE_1_HOSTNAME), 10000000, false);
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.OUT_OF_SERVICE);
// Now remove override
statusResult = registry.deleteStatusOverride(LOCAL_REGION_APP_NAME, myInstance.getId(), InstanceStatus.DOWN, "0", false);
assertThat("Couldn't remove status override", statusResult, is(true));
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.DOWN);
// Register again with status UP (this is what health check is doing)
registry.register(createLocalInstance(LOCAL_REGION_INSTANCE_1_HOSTNAME), 10000000, false);
verifyLocalInstanceStatus(myInstance.getId(), InstanceStatus.UP);
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class AbstractVIPResourceTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
InstanceInfoGenerator instanceInfos = InstanceInfoGenerator.newBuilder(6, 1).build();
testApplication = instanceInfos.toApplications().getRegisteredApplications().get(0);
resource = new AbstractVIPResource(serverContext) {
@Override
protected Response getVipResponse(String version, String entityName, String acceptHeader, EurekaAccept eurekaAccept, Key.EntityType entityType) {
return super.getVipResponse(version, entityName, acceptHeader, eurekaAccept, entityType);
}
};
vipName = testApplication.getName() + "#VIP";
for (InstanceInfo instanceInfo : testApplication.getInstances()) {
InstanceInfo changed = new InstanceInfo.Builder(instanceInfo).setASGName(// null asgName to get around AwsAsgUtil check
null).setVIPAddress(// use the same vip address for all the instances in this test
vipName).build();
registry.register(changed, false);
}
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class AbstractVIPResourceTest method testMiniVipGet.
@Test
public void testMiniVipGet() throws Exception {
Response response = resource.getVipResponse(Version.V2.name(), vipName, MediaType.APPLICATION_JSON, EurekaAccept.compact, Key.EntityType.VIP);
String json = String.valueOf(response.getEntity());
DecoderWrapper decoder = CodecWrappers.getDecoder(CodecWrappers.LegacyJacksonJson.class);
Applications decodedApps = decoder.decode(json, Applications.class);
Application decodedApp = decodedApps.getRegisteredApplications(testApplication.getName());
// assert false as one is mini, so should NOT equal
assertThat(EurekaEntityComparators.equal(testApplication, decodedApp), is(false));
for (InstanceInfo instanceInfo : testApplication.getInstances()) {
InstanceInfo decodedInfo = decodedApp.getByInstanceId(instanceInfo.getId());
assertThat(EurekaEntityComparators.equalMini(instanceInfo, decodedInfo), is(true));
}
}
Aggregations