@@ -126,7 +126,7 @@ private static ContextIndexSearcher newContextSearcher(IndexReader reader) throw
126126 }
127127
128128 /**
129- * Test that a timeout is appropriately handled when the directory reader raises it while loading terms enum
129+ * Test that a timeout is appropriately handled when the (exitable) directory reader raises it while loading terms enum
130130 * as the scorer supplier is requested.
131131 */
132132 public void testScorerSupplierTimeoutTerms () throws IOException {
@@ -139,7 +139,7 @@ public void testScorerSupplierTimeoutTerms() throws IOException {
139139 }
140140
141141 /**
142- * Test that a timeout is appropriately handled when the directory reader raises it while loading points
142+ * Test that a timeout is appropriately handled when the (exitable) directory reader raises it while loading points
143143 * as the scorer supplier is requested.
144144 */
145145 public void testScorerSupplierTimeoutPoints () throws IOException {
@@ -201,7 +201,7 @@ public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOExcepti
201201 }
202202
203203 /**
204- * Test that a timeout is appropriately handled when the directory reader raises it while loading terms enum
204+ * Test that a timeout is appropriately handled when the (exitable) directory reader raises it while loading terms enum
205205 * as the scorer is retrieved from the scorer supplier
206206 */
207207 public void testScorerGetTimeoutTerms () throws IOException {
@@ -214,7 +214,7 @@ public void testScorerGetTimeoutTerms() throws IOException {
214214 }
215215
216216 /**
217- * Test that a timeout is appropriately handled when the directory reader raises it while loading points
217+ * Test that a timeout is appropriately handled when the (exitable) directory reader raises it while loading points
218218 * as the scorer is retrieved from the scorer supplier
219219 */
220220 public void testScorerGetTimeoutPoints () throws IOException {
@@ -375,6 +375,9 @@ private TestSearchContext createSearchContextWithTimeout(TimeoutQuery query, int
375375 TestSearchContext context = new TestSearchContext (null , indexShard , newContextSearcher (reader )) {
376376 @ Override
377377 public long getRelativeTimeInMillis () {
378+ // this controls whether a timeout is raised or not. We abstract time away by pretending that the clock stops
379+ // when a timeout is not expected. The tiniest increment to relative time in millis triggers a timeout.
380+ // See QueryPhase#getTimeoutCheck
378381 return query .shouldTimeout ? 1L : 0L ;
379382 }
380383 };
0 commit comments