Skip to content

Commit 8dfb7ea

Browse files
committed
Timescale constants
1 parent d02cd3b commit 8dfb7ea

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import static ch.qos.logback.classic.Level.ERROR;
3030
import static org.junit.jupiter.api.Assertions.assertEquals;
3131
import static org.junit.jupiter.api.Assertions.assertThrows;
32+
import static works.bosk.drivers.mongo.internal.TestParameters.SHORT_TIMESCALE;
3233
import static works.bosk.testing.BoskTestUtils.boskName;
3334
import static works.bosk.ListingEntry.LISTING_ENTRY;
3435
import static works.bosk.drivers.mongo.internal.MainDriver.COLLECTION_NAME;
@@ -62,7 +63,7 @@ static Stream<TestParameters.ParameterSet> parameters() {
6263
),
6364
Stream.of(TestParameters.EventTiming.NORMAL)
6465
).map(b -> b.applyDriverSettings(s -> s
65-
.timescaleMS(100) // Note that some tests can take as long as 25x this
66+
.timescaleMS(SHORT_TIMESCALE) // Note that some tests can take as long as 25x this
6667
));
6768
}
6869

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import static org.junit.jupiter.api.Assertions.assertNull;
5757
import static org.junit.jupiter.api.Assertions.assertThrows;
5858
import static org.junit.jupiter.api.Assertions.assertTrue;
59+
import static works.bosk.drivers.mongo.internal.TestParameters.SHORT_TIMESCALE;
5960
import static works.bosk.testing.BoskTestUtils.boskName;
6061
import static works.bosk.ListingEntry.LISTING_ENTRY;
6162

@@ -78,7 +79,7 @@ static Stream<TestParameters.ParameterSet> parameters() {
7879
),
7980
Stream.of(TestParameters.EventTiming.NORMAL)
8081
).map(b -> b.applyDriverSettings(s -> s
81-
.timescaleMS(100) // Note that some tests can take as long as 25x this
82+
.timescaleMS(SHORT_TIMESCALE) // Note that some tests can take as long as 25x this
8283
));
8384
}
8485

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
public class TestParameters {
1313
private static final AtomicInteger dbCounter = new AtomicInteger(0);
1414

15+
/**
16+
* For tests that are expecting timeouts. A short value makes the tests run faster.
17+
* Too short, and the tests might not be testing the right thing.
18+
* This should be much larger than the expected latency of MongoDB and the network.
19+
*/
20+
public static final int SHORT_TIMESCALE = 100;
21+
22+
/**
23+
* For tests that are not expecting timeouts. A nice long value makes spurious test failures unlikely.
24+
*/
25+
public static final int LONG_TIMESCALE = 90_000;
26+
1527
@Value
1628
public static class ParameterSet {
1729
String name;
@@ -26,7 +38,7 @@ public static ParameterSet from(MongoDriverSettings.DatabaseFormat format, Event
2638
timing + "," + format,
2739
MongoDriverSettings.builder()
2840
.preferredDatabaseFormat(format)
29-
.timescaleMS(90_000) // Tests that actually exercise timeouts should use a much shorter value
41+
.timescaleMS(LONG_TIMESCALE)
3042
.testing(MongoDriverSettings.Testing.builder()
3143
.eventDelayMS(timing.eventDelayMS)
3244
.build())

0 commit comments

Comments
 (0)