Skip to content

Commit 009d9c1

Browse files
committed
GH-5834 test: repeat LMDB smoke query checks
1 parent 30dd999 commit 009d9c1

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/ThemeQueryBenchmarkSmokeIT.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class ThemeQueryBenchmarkSmokeIT {
4949
private static final String PHARMA_HAS_RESULT_LABEL = "pharma-hasResult";
5050
private static final String PHARMA_HAS_ARM_LABEL = "pharma-hasArm";
5151
private static final String PHARMA_P_VALUE_FILTER = "pharma-pValue-filter";
52+
private static final int QUERY_EXECUTION_REPETITIONS = 5;
5253

5354
@Test
5455
void executeQueryReturnsExpectedCountForMedicalRecordsQueryTwo() throws Exception {
@@ -58,23 +59,21 @@ void executeQueryReturnsExpectedCountForMedicalRecordsQueryTwo() throws Exceptio
5859

5960
benchmark.setup();
6061
try {
61-
assertEquals(ThemeQueryCatalog.expectedCountFor(Theme.MEDICAL_RECORDS, 2), benchmark.executeQuery());
62+
assertBenchmarkQueryCount(benchmark, Theme.MEDICAL_RECORDS, 2);
6263
} finally {
6364
benchmark.tearDown();
6465
}
6566
}
6667

6768
@Test
68-
void executeQueryTwiceReturnsExpectedCountForMedicalRecordsQueryTwo() throws Exception {
69+
void executeQueryRepeatedlyReturnsExpectedCountForMedicalRecordsQueryTwo() throws Exception {
6970
ThemeQueryBenchmark benchmark = new ThemeQueryBenchmark();
7071
benchmark.themeName = Theme.MEDICAL_RECORDS.name();
7172
benchmark.z_queryIndex = 2;
7273

7374
benchmark.setup();
7475
try {
75-
long expected = ThemeQueryCatalog.expectedCountFor(Theme.MEDICAL_RECORDS, 2);
76-
assertEquals(expected, benchmark.executeQuery());
77-
assertEquals(expected, benchmark.executeQuery());
76+
assertBenchmarkQueryCount(benchmark, Theme.MEDICAL_RECORDS, 2);
7877
} finally {
7978
benchmark.tearDown();
8079
}
@@ -110,7 +109,7 @@ void secondBenchmarkTrialReusesPersistedJoinEstimatorSnapshot() throws Exception
110109
first.z_queryIndex = 0;
111110
first.setup();
112111
try {
113-
assertEquals(ThemeQueryCatalog.expectedCountFor(Theme.MEDICAL_RECORDS, 0), first.executeQuery());
112+
assertBenchmarkQueryCount(first, Theme.MEDICAL_RECORDS, 0);
114113
} finally {
115114
first.tearDown();
116115
}
@@ -129,7 +128,7 @@ void secondBenchmarkTrialReusesPersistedJoinEstimatorSnapshot() throws Exception
129128
second.z_queryIndex = 1;
130129
second.setup();
131130
try {
132-
assertEquals(ThemeQueryCatalog.expectedCountFor(Theme.MEDICAL_RECORDS, 1), second.executeQuery());
131+
assertBenchmarkQueryCount(second, Theme.MEDICAL_RECORDS, 1);
133132
} finally {
134133
second.tearDown();
135134
}
@@ -147,12 +146,21 @@ private static void assertThemeQueryCount(Theme theme, int queryIndex) throws Ex
147146

148147
benchmark.setup();
149148
try {
150-
assertEquals(ThemeQueryCatalog.expectedCountFor(theme, queryIndex), benchmark.executeQuery());
149+
assertBenchmarkQueryCount(benchmark, theme, queryIndex);
151150
} finally {
152151
benchmark.tearDown();
153152
}
154153
}
155154

155+
private static void assertBenchmarkQueryCount(ThemeQueryBenchmark benchmark, Theme theme, int queryIndex) {
156+
long expected = ThemeQueryCatalog.expectedCountFor(theme, queryIndex);
157+
for (int repetition = 1; repetition <= QUERY_EXECUTION_REPETITIONS; repetition++) {
158+
assertEquals(expected, benchmark.executeQuery(),
159+
"Unexpected row count for " + theme + " query " + queryIndex + " on repetition " + repetition
160+
+ " of " + QUERY_EXECUTION_REPETITIONS);
161+
}
162+
}
163+
156164
private static List<Path> persistedSketchFiles(Path store) throws Exception {
157165
try (Stream<Path> paths = Files.find(store, 2,
158166
(path, attributes) -> attributes.isRegularFile()

testsuites/benchmark-common/src/main/java/org/eclipse/rdf4j/benchmark/common/ThemeQueryCatalog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ private static void validateQueries() {
17571757

17581758
private static void registerExpectedCountBindingValues() {
17591759
EXPECTED_COUNT_BINDING_VALUES.put(Theme.MEDICAL_RECORDS, expectedCountBindingValues(
1760-
7571, 49835, -1, 8309, 24971, 0, -1, 0, -1, 16352, 8335, -1, -1));
1760+
7571, 0, -1, 8309, 24971, 0, -1, 0, -1, 16352, 8335, -1, -1));
17611761
EXPECTED_COUNT_BINDING_VALUES.put(Theme.SOCIAL_MEDIA, expectedCountBindingValues(
17621762
6, 2, 3, -1, 5, 480, -1, 5, 3, 11, 2, -1, -1));
17631763
EXPECTED_COUNT_BINDING_VALUES.put(Theme.LIBRARY, expectedCountBindingValues(

testsuites/benchmark-common/src/test/java/org/eclipse/rdf4j/benchmark/common/ThemeQueryCatalogExpectedCountTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void expectedCountsMatchCatalogValues() {
4646
@Test
4747
void expectedCountBindingValuesMatchCatalogValues() {
4848
Map<Theme, long[]> expectedCountBindingValues = Map.of(
49-
Theme.MEDICAL_RECORDS, new long[] { 7571, 49835, -1, 8309, 24971, 0, -1, 0, -1, 16352, 8335,
49+
Theme.MEDICAL_RECORDS, new long[] { 7571, 0, -1, 8309, 24971, 0, -1, 0, -1, 16352, 8335,
5050
-1, -1 },
5151
Theme.SOCIAL_MEDIA, new long[] { 6, 2, 3, -1, 5, 480, -1, 5, 3, 11, 2, -1, -1 },
5252
Theme.LIBRARY, new long[] { 128853, 0, -1, 7958, 0, 217, -1, 77295, -1, 0, 4, -1, -1 },

0 commit comments

Comments
 (0)