Search in sources :

Example 6 with ReplicationInstance

use of com.netflix.eureka.cluster.protocol.ReplicationInstance in project eureka by Netflix.

the class PeerEurekaNodeTest method testDeleteStatusOverrideBatchReplication.

@Test
public void testDeleteStatusOverrideBatchReplication() throws Throwable {
    createPeerEurekaNode().deleteStatusOverride(instanceInfo.getAppName(), instanceInfo.getId(), instanceInfo);
    ReplicationInstance replicationInstance = expectSingleBatchRequest();
    assertThat(replicationInstance.getAction(), is(equalTo(Action.DeleteStatusOverride)));
}
Also used : ReplicationInstance(com.netflix.eureka.cluster.protocol.ReplicationInstance) Test(org.junit.Test)

Example 7 with ReplicationInstance

use of com.netflix.eureka.cluster.protocol.ReplicationInstance in project eureka by Netflix.

the class PeerEurekaNodeTest method expectSingleBatchRequest.

private ReplicationInstance expectSingleBatchRequest() throws InterruptedException {
    HandledRequest handledRequest = httpReplicationClient.nextHandledRequest(30, TimeUnit.SECONDS);
    assertThat(handledRequest, is(notNullValue()));
    assertThat(handledRequest.getRequestType(), is(equalTo(RequestType.Batch)));
    Object data = handledRequest.getData();
    assertThat(data, is(instanceOf(ReplicationList.class)));
    List<ReplicationInstance> replications = ((ReplicationList) data).getReplicationList();
    assertThat(replications.size(), is(equalTo(1)));
    return replications.get(0);
}
Also used : ReplicationInstance(com.netflix.eureka.cluster.protocol.ReplicationInstance) ReplicationList(com.netflix.eureka.cluster.protocol.ReplicationList) HandledRequest(com.netflix.eureka.cluster.TestableHttpReplicationClient.HandledRequest)

Example 8 with ReplicationInstance

use of com.netflix.eureka.cluster.protocol.ReplicationInstance in project eureka by Netflix.

the class PeerReplicationResourceTest method testHeartbeat.

@Test
public void testHeartbeat() throws Exception {
    when(instanceResource.renewLease(anyString(), anyString(), anyString(), anyString())).thenReturn(Response.ok().build());
    ReplicationInstance replicationInstance = newReplicationInstanceOf(Action.Heartbeat, instanceInfo);
    Response response = peerReplicationResource.batchReplication(new ReplicationList(replicationInstance));
    assertStatusOkReply(response);
    verify(instanceResource, times(1)).renewLease("true", replicationInstance.getOverriddenStatus(), instanceInfo.getStatus().name(), Long.toString(replicationInstance.getLastDirtyTimestamp()));
}
Also used : ReplicationListResponse(com.netflix.eureka.cluster.protocol.ReplicationListResponse) Response(javax.ws.rs.core.Response) ReplicationInstanceResponse(com.netflix.eureka.cluster.protocol.ReplicationInstanceResponse) ReplicationInstance(com.netflix.eureka.cluster.protocol.ReplicationInstance) ReplicationList(com.netflix.eureka.cluster.protocol.ReplicationList) Test(org.junit.Test)

Example 9 with ReplicationInstance

use of com.netflix.eureka.cluster.protocol.ReplicationInstance in project eureka by Netflix.

the class PeerReplicationResourceTest method testDeleteStatusOverride.

@Test
public void testDeleteStatusOverride() throws Exception {
    when(instanceResource.deleteStatusUpdate(anyString(), anyString(), anyString())).thenReturn(Response.ok().build());
    ReplicationInstance replicationInstance = newReplicationInstanceOf(Action.DeleteStatusOverride, instanceInfo);
    Response response = peerReplicationResource.batchReplication(new ReplicationList(replicationInstance));
    assertStatusOkReply(response);
    verify(instanceResource, times(1)).deleteStatusUpdate("true", replicationInstance.getStatus(), Long.toString(replicationInstance.getLastDirtyTimestamp()));
}
Also used : ReplicationListResponse(com.netflix.eureka.cluster.protocol.ReplicationListResponse) Response(javax.ws.rs.core.Response) ReplicationInstanceResponse(com.netflix.eureka.cluster.protocol.ReplicationInstanceResponse) ReplicationInstance(com.netflix.eureka.cluster.protocol.ReplicationInstance) ReplicationList(com.netflix.eureka.cluster.protocol.ReplicationList) Test(org.junit.Test)

Example 10 with ReplicationInstance

use of com.netflix.eureka.cluster.protocol.ReplicationInstance in project eureka by Netflix.

the class PeerEurekaNodeTest method testRegistrationBatchReplication.

@Test
public void testRegistrationBatchReplication() throws Exception {
    createPeerEurekaNode().register(instanceInfo);
    ReplicationInstance replicationInstance = expectSingleBatchRequest();
    assertThat(replicationInstance.getAction(), is(equalTo(Action.Register)));
}
Also used : ReplicationInstance(com.netflix.eureka.cluster.protocol.ReplicationInstance) Test(org.junit.Test)

Aggregations

ReplicationInstance (com.netflix.eureka.cluster.protocol.ReplicationInstance)12 Test (org.junit.Test)11 ReplicationList (com.netflix.eureka.cluster.protocol.ReplicationList)6 ReplicationInstanceResponse (com.netflix.eureka.cluster.protocol.ReplicationInstanceResponse)4 ReplicationListResponse (com.netflix.eureka.cluster.protocol.ReplicationListResponse)4 Response (javax.ws.rs.core.Response)3 InstanceInfo (com.netflix.appinfo.InstanceInfo)2 CodecWrapper (com.netflix.discovery.converters.wrappers.CodecWrapper)1 CodecWrappers (com.netflix.discovery.converters.wrappers.CodecWrappers)1 DecoderWrapper (com.netflix.discovery.converters.wrappers.DecoderWrapper)1 EncoderWrapper (com.netflix.discovery.converters.wrappers.EncoderWrapper)1 HandledRequest (com.netflix.eureka.cluster.TestableHttpReplicationClient.HandledRequest)1 ArrayList (java.util.ArrayList)1