use of io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService in project ksql by confluentinc.
the class HeartbeatAgentTest method shouldMarkServerAsDownOutOfOrderHeartbeats.
@Test
public void shouldMarkServerAsDownOutOfOrderHeartbeats() {
// Given:
long windowStart = 5;
long windowEnd = 8;
heartbeatAgent.setHostsStatus(hostsStatus);
heartbeatAgent.receiveHeartbeat(remoteHost, 10L);
heartbeatAgent.receiveHeartbeat(remoteHost, 9L);
heartbeatAgent.receiveHeartbeat(remoteHost, 0L);
heartbeatAgent.receiveHeartbeat(remoteHost, 4L);
heartbeatAgent.receiveHeartbeat(remoteHost, 2L);
heartbeatAgent.receiveHeartbeat(remoteHost, 3L);
heartbeatAgent.receiveHeartbeat(remoteHost, 1L);
CheckHeartbeatService processService = heartbeatAgent.new CheckHeartbeatService();
// When:
processService.runWithWindow(windowStart, windowEnd);
// Then:
assertThat(heartbeatAgent.getHostsStatus().entrySet(), hasSize(2));
assertThat(heartbeatAgent.getHostsStatus().get(remoteHost).isHostAlive(), is(false));
verify(hostStatusListener).onHostStatusUpdated(Mockito.eq(heartbeatAgent.getHostsStatus()));
}
use of io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService in project ksql by confluentinc.
the class HeartbeatAgentTest method shouldMarkServerAsUpMissOneHeartbeat.
@Test
public void shouldMarkServerAsUpMissOneHeartbeat() {
// Given:
long windowStart = 1;
long windowEnd = 10;
heartbeatAgent.setHostsStatus(hostsStatus);
heartbeatAgent.receiveHeartbeat(remoteHost, 0L);
heartbeatAgent.receiveHeartbeat(remoteHost, 2L);
heartbeatAgent.receiveHeartbeat(remoteHost, 4L);
heartbeatAgent.receiveHeartbeat(remoteHost, 6L);
heartbeatAgent.receiveHeartbeat(remoteHost, 8L);
heartbeatAgent.receiveHeartbeat(remoteHost, 10L);
CheckHeartbeatService processService = heartbeatAgent.new CheckHeartbeatService();
// When:
processService.runWithWindow(windowStart, windowEnd);
// Then:
assertThat(heartbeatAgent.getHostsStatus().entrySet(), hasSize(2));
assertThat(heartbeatAgent.getHostsStatus().get(remoteHost).isHostAlive(), is(true));
verify(hostStatusListener).onHostStatusUpdated(Mockito.eq(heartbeatAgent.getHostsStatus()));
}
use of io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService in project ksql by confluentinc.
the class HeartbeatAgentTest method shouldMarkServerAsUpMissInterleaved.
@Test
public void shouldMarkServerAsUpMissInterleaved() {
// Given:
long windowStart = 0;
long windowEnd = 10;
heartbeatAgent.setHostsStatus(hostsStatus);
heartbeatAgent.receiveHeartbeat(remoteHost, 0L);
heartbeatAgent.receiveHeartbeat(remoteHost, 2L);
heartbeatAgent.receiveHeartbeat(remoteHost, 5L);
heartbeatAgent.receiveHeartbeat(remoteHost, 8L);
CheckHeartbeatService processService = heartbeatAgent.new CheckHeartbeatService();
// When:
processService.runWithWindow(windowStart, windowEnd);
// Then:
assertThat(heartbeatAgent.getHostsStatus().entrySet(), hasSize(2));
assertThat(heartbeatAgent.getHostsStatus().get(remoteHost).isHostAlive(), is(true));
verify(hostStatusListener).onHostStatusUpdated(Mockito.eq(heartbeatAgent.getHostsStatus()));
}
use of io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService in project ksql by confluentinc.
the class HeartbeatAgentTest method shouldMarkServerAsUpOutOfOrderHeartbeats.
@Test
public void shouldMarkServerAsUpOutOfOrderHeartbeats() {
// Given:
long windowStart = 0;
long windowEnd = 10;
heartbeatAgent.setHostsStatus(hostsStatus);
heartbeatAgent.receiveHeartbeat(remoteHost, 8L);
heartbeatAgent.receiveHeartbeat(remoteHost, 0L);
heartbeatAgent.receiveHeartbeat(remoteHost, 5L);
heartbeatAgent.receiveHeartbeat(remoteHost, 2L);
CheckHeartbeatService processService = heartbeatAgent.new CheckHeartbeatService();
// When:
processService.runWithWindow(windowStart, windowEnd);
// Then:
assertThat(heartbeatAgent.getHostsStatus().entrySet(), hasSize(2));
assertThat(heartbeatAgent.getHostsStatus().get(remoteHost).isHostAlive(), is(true));
verify(hostStatusListener).onHostStatusUpdated(Mockito.eq(heartbeatAgent.getHostsStatus()));
}
Aggregations