Skip to content

[Hadoop] Cover Azure and GCS credential property round trips - #1980

Merged
yili-db merged 3 commits into
unitycatalog:mainfrom
iamkiayun:contribution/1764-cloud-roundtrip
Oct 26, 2026
Merged

yili-db merged 3 commits into
unitycatalog:mainfrom
iamkiayun:contribution/1764-cloud-roundtrip

Conversation

@iamkiayun

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated (not applicable: tests only; no production behavior change).

Description of changes

Parameterize credential property round-trip tests across AWS, Azure, and GCS. The tests exercise credential property encoding and filesystem decoding with mocked credential fetchers and a local filesystem.

Coverage includes seeded single credentials, longest-prefix selection, missing and empty prefixes, rejection of uncovered paths when multiple credentials are returned, renewal through the same provider instance, and preserved AWS null-expiration behavior.

This changes tests only; production behavior is unchanged.

Fixes #1764.

Validation

  • Focused tests: 79 passed.
  • Full Hadoop tests: 1,490 passed.
  • javafmtCheckAll and git diff --check passed.
  • Full repository matrix and live-cloud tests were not run.

AI assistance: Codex helped implement the test changes, run validation, and review the code. I reviewed the final patch and authorized its submission and DCO sign-off.

@iamkiayun
iamkiayun marked this pull request as ready for review October 12, 2026 15:25
@yili-db

yili-db commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, this is a nice extension of the round-trip suite. The non-default EXPIRATION_MILLIS and the fetch-count verify calls make it meaningfully stronger than before. A few comments inline; the first three are the ones I care about, the rest are nits.

new AwsCredential("ak-a", "sk-a", "st-a", null, "s3://bucket/a"),
new AwsCredential("ak-b", "sk-b", "st-b", null, "s3://bucket/b"));
Configuration conf = createTableCredProps();
void awsCredentialWithoutExpirationRoundTrips() throws Exception {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we parameterize this over all clouds? The no-expiration path is where they actually differ: AWS and GCS default to Long.MAX_VALUE, but for Azure AbfsCredPropsBuilder writes the SAS token without an expiry, and AbfsVendedTokenProvider.initGenericCredential requires both, so the seeded token is dropped and the first access fetches. Is that intended? If not, let's file an issue; either way a test should pin the behavior per cloud.

long expirationMillis = clock.now().toEpochMilli() + 2_000L;
conf.setLong(cloud.expirationKey, expirationMillis);
GenericCredential initial = withExpiration(original, expirationMillis);
boolean seeded = cloud.initialCredentialKeys.stream().allMatch(key -> conf.get(key) != null);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This derives the expectation from the state under test. If seeding regressed, the helper would switch to the fetch-first stub and expected counts, and the renewal half would still pass. Can callers pass an explicit isSeeded instead?


private static void assertResolvedCreds(
GenericCredentialProvider provider, GenericCredential expected, String expectedPrefix) {
assertThat(provider.accessCredentials().prefix()).isEqualTo(expectedPrefix);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

accessCredentials() runs (and renews) before resolveCredentials() / getSASToken(...) / getAccessToken(), so those calls only read an already-renewed credential. Can we call the cloud-facing method first and check prefix/expiry after? Then the test proves the interface Hadoop actually calls triggers renewal.

private static void assertResolvedCreds(
AwsVendedTokenProvider provider, AwsCredential expected, String expectedPrefix) {
AwsSessionCredentials resolved = (AwsSessionCredentials) provider.resolveCredentials();
private static GenericCredential withExpiration(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Per-cloud dispatch now lives in three places in two styles (the enum switches, plus instanceof chains here and in assertResolvedCreds whose final else blindly casts to GCS). Can this move onto Cloud? E.g. credential(id, prefix, expirationMillis) would remove withExpiration entirely, and awsCredentialWithoutExpirationRoundTrips could use it too.

TableCredId expectedCredId =
new TableCredId(
delegateConf.get(UCHadoopConfConstants.UC_CRED_CONTEXT_ID_KEY), "table-id", "READ");
delegateConf.get(UCHadoopConfConstants.UC_CRED_CONTEXT_ID_KEY), "tid-1", "READ_WRITE");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: "tid-1" / "READ_WRITE" are duplicated with createTableCredProps. Extract constants so the two can't drift.

assertResolvedCreds(
provider,
initial,
initialPrefix == null || initialPrefix.isEmpty() ? null : initialPrefix);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: same empty-to-null normalization as in singleVendedCredentialRoundTripsWithoutRequiringUriCoverage; a tiny helper would do.

@yili-db

yili-db commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Thanks for addressing the earlier comments, this reads much cleaner now. One remaining item inline.

assertThat(resolved.accessKeyId()).isEqualTo("child-ak");
assertThat(resolved.secretAccessKey()).isEqualTo("child-sk");
assertThat(resolved.sessionToken()).isEqualTo("child-st");
cloud.assertResolvedCreds(cloud.provider(delegateConf), child, cloud.location());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] This resolve still goes through the JVM-wide globalCache: UC_CREDENTIAL_CACHE_ENABLED_KEY isn't propagated into delegateConf (as the new comment in credentialWithoutExpirationRoundTrips notes), reset() doesn't clear that cache, and the key is deterministic with an expiry of Long.MAX_VALUE - 1. Can we disable the cache once in getDelegateFileSystemConf and drop the one-off in credentialWithoutExpirationRoundTrips? A verify(fetcher).createCredentials() here would also prove the mock was actually used.

@yili-db

yili-db commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db
yili-db merged commit f395ceb into unitycatalog:main Oct 26, 2026
16 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.

[hadoop] Increase test coverage for CredPropsRoundTripTest

2 participants