@Test(invocationCount = 5)
public void testIncrementalRealtimeExpiration()
throws Exception {
String tableName = CryptUtil.generateRandomKey(10);
populate(tableName);
MaterializedView view = new MaterializedView("testview", "testview", format("select count(*) as count from %s", checkCollection(tableName)), Duration.ofSeconds(1), true, true, ImmutableMap.of());
getMaterializedViewService().create(new RequestContext(PROJECT_NAME), view).join();
QueryExecutorService queryService = getQueryService();
QueryResult result = queryService.executeQuery(PROJECT_NAME, "select * from materialized.testview", ZoneId.systemDefault()).getResult().join();
assertFalse(result.isFailed());
populate(tableName);
getClock().increment(Duration.ofSeconds(2).toMillis());
result = queryService.executeQuery(PROJECT_NAME, "select * from materialized.testview", ZoneId.systemDefault()).getResult().join();
assertFalse(result.isFailed());
int total = 0;
for (List<Object> objects : result.getResult()) {
total += ((Number) objects.get(0)).intValue();
}
assertEquals(SCALE_FACTOR * 2, total);
}