Fix flaky regular player test

This commit is contained in:
Aurora Lahtela 2022-09-09 14:24:35 +03:00
parent 59a2909467
commit 54c66c7232
2 changed files with 8 additions and 2 deletions

View File

@ -250,8 +250,10 @@ public interface ActivityIndexQueriesTest extends DatabaseTestPreparer {
@RepeatedTest(25)
default void countRegularPlayers() {
storeSessions(session -> true);
long playtimeThreshold = TimeUnit.SECONDS.toMillis(1L);
long playtimeThreshold = TimeUnit.MILLISECONDS.toMillis(1L);
Integer expected = 1; // All players are very active
FinishedSession randomSession = RandomData.randomSession(serverUUID(), worlds, System.currentTimeMillis() - TimeUnit.HOURS.toMillis(1L), playerUUID, player2UUID);
db().executeTransaction(new StoreSessionTransaction(randomSession));
Integer result = db().query(ActivityIndexQueries.fetchRegularPlayerCount(System.currentTimeMillis(), serverUUID(), playtimeThreshold));
assertEquals(expected, result);
}

View File

@ -112,9 +112,13 @@ public class RandomData {
}
public static FinishedSession randomSession(ServerUUID serverUUID, String[] worlds, UUID... uuids) {
long start = RandomData.randomTime();
return randomSession(serverUUID, worlds, start, uuids);
}
public static FinishedSession randomSession(ServerUUID serverUUID, String[] worlds, long start, UUID... uuids) {
DataMap extraData = new DataMap();
extraData.put(WorldTimes.class, RandomData.randomWorldTimes(worlds));
long start = RandomData.randomTime();
long end = RandomData.randomTimeAfter(start);
if (uuids.length >= 2) {