slackhappy commented on a change in pull request #1436: URL: https://github.com/apache/lucene-solr/pull/1436#discussion_r473302488
########## File path: solr/core/src/test/org/apache/solr/CursorPagingTest.java ########## @@ -499,6 +492,61 @@ public void testSimple() throws Exception { )); } + /** + * test that timeAllowed parameter can be used with cursors + * uses DelayingSearchComponent in solrconfig-deeppaging.xml + */ + public void testTimeAllowed() throws Exception { + String wontExceedTimeout = "10000"; + int numDocs = 100; + // Create a bunch of docs, inspired by createIndex in ExitableDirectoryReaderTest + for (int i = 0; i < numDocs; i++) { + assertU(adoc("id", Integer.toString(i), "name", "a" + i + " b" + i + " c" + i + " d"+i + " e" + i)); + if (random().nextInt(numDocs) == 0) { + assertU(commit()); // sometimes make multiple segments + } + } + assertU(commit()); + + String cursorMark; + SolrParams params = null; + + // start by triggering partial results - set the timeAllowed + // lower than the sleep used in DelayingSearchComponent + // NB: this only seems to work reliably if results havent + // been returned yet. + SolrParams partialParams = params("q", "name:a*", + "fl", "id", + "sort", "id desc", + "rows", "2", + "sleep", "10", + "timeAllowed", "1"); + + cursorMark = CURSOR_MARK_START; + + // assertCursor will confirm the nextCursorMark was set + String partialCursorMark = assertCursor(req(partialParams, CURSOR_MARK_PARAM, cursorMark) + , "/responseHeader/partialResults==true]" + ); + + // we can continue on, paging as normal + cursorMark = partialCursorMark; + params = params("q", "*:*", + "fl", "id", + "sort", "id desc", + "rows", "2", + "timeAllowed", wontExceedTimeout); + cursorMark = assertCursor(req(params, CURSOR_MARK_PARAM, cursorMark) + , "/response/numFound==100" + ); + assertNotEquals(cursorMark, partialCursorMark); + + cursorMark = assertCursor(req(params, CURSOR_MARK_PARAM, cursorMark) Review comment: good idea, maybe I'll run the cursor to the end, adding up the returned docs along the way, making sure we got them all, which would verify the cursor behavior, taking inspiration from Bram's patch: https://issues.apache.org/jira/secure/attachment/13010039/SOLR-14413-bram.patch ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org