Search in sources :

Example 76 with InstanceInfo

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);
}
Also used : InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 77 with InstanceInfo

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));
}
Also used : ProcessingResult(com.netflix.eureka.util.batcher.TaskProcessor.ProcessingResult) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 78 with InstanceInfo

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");
        }
    };
}
Also used : Iterator(java.util.Iterator) InstanceInfo(com.netflix.appinfo.InstanceInfo) NoSuchElementException(java.util.NoSuchElementException)

Example 79 with InstanceInfo

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)));
}
Also used : InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 80 with InstanceInfo

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)));
}
Also used : InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Aggregations

InstanceInfo (com.netflix.appinfo.InstanceInfo)192 Test (org.junit.Test)74 Application (com.netflix.discovery.shared.Application)35 Applications (com.netflix.discovery.shared.Applications)22 AmazonInfo (com.netflix.appinfo.AmazonInfo)21 ArrayList (java.util.ArrayList)19 InstanceStatus (com.netflix.appinfo.InstanceInfo.InstanceStatus)11 Before (org.junit.Before)11 DiscoveryClient (com.netflix.discovery.DiscoveryClient)10 DecoderWrapper (com.netflix.discovery.converters.wrappers.DecoderWrapper)10 Lease (com.netflix.eureka.lease.Lease)9 HashMap (java.util.HashMap)8 Response (javax.ws.rs.core.Response)8 DataCenterInfo (com.netflix.appinfo.DataCenterInfo)7 CodecWrappers (com.netflix.discovery.converters.wrappers.CodecWrappers)7 EncoderWrapper (com.netflix.discovery.converters.wrappers.EncoderWrapper)7 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)6 EurekaEntityFunctions.mergeApplications (com.netflix.discovery.util.EurekaEntityFunctions.mergeApplications)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6