Skip to content

Commit 3e2fc19

Browse files
committed
Timescale comments
1 parent f654812 commit 3e2fc19

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

bosk-mongo/src/main/java/works/bosk/drivers/mongo/MongoDriverSettings.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ public class MongoDriverSettings {
1515
String database;
1616

1717
/**
18-
* The general responsiveness of the system. Changes to the database will be
19-
* "noticed" in about this many milliseconds, and other time-related behaviours
20-
* will be scaled accordingly. Lower values are more responsive, while higher
21-
* values are more efficient because they'll do less polling.
18+
* The general responsiveness of the system under unusual circumstances.
19+
* Changes to the database connectivity and status will be "noticed"
20+
* in about this many milliseconds, and other time-related behaviours
21+
* are scaled accordingly.
22+
* Lower values recover more quickly, but will also give up sooner
23+
* and cause more network traffic;
24+
* higher values are more patient and efficient, but slower to recover.
25+
* <p>
26+
* Under normal circumstances, the system responds promptly
27+
* and efficiently regardless of this setting.
2228
* <p>
2329
* For test cases,
2430
*
@@ -32,6 +38,9 @@ public class MongoDriverSettings {
3238
* to avoid spurious test failures.
3339
* </li>
3440
* </ul>
41+
*
42+
* In Bosk's own tests, we use even more extreme values to ensure
43+
* this works across a wide range of values.
3544
*/
3645
@Default int timescaleMS = 1000;
3746

bosk-mongo/src/test/java/works/bosk/drivers/mongo/internal/MongoDriverRecoveryTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void initialOutage_recovers() throws InvalidTypeException, InterruptedException,
136136

137137
LOGGER.debug("Wait and check that the state updates");
138138
// With FLUSH this succeeds almost immediately.
139-
// With WAIT it is artificially delayed.
139+
// With WAIT, it is artificially delayed.
140140
waitFor(driver);
141141
try (var _ = bosk.readContext()) {
142142
assertEquals(initialState, bosk.rootReference().value(),
@@ -253,6 +253,9 @@ void revisionDeleted_recovers() throws InterruptedException, IOException {
253253
Bosk<TestEntity> bosk = new Bosk<>(boskName(getClass().getSimpleName()), TestEntity.class, AbstractMongoDriverTest::initialRoot, BoskConfig.<TestEntity>builder().driverFactory(driverFactory).build());
254254

255255
try (var _ = bosk.readContext()) {
256+
// This can fail on very short timescales; see testRecovery.
257+
// This isn't related to the revision deletion issues described above
258+
// and shouldn't really be grounds for removing this test.
256259
assertEquals(beforeState, bosk.rootReference().value());
257260
}
258261

@@ -320,6 +323,9 @@ private void testRecovery(Runnable disruptiveAction, Function<TestEntity, TestEn
320323
Bosk<TestEntity> bosk = new Bosk<>(boskName(getClass().getSimpleName()), TestEntity.class, AbstractMongoDriverTest::initialRoot, BoskConfig.<TestEntity>builder().driverFactory(driverFactory).build());
321324

322325
try (var _ = bosk.readContext()) {
326+
// Note: with very short timescales, this assertion can fail because the newly created bosk
327+
// times out trying to read the database contents and instead uses AbstractMongoDriverTest::initialRoot.
328+
// This is actually valid behaviour for a sufficiently impatient user.
323329
assertEquals(beforeState, bosk.rootReference().value());
324330
}
325331

0 commit comments

Comments
 (0)