Uh oh!
There was an error while loading. Please reload this page.
test(aws): add S3 contract tests - #1065
Merged
Merged
Conversation
Contributor
Claude finished @mbevc1's task in 2m 51s —— View job PR Review: S3 contract tests
This is a well-constructed PR. The dual-target contract suite (fake + gated real-AWS) is exactly the right shape to stop the fake from drifting, and the seam design is clean. Static analysis
Strengths
Minor / optional (nothing blocking)
VerdictLooks good to merge. The observations above are all optional polish — I found no correctness bugs, and the previously-raised hardening items are resolved. |
Uh oh!
There was an error while loading. Please reload this page.
mbevc1
marked this pull request as ready for review
July 31, 2026 13:42
mbevc1
enabled auto-merge (squash)
July 31, 2026 13:42
mbevc1
commented
Jul 31, 2026
ContributorAuthor
Comments on the observations:
|
Introduce `S3ListAPI` (ListObjectsV2) and `S3DownloadAPI` (DownloadObject), combined into `S3API`, plus a `NewS3ClientFunc` factory that tests can replace. The real `*s3.Client` and `*transfermanager.Client` satisfy their half of the interface implicitly, so no adapter is needed. Split `GetS3Data` into a credentials-to-client entry point and `getS3DataFromClient`, mirroring the existing Lambda seam.
`runS3ContractTests` asserts the S3 behaviours this codebase depends on: object listing, continuation-token pagination, object download, and the error responses for unknown buckets and missing keys. The suite runs against both `FakeS3Client` (always) and real AWS (gated on credentials), so the fake cannot drift from the real API unnoticed.
Cover the paths real AWS cannot exercise cheaply: path and regex filters, folder-marker skipping, single-file versus directory fingerprinting and naming, multi-page listing, the newest-matched-object timestamp, and error propagation from listing and download. Filter selection is pinned by asserting that filtering the full bucket fingerprints identically to a bucket holding only the expected subset, which avoids hardcoding directory digests. This also gives `--include-regex` / `--exclude-regex` their first end-to-end coverage.
Inject `FakeS3Client` via `NewS3ClientFunc` in `SetupTest` and restore the real factory in TearDownTest, so all 11 cases run without AWS credentials. Three of these cases previously called live S3 with no credential gate at all, so they failed for anyone without AWS credentials; CI only masked it because the main test job configures them.
Reduce the live-S3 table from 10 cases to 4: the two credential and region error paths, a whole-bucket happy path, and one include-path case that keeps its fingerprint so drift in the test bucket is still detected. The nested-path, leading-slash and exclude cases now live in the fake-backed tests, where their fingerprints come from fixtures rather than live bucket content. Run the S3 contract tests against real AWS from make test_contract_aws.
The ADR claimed we always fake at the operation level, but that only described GitHub: LambdaAPI and ECSServicesAPI are SDK-level interfaces. State the rule we actually follow — prefer SDK-level when the SDK client is an ordinary Go type a fake can implement directly, fall back to operation-level when that would mean reimplementing SDK machinery — and use S3 as the worked example of a seam that mixes both.
staticcheck flags an error string whose first word is an ordinary
capitalized word, which failed the Lint job on two of the fake's
argument checks.
The sibling fakes escape the check only because their leading words
("FunctionName", "InvalidParameterException", "WriterAt") contain internal
capitals and read as identifiers. Reword all three of this file's argument
errors to start lowercase while still naming the SDK input field.Two odd inputs made the fake misbehave in ways real S3 would not: - MaxKeys of 0 gave every page zero objects while IsTruncated stayed true and the continuation token repeated, so s3.ListObjectsV2Paginator would spin forever. - A negative continuation token parsed fine via strconv.Atoi and then indexed the key slice out of range. Reject both rather than clamping them. Nothing in this package sets MaxKeys, so values below 1 sit outside the contract verified against real S3, and silently substituting a different page size is the kind of fake/real divergence contract tests exist to catch. The two new cases go in the fake-only block: real S3 accepts these inputs without erroring, so asserting on them in runS3ContractTests would break the real-AWS run.
DownloadObject looked the object body up before checking WriterAt, so a nil WriterAt combined with a missing key reported "object not found" instead of the programming error that actually caused it. Move the check up beside the Bucket and Key checks, so all required-input validation happens together and the more specific diagnostic wins.
mbevc1force-pushed
the
20260731_s3_contract_testing
branch
from
July 31, 2026 13:45
bbbcb20 to
a33359bCompareAlexKantor87
approved these changes
Jul 31, 2026
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
runS3ContractTestsasserts the S3 behaviours this codebase depends on:object listing, continuation-token pagination, object download, and the
error responses for unknown buckets and missing keys.
The suite runs against both
FakeS3Client(always) and real AWS (gated oncredentials), so the fake cannot drift from the real API unnoticed.
Related #758
Checklist
charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PR