use of io.confluent.ksql.execution.streams.RoutingFilter.Host in project ksql by confluentinc.
the class MaximumLagFilterTest method filter_shouldNotIncludeAboveThreshold.
@Test
public void filter_shouldNotIncludeAboveThreshold() {
// The max end offset is 15, so the lag for HOST is 12
// Given:
when(routingOptions.getMaxOffsetLagAllowed()).thenReturn(11L);
// When:
filter = MaximumLagFilter.create(Optional.of(lagReportingAgent), routingOptions, HOSTS, APPLICATION_ID, STATE_STORE, PARTITION).get();
// Then:
final Host host = filter.filter(HOST1);
assertFalse(host.isSelected());
assertEquals(host.getReasonNotSelected(), "Host excluded because lag 12 exceeds maximum allowed lag 11.");
}
use of io.confluent.ksql.execution.streams.RoutingFilter.Host in project ksql by confluentinc.
the class LivenessFilterTest method shouldFilterActiveAlive.
@Test
public void shouldFilterActiveAlive() {
// Given:
allHostsStatus = ImmutableMap.of(activeHost, HOST_ALIVE, standByHost1, HOST_DEAD, standByHost2, HOST_DEAD);
when(heartbeatAgent.getHostsStatus()).thenReturn(allHostsStatus);
// When:
final Host filterActive = livenessFilter.filter(activeHost);
final Host filterStandby1 = livenessFilter.filter(standByHost1);
final Host filterStandby2 = livenessFilter.filter(standByHost2);
// Then:
assertThat(filterActive.isSelected(), is(true));
assertThat(filterStandby1.isSelected(), is(false));
assertThat(filterStandby1.getReasonNotSelected(), is("Host is not alive as of time 0"));
assertThat(filterStandby2.isSelected(), is(false));
assertThat(filterStandby2.getReasonNotSelected(), is("Host is not alive as of time 0"));
}
use of io.confluent.ksql.execution.streams.RoutingFilter.Host in project ksql by confluentinc.
the class LivenessFilterTest method shouldFilterStandbyAlive.
@Test
public void shouldFilterStandbyAlive() {
// Given:
allHostsStatus = ImmutableMap.of(activeHost, HOST_DEAD, standByHost1, HOST_ALIVE, standByHost2, HOST_DEAD);
when(heartbeatAgent.getHostsStatus()).thenReturn(allHostsStatus);
// When:
final Host filterActive = livenessFilter.filter(activeHost);
final Host filterStandby1 = livenessFilter.filter(standByHost1);
final Host filterStandby2 = livenessFilter.filter(standByHost2);
// Then:
assertThat(filterActive.isSelected(), is(false));
assertThat(filterActive.getReasonNotSelected(), is("Host is not alive as of time 0"));
assertThat(filterStandby1.isSelected(), is(true));
assertThat(filterStandby2.isSelected(), is(false));
assertThat(filterActive.getReasonNotSelected(), is("Host is not alive as of time 0"));
}
use of io.confluent.ksql.execution.streams.RoutingFilter.Host in project ksql by confluentinc.
the class ActiveHostFilterTest method shouldFilterActive.
@Test
public void shouldFilterActive() {
// Given:
// When:
final Host filterActive = activeHostFilter.filter(activeHost);
final Host filterStandby = activeHostFilter.filter(standByHost);
// Then:
assertThat(filterActive.isSelected(), is(true));
assertThat(filterStandby.isSelected(), is(false));
assertThat(filterStandby.getReasonNotSelected(), is("Host is not the active host for this partition."));
}
use of io.confluent.ksql.execution.streams.RoutingFilter.Host in project ksql by confluentinc.
the class MaximumLagFilterTest method filter_shouldIncludeBelowThreshold.
@Test
public void filter_shouldIncludeBelowThreshold() {
// The max end offset is 15, so the lag for HOST is 12
// Given:
when(routingOptions.getMaxOffsetLagAllowed()).thenReturn(13L);
// When:
filter = MaximumLagFilter.create(Optional.of(lagReportingAgent), routingOptions, HOSTS, APPLICATION_ID, STATE_STORE, PARTITION).get();
// Then:
final Host host = filter.filter(HOST1);
assertTrue(host.isSelected());
assertEquals(host.getReasonNotSelected(), "");
}
Aggregations