rahil-c commented on code in PR #9782: URL: https://github.com/apache/iceberg/pull/9782#discussion_r1577061740
########## core/src/test/java/org/apache/iceberg/rest/TestRESTViewCatalog.java: ########## @@ -144,6 +157,65 @@ public void closeCatalog() throws Exception { } } + @Test + public void testPaginationForListViews() { + RESTCatalogAdapter adapter = Mockito.spy(new RESTCatalogAdapter(backendCatalog)); + RESTCatalog catalog = + new RESTCatalog(SessionCatalog.SessionContext.createEmpty(), (config) -> adapter); + catalog.initialize("test", ImmutableMap.of(RESTSessionCatalog.REST_PAGE_SIZE, "10")); + + int numberOfItems = 20; + int numberOfInvocations = 2; + String namespaceName = "newdb"; + String viewName = "newview"; + + // create initial namespace + catalog().createNamespace(Namespace.of(namespaceName)); + + // create several views under namespace, based off a table for listing and verify + for (int i = 0; i < numberOfItems; i++) { + TableIdentifier viewIndentifier = TableIdentifier.of(namespaceName, viewName + i); + catalog + .buildView(viewIndentifier) + .withSchema(SCHEMA) + .withDefaultNamespace(viewIndentifier.namespace()) + .withQuery("spark", "select * from ns.tbl") + .create(); + } + List<TableIdentifier> views = catalog.listViews(Namespace.of(namespaceName)); + assertThat(views).hasSize(numberOfItems); + + Mockito.verify(adapter) + .execute( + eq(HTTPMethod.GET), + eq("v1/config"), + any(), + any(), + eq(ConfigResponse.class), + any(), + any()); + + Mockito.verify(adapter, times(numberOfItems)) + .execute( + eq(HTTPMethod.POST), + eq(String.format("v1/namespaces/%s/views", namespaceName)), + any(), + any(), + eq(LoadViewResponse.class), + any(), + any()); + + Mockito.verify(adapter, times(numberOfInvocations)) + .execute( + eq(HTTPMethod.GET), + eq(String.format("v1/namespaces/%s/views", namespaceName)), + eq(ImmutableMap.of("pageToken", "10", "pageSize", "10")), Review Comment: Yea I had tried out a similar example to what you shared above, and mentioned the issues i faced here https://github.com/apache/iceberg/pull/9782#discussion_r1571188458, when i tried make two seperate requests, like so : ``` Mockito.verify(adapter) .execute( eq(HTTPMethod.GET), eq("v1/namespaces"), eq(ImmutableMap.of("pageToken", "", "pageSize", "10")), any(), eq(ListNamespacesResponse.class), any(), any()); Mockito.verify(adapter) .execute( eq(HTTPMethod.GET), eq("v1/namespaces"), eq(ImmutableMap.of("pageToken", "10", "pageSize", "10")), any(), eq(ListNamespacesResponse.class), any(), any()); ``` It always fail on the first request, i think because this list namespaces endpoint is hit multiple times and the last value of the query params is `"pageToken", "10", "pageSize", "10"` is what gets called thus leading to this exception, instead of what was sent intially. ``` Argument(s) are different! Wanted: rESTCatalogAdapter.execute( GET, "v1/namespaces", {"pageToken" = "", "pageSize" = "10"}, <any>, class org.apache.iceberg.rest.responses.ListNamespacesResponse, <any>, <any> ); ``` -- 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. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org