diff options
author | Diego Zambelli Sessona <diego.sessona@gmail.com> | 2024-03-14 15:12:04 +0100 |
---|---|---|
committer | Diego Zambelli Sessona <diego.sessona@gmail.com> | 2024-03-15 16:13:23 +0100 |
commit | 242d514e6143b2d9c38b4bc27f4617289f27a853 (patch) | |
tree | 5383a16594750a03540b2b7561e4b87b7a39fb8e | |
parent | be8e6df913f8950f43a09348fff4a68f148e19fd (diff) |
Add tests for pagination to back fill the results
When querying Lucene, if we have not filled the full
limit the caller wants, `PaginatingSource.read()`
need to restart the source and continue. This should happen
regardless of the paginationType.
Bug: Issue 328958027
Release-Notes: skip
Change-Id: I02bc97eeecde2149e374dd036b87dd4c06034f27
-rw-r--r-- | javatests/com/google/gerrit/server/query/change/LuceneQueryChangesTest.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/javatests/com/google/gerrit/server/query/change/LuceneQueryChangesTest.java b/javatests/com/google/gerrit/server/query/change/LuceneQueryChangesTest.java index 9717bfb919..4996ff95d7 100644 --- a/javatests/com/google/gerrit/server/query/change/LuceneQueryChangesTest.java +++ b/javatests/com/google/gerrit/server/query/change/LuceneQueryChangesTest.java @@ -20,8 +20,10 @@ import static com.google.gerrit.common.data.GlobalCapability.QUERY_LIMIT; import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS; import static com.google.gerrit.testing.GerritJUnit.assertThrows; +import com.google.gerrit.entities.Account; import com.google.gerrit.entities.Change; import com.google.gerrit.extensions.restapi.BadRequestException; +import com.google.gerrit.server.account.AuthRequest; import com.google.gerrit.server.config.AllProjectsName; import com.google.gerrit.testing.InMemoryModule; import com.google.gerrit.testing.InMemoryRepositoryManager.Repo; @@ -31,6 +33,7 @@ import com.google.inject.Injector; import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.revwalk.RevCommit; +import org.junit.Ignore; import org.junit.Test; public abstract class LuceneQueryChangesTest extends AbstractQueryChangesTest { @@ -98,4 +101,27 @@ public abstract class LuceneQueryChangesTest extends AbstractQueryChangesTest { Change[] expected = new Change[] {change6, change5, change4, change3, change2, change1}; assertQuery(newQuery("project:repo").withNoLimit(), expected); } + + @Ignore + public void skipChangesNotVisible() throws Exception { + // create 1 new change on a repo + TestRepository<Repo> repo = createProject("repo"); + Change visibleChange = insert(repo, newChangeWithStatus(repo, Change.Status.NEW)); + Change[] expected = new Change[] {visibleChange}; + + // pagination does not need to restart the datasource, the request is fulfilled + assertQuery(newQuery("status:new").withLimit(1), expected); + + // create 2 new private changes + Account.Id user2 = + accountManager.authenticate(AuthRequest.forUser("anotheruser")).getAccountId(); + + Change invisibleChange1 = insert(repo, newChangeWithStatus(repo, Change.Status.NEW), user2); + Change invisibleChange2 = insert(repo, newChangeWithStatus(repo, Change.Status.NEW), user2); + gApi.changes().id(invisibleChange1.getChangeId()).setPrivate(true, null); + gApi.changes().id(invisibleChange2.getChangeId()).setPrivate(true, null); + + // pagination should back-fill when the results skipped because of the visibility + assertQuery(newQuery("status:new").withLimit(1), expected); + } } |