use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class EurekaClientServerRestIntegrationTest method testStatusOverrideUpdateAndDelete.
@Test
public void testStatusOverrideUpdateAndDelete() throws Exception {
// Register first
InstanceInfo instanceInfo = instanceInfoIt.next();
jerseyEurekaClient.register(instanceInfo);
// Now override status
EurekaHttpResponse<Void> overrideUpdateResponse = jerseyEurekaClient.statusUpdate(instanceInfo.getAppName(), instanceInfo.getId(), InstanceStatus.DOWN, instanceInfo);
assertThat(overrideUpdateResponse.getStatusCode(), is(equalTo(200)));
InstanceInfo fetchedInstance = expectInstanceInfoInRegistry(instanceInfo);
assertThat(fetchedInstance.getStatus(), is(equalTo(InstanceStatus.DOWN)));
// Now remove override
EurekaHttpResponse<Void> deleteOverrideResponse = jerseyEurekaClient.deleteStatusOverride(instanceInfo.getAppName(), instanceInfo.getId(), instanceInfo);
assertThat(deleteOverrideResponse.getStatusCode(), is(equalTo(200)));
fetchedInstance = expectInstanceInfoInRegistry(instanceInfo);
assertThat(fetchedInstance.getStatus(), is(equalTo(InstanceStatus.UNKNOWN)));
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class EurekaClientServerRestIntegrationTest method testBatch.
@Test
public void testBatch() throws Exception {
InstanceInfo instanceInfo = instanceInfoIt.next();
ReplicationInstance replicationInstance = ReplicationInstance.replicationInstance().withAction(Action.Register).withAppName(instanceInfo.getAppName()).withId(instanceInfo.getId()).withInstanceInfo(instanceInfo).withLastDirtyTimestamp(System.currentTimeMillis()).withStatus(instanceInfo.getStatus().name()).build();
EurekaHttpResponse<ReplicationListResponse> httpResponse = jerseyReplicationClient.submitBatchUpdates(new ReplicationList(replicationInstance));
assertThat(httpResponse.getStatusCode(), is(equalTo(200)));
List<ReplicationInstanceResponse> replicationListResponse = httpResponse.getEntity().getResponseList();
assertThat(replicationListResponse.size(), is(equalTo(1)));
assertThat(replicationListResponse.get(0).getStatusCode(), is(equalTo(200)));
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class AwsAsgUtilTest method setUp.
@Before
public void setUp() throws Exception {
ConfigurationManager.getConfigInstance().setProperty("eureka.awsAccessId", "fakeId");
ConfigurationManager.getConfigInstance().setProperty("eureka.awsSecretKey", "fakeKey");
AmazonInfo dataCenterInfo = mock(AmazonInfo.class);
EurekaServerConfig serverConfig = new DefaultEurekaServerConfig();
InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder();
builder.setIPAddr("10.10.101.00");
builder.setHostName("fakeHost");
builder.setAppName("fake-" + UUID.randomUUID());
builder.setLeaseInfo(LeaseInfo.Builder.newBuilder().build());
builder.setDataCenterInfo(dataCenterInfo);
instanceInfo = builder.build();
applicationInfoManager = new ApplicationInfoManager(new MyDataCenterInstanceConfig(), instanceInfo);
DefaultEurekaClientConfig clientConfig = new DefaultEurekaClientConfig();
// setup config in advance, used in initialize converter
client = mock(DiscoveryClient.class);
registry = mock(PeerAwareInstanceRegistry.class);
awsAsgUtil = spy(new AwsAsgUtil(serverConfig, clientConfig, registry));
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class ApplicationResourceTest method testGoodRegistration.
@Test
public void testGoodRegistration() throws Exception {
InstanceInfo noIdInfo = InstanceInfoGenerator.takeOne();
Response response = applicationResource.addInstance(noIdInfo, false + "");
assertThat(response.getStatus(), is(204));
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class ApplicationResourceTest method testMiniAppGet.
@Test
public void testMiniAppGet() throws Exception {
Response response = applicationResource.getApplication(Version.V2.name(), MediaType.APPLICATION_JSON, EurekaAccept.compact.name());
String json = String.valueOf(response.getEntity());
DecoderWrapper decoder = CodecWrappers.getDecoder(CodecWrappers.LegacyJacksonJson.class);
Application decodedApp = decoder.decode(json, Application.class);
// 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