use of oap.logstream.AvailabilityReport.State.FAILED in project oap by oaplatform.
the class ShardedLoggerBackendTest method testAvailability.
@Test
public void testAvailability() {
LoggerBackend log1 = mock(LoggerBackend.class);
LoggerBackend log2 = mock(LoggerBackend.class);
LoggerShardRange shard0To100 = new LoggerShardRange(log1, 0, 100);
LoggerShardRange shard100To200 = new LoggerShardRange(log2, 100, 200);
List<LoggerShardRange> shards = Arrays.asList(shard0To100, shard100To200);
ShardedLoggerBackend slb = new ShardedLoggerBackend(shards, mapper);
when(log1.availabilityReport()).thenReturn(new AvailabilityReport(OPERATIONAL));
when(log2.availabilityReport()).thenReturn(new AvailabilityReport(OPERATIONAL));
assertEquals(slb.availabilityReport().state, OPERATIONAL);
assertEquals(slb.availabilityReport().subsystemStates.size(), 2);
assertTrue(Stream.of(slb.availabilityReport().subsystemStates.values()).allMatch(s -> s == OPERATIONAL));
when(log1.availabilityReport()).thenReturn(new AvailabilityReport(FAILED));
when(log2.availabilityReport()).thenReturn(new AvailabilityReport(FAILED));
assertEquals(slb.availabilityReport().state, FAILED);
assertEquals(slb.availabilityReport().subsystemStates.size(), 2);
assertTrue(Stream.of(slb.availabilityReport().subsystemStates.values()).allMatch(s -> s == FAILED));
when(log1.availabilityReport()).thenReturn(new AvailabilityReport(OPERATIONAL));
when(log2.availabilityReport()).thenReturn(new AvailabilityReport(FAILED));
assertEquals(slb.availabilityReport().state, PARTIALLY_OPERATIONAL);
assertEquals(slb.availabilityReport().subsystemStates.size(), 2);
assertTrue(slb.availabilityReport().subsystemStates.values().contains(OPERATIONAL));
assertTrue(slb.availabilityReport().subsystemStates.values().contains(FAILED));
}
Aggregations