use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class PeerEurekaNodeTest method testHeartbeatWithInstanceInfoFromPeer.
@Test
public void testHeartbeatWithInstanceInfoFromPeer() throws Throwable {
InstanceInfo instanceInfoFromPeer = ClusterSampleData.newInstanceInfo(2);
httpReplicationClient.withNetworkStatusCode(200);
httpReplicationClient.withBatchReply(400);
httpReplicationClient.withInstanceInfo(instanceInfoFromPeer);
// InstanceInfo in response from peer will trigger local registry call
createPeerEurekaNode().heartbeat(instanceInfo.getAppName(), instanceInfo.getId(), instanceInfo, null, false);
expectRequestType(RequestType.Batch);
// Check that registry has instanceInfo from peer
verify(registry, timeout(1000).times(1)).register(instanceInfoFromPeer, true);
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class ReplicationTaskProcessorTest method testBatchableTaskPermanentFailureHandling.
@Test
public void testBatchableTaskPermanentFailureHandling() throws Exception {
TestableInstanceReplicationTask task = aReplicationTask().build();
InstanceInfo instanceInfoFromPeer = InstanceInfoGenerator.takeOne();
replicationClient.withNetworkStatusCode(200);
replicationClient.withBatchReply(400);
replicationClient.withInstanceInfo(instanceInfoFromPeer);
ProcessingResult status = replicationTaskProcessor.process(Collections.<ReplicationTask>singletonList(task));
assertThat(status, is(ProcessingResult.Success));
assertThat(task.getProcessingState(), is(ProcessingState.Failed));
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class InstanceInfoGenerator method serviceIterator.
public Iterator<InstanceInfo> serviceIterator() {
return new Iterator<InstanceInfo>() {
private int returned;
private final int[] appInstanceIds = new int[appNames.length];
private int currentApp;
@Override
public boolean hasNext() {
return returned < instanceCount;
}
@Override
public InstanceInfo next() {
if (!hasNext()) {
throw new NoSuchElementException("no more InstanceInfo elements");
}
InstanceInfo toReturn = generateInstanceInfo(currentApp, appInstanceIds[currentApp], useInstanceId);
appInstanceIds[currentApp]++;
currentApp = (currentApp + 1) % appNames.length;
returned++;
return toReturn;
}
@Override
public void remove() {
throw new IllegalStateException("method not supported");
}
};
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class EurekaHttpClientCompatibilityTestSuite method testRegisterRequest.
@Test
public void testRegisterRequest() throws Exception {
InstanceInfo instance = InstanceInfoGenerator.takeOne();
when(requestHandler.register(instance)).thenReturn(EurekaHttpResponse.status(204));
EurekaHttpResponse<Void> httpResponse = getEurekaHttpClient().register(instance);
assertThat(httpResponse.getStatusCode(), is(equalTo(204)));
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class EurekaHttpClientCompatibilityTestSuite method testStatusUpdateRequest.
@Test
public void testStatusUpdateRequest() throws Exception {
InstanceInfo instance = InstanceInfoGenerator.takeOne();
when(requestHandler.statusUpdate(instance.getAppName(), instance.getId(), InstanceStatus.OUT_OF_SERVICE, null)).thenReturn(EurekaHttpResponse.status(200));
EurekaHttpResponse<Void> httpResponse = getEurekaHttpClient().statusUpdate(instance.getAppName(), instance.getId(), InstanceStatus.OUT_OF_SERVICE, instance);
assertThat(httpResponse.getStatusCode(), is(equalTo(200)));
}
Aggregations