Search in sources :

Example 1 with CheckHeartbeatService

use of io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService in project ksql by confluentinc.

the class HeartbeatAgentTest method shouldMarkServerAsUpMissAtBeginning.

@Test
public void shouldMarkServerAsUpMissAtBeginning() {
    // Given:
    long windowStart = 0;
    long windowEnd = 10;
    heartbeatAgent.setHostsStatus(hostsStatus);
    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()));
}
Also used : CheckHeartbeatService(io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService) Test(org.junit.Test)

Example 2 with CheckHeartbeatService

use of io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService in project ksql by confluentinc.

the class HeartbeatAgentTest method shouldMarkServerAsUpNoMissingHeartbeat.

@Test
public void shouldMarkServerAsUpNoMissingHeartbeat() {
    // Given:
    long windowStart = 0;
    long windowEnd = 5;
    heartbeatAgent.setHostsStatus(hostsStatus);
    heartbeatAgent.receiveHeartbeat(remoteHost, 0L);
    heartbeatAgent.receiveHeartbeat(remoteHost, 1L);
    heartbeatAgent.receiveHeartbeat(remoteHost, 2L);
    heartbeatAgent.receiveHeartbeat(remoteHost, 3L);
    heartbeatAgent.receiveHeartbeat(remoteHost, 4L);
    heartbeatAgent.receiveHeartbeat(remoteHost, 5L);
    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()));
}
Also used : CheckHeartbeatService(io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService) Test(org.junit.Test)

Example 3 with CheckHeartbeatService

use of io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService in project ksql by confluentinc.

the class HeartbeatAgentTest method shouldMarkServerAsDownMissAtEnd.

@Test
public void shouldMarkServerAsDownMissAtEnd() {
    // Given:
    long windowStart = 0;
    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, 7L);
    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()));
}
Also used : CheckHeartbeatService(io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService) Test(org.junit.Test)

Example 4 with CheckHeartbeatService

use of io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService in project ksql by confluentinc.

the class HeartbeatAgentTest method shouldMarkServerAsDownIgnoreHeartbeatsOutOfWindow.

@Test
public void shouldMarkServerAsDownIgnoreHeartbeatsOutOfWindow() {
    // Given:
    long windowStart = 5;
    long windowEnd = 8;
    heartbeatAgent.setHostsStatus(hostsStatus);
    heartbeatAgent.receiveHeartbeat(remoteHost, 0L);
    heartbeatAgent.receiveHeartbeat(remoteHost, 1L);
    heartbeatAgent.receiveHeartbeat(remoteHost, 2L);
    heartbeatAgent.receiveHeartbeat(remoteHost, 3L);
    heartbeatAgent.receiveHeartbeat(remoteHost, 4L);
    heartbeatAgent.receiveHeartbeat(remoteHost, 9L);
    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(false));
    verify(hostStatusListener).onHostStatusUpdated(Mockito.eq(heartbeatAgent.getHostsStatus()));
}
Also used : CheckHeartbeatService(io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService) Test(org.junit.Test)

Example 5 with CheckHeartbeatService

use of io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService in project ksql by confluentinc.

the class HeartbeatAgentTest method localhostOnlyShouldMarkServerAsUp.

@Test
public void localhostOnlyShouldMarkServerAsUp() {
    // Given:
    long windowStart = 0;
    long windowEnd = 5;
    hostsStatus = ImmutableMap.of(localHost, new HostStatus(true, 0L));
    heartbeatAgent.setHostsStatus(hostsStatus);
    CheckHeartbeatService processService = heartbeatAgent.new CheckHeartbeatService();
    // When:
    processService.runWithWindow(windowStart, windowEnd);
    // Then:
    assertThat(heartbeatAgent.getHostsStatus().entrySet(), hasSize(1));
    assertThat(heartbeatAgent.getHostsStatus().get(localHost).isHostAlive(), is(true));
    verify(hostStatusListener).onHostStatusUpdated(Mockito.eq(heartbeatAgent.getHostsStatus()));
}
Also used : HostStatus(io.confluent.ksql.util.HostStatus) CheckHeartbeatService(io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService) Test(org.junit.Test)

Aggregations

CheckHeartbeatService (io.confluent.ksql.rest.server.HeartbeatAgent.CheckHeartbeatService)9 Test (org.junit.Test)9 HostStatus (io.confluent.ksql.util.HostStatus)1