@@ -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 ()
0 commit comments