Repository navigation
[Hadoop] Cover Azure and GCS credential property round trips - #1980
Conversation
Signed-off-by: Kee Kia Yun <[email protected]>
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
nit: same empty-to-null normalization as in singleVendedCredentialRoundTripsWithoutRequiringUriCoverage; a tiny helper would do.
Signed-off-by: Kee Kia Yun <[email protected]>
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[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()); |
There was a problem hiding this comment.
[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.
Signed-off-by: Kee Kia Yun <[email protected]>
|
/review |
PR Checklist
docsis 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
javafmtCheckAllandgit diff --checkpassed.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.