Skip to content

Conversation

@sandhyasun
Copy link
Contributor

@sandhyasun sandhyasun commented Jun 27, 2025

Description.

  • Unit tests for corner cases and interaction with the IcebergHttpUtil etag generation method
  • Unit test for etag changes in the context of schema lifecycle changes
  • Integration tests for non-existent tables with etag passed in by client, malformed headers
  • Integration tests for DDL and DML changes affecting etags

Motivation.
The additonal tests ensure that the ETag mechanism correctly handles the most common table changes - schema evolution and DDL/ DML operations. This ensures caching correctness in scenarios where tables are actively being written to and callers are caching etags for performance reasons

Related change
Related original change (Commit 8b5dfa9) (#1037)

-Added a few corner case IT tests for testing etags with schema changes.
Copy link
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, @sandhyasun !

The tests looks very useful to me overall... just some minor comments.

}

@Test
public void testETagBehaviorForTableDropAndRecreate() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this test materially different from testETagChangeAfterMetadataLocationChange?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed - consolidated 3 tests into 1 that basically test metadata location change.

// Verify all ETags are different from each other
for (int i = 0; i < allETags.size(); i++) {
for (int j = i + 1; j < allETags.size(); j++) {
assertThat(allETags.get(i)).isNotEqualTo(allETags.get(j));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: might be more intuitive to put them all into a Set and check size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you forget to push? 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I still see nested loops 🤷 but it's a nit comment... approving.


try (Response currentEtagResponse = currentEtagInvocation.invoke()) {
// Should return 304 Not Modified because ETag matches current version
assertThat(currentEtagResponse.getStatus()).isEqualTo(Response.Status.NOT_MODIFIED.getStatusCode());
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it also make sense to test this when v3ETag is combined with v1ETag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added another case


// Create a mock data file entry
DataFile dataFile = DataFiles.builder(table.spec())
.withPath("/path/to/data/file1.parquet")
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure this will work with cloud storage 🤔 Why not table.locationProvider().newDataLocation(...)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True ! Fixed it.

@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Jun 30, 2025
@dimas-b dimas-b merged commit 9c0d209 into apache:main Jun 30, 2025
11 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Jun 30, 2025
@sandhyasun sandhyasun deleted the additionalEtagTests branch June 30, 2025 22:51
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.

2 participants