Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add namespace validation for rename operation #7650

Merged
merged 1 commit into from Nov 6, 2023

Conversation

ajantha-bhat
Copy link
Contributor

Fixes #7645

@@ -132,6 +132,28 @@ public void testRefreshAfterMergeWithIcebergTableCaching()
.containsExactlyInAnyOrder(row(23, "test"), row(24, "test24"));
}

@Test
public void testRenameTableToMissingNamespace()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is way "too far away" from the changed code. A test needs to be in :nessie-versioned-storage-common-tests - such a test must also verify that the identified-key for CommitValidator works in that case.

Copy link
Member

@snazy snazy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test missing / wrong place.

@ajantha-bhat
Copy link
Contributor Author

Test missing / wrong place.

I tried adding a test in AbstractNamespaceValidation

@Test
  void RenameWithNonExistingNamespace() throws Exception {
    BranchName branch = BranchName.of("renameWithNonExistingNamespace");
    store().create(branch, Optional.empty());

    Namespace ns1 = Namespace.of("ns");
    Namespace ns2 = Namespace.of("non_existing");
    ContentKey key1 = ContentKey.of(ns1, "table");
    ContentKey key2 = ContentKey.of(ns2, "tbl");

    store()
      .commit(
        branch,
        Optional.empty(),
        fromMessage("create namespace ns"),
        singletonList(
          Put.of(ns1.toContentKey(), ns1)));

    OnRefOnly content = newOnRef("value");
    store()
      .commit(
        branch,
        Optional.empty(),
        fromMessage("create a table"),
        singletonList(Put.of(key1, content)));

    store()
      .commit(
        branch,
        Optional.empty(),
        fromMessage("rename table"),
        asList(Delete.of(key1), Put.of(key2, content)));
  }

But it seems it is not going to the place where I fixed.

I am not very familiar with that part of the code now. It would take too much time for me to understand it now.
Hence, I went with black box level testing. Agree that we should have unit tests for this. But I am not sure whether I
can work on it (or fix it soon).

@ajantha-bhat
Copy link
Contributor Author

But it seems it is not going to the place where I fixed.

I should fetch the content from the backend to use it for rename. Without that reusing the content object in the test class will be considered as new content as it is not having content id. Fixed now.

Copy link
Contributor

@adutra adutra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add an entry to CHANGELOG.md.

@adutra
Copy link
Contributor

adutra commented Oct 31, 2023

such a test must also verify that the identified-key for CommitValidator works in that case.

Namespace validation happens before the CommitValidator is invoked. The identified key is correctly created, but discarded when the validation error is thrown. I think that's fine?

@snazy snazy merged commit 1ee68ec into projectnessie:main Nov 6, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Namespace enforcement is not handled for rename operation.
4 participants