adutra commented on code in PR #8857: URL: https://github.com/apache/iceberg/pull/8857#discussion_r1404533616
########## nessie/src/test/java/org/apache/iceberg/nessie/TestMultipleClients.java: ########## @@ -67,33 +71,84 @@ public void afterEach() throws Exception { } @Test - public void testListNamespaces() { + public void testListNamespaces() throws NessieConflictException, NessieNotFoundException { + Assertions.assertThat(catalog.listNamespaces()).isEmpty(); + Assertions.assertThat(anotherCatalog.listNamespaces()).isEmpty(); + + // listing a non-existent namespace should return empty + Assertions.assertThat(catalog.listNamespaces(Namespace.of("db1"))).isEmpty(); + Assertions.assertThat(anotherCatalog.listNamespaces(Namespace.of("db1"))).isEmpty(); + catalog.createNamespace(Namespace.of("db1"), Collections.emptyMap()); + Assertions.assertThat(catalog.listNamespaces()).containsExactlyInAnyOrder(Namespace.of("db1")); + Assertions.assertThat(anotherCatalog.listNamespaces()) + .containsExactlyInAnyOrder(Namespace.of("db1")); // another client creates a namespace with the same nessie server anotherCatalog.createNamespace(Namespace.of("db2"), Collections.emptyMap()); - Assertions.assertThat(anotherCatalog.listNamespaces()) - .containsExactlyInAnyOrder(Namespace.of("db1"), Namespace.of("db2")); Assertions.assertThat(catalog.listNamespaces()) .containsExactlyInAnyOrder(Namespace.of("db1"), Namespace.of("db2")); + Assertions.assertThat(anotherCatalog.listNamespaces()) + .containsExactlyInAnyOrder(Namespace.of("db1"), Namespace.of("db2")); + + api.deleteBranch().branch((Branch) api.getReference().refName(branch).get()).delete(); + + Assertions.assertThatThrownBy(() -> catalog.listNamespaces()) + .hasMessageContaining( + "Cannot list top-level namespaces: ref '%s' is no longer valid", branch); + Assertions.assertThatThrownBy(() -> anotherCatalog.listNamespaces(Namespace.of("db1"))) + .hasMessageContaining( + "Cannot list child namespaces from 'db1': ref '%s' is no longer valid", branch); } @Test - public void testLoadNamespaceMetadata() { + public void testLoadNamespaceMetadata() throws NessieConflictException, NessieNotFoundException { + + Assertions.assertThatThrownBy(() -> catalog.loadNamespaceMetadata(Namespace.of("namespace1"))) Review Comment: Adding more tests here as requested by @snazy brought up an interesting issue. I _think_ the test was wrong, but I'd like others to confirm: Previously, the call to `anotherCatalog.setProperties` was succeeding only because `anotherCatalog` was uninitialized. Therefore, before committing, an initial refresh was being done which was updating the ref to the current HEAD. Now that a few operations are being done _before_ the namespace creation, the call to `anotherCatalog.setProperties` is failing because that client is still on the old hash and does not know about the new namespace. I think this is the right behavior. But I also admit that it's a bit confusing that `anotherCatalog` is able to _see_ the new namespace (e.g. with `listNamespaces` and `loadNamespaceMetadata`), but is not able to _update_ it (or drop it). That's a direct consequence of the current behavior: * Committing operations always commit on the ref's last known hash, and refresh the ref once the commit is done. * Non-committing operations ignore the ref's known hash and always fetch contents from the ref's most recent HEAD, and they do not refresh after. Do we all agree with this behavior? -- 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