Skip to content

test(r2): run the multipart upload test - #1155

Open
instantraaamen wants to merge 1 commit into
cloudflare:mainfrom
instantraaamen:test/r2-multipart
Open

instantraaamen wants to merge 1 commit into
cloudflare:mainfrom
instantraaamen:test/r2-multipart

Conversation

@instantraaamen

Copy link
Copy Markdown

Problem

test/src/r2.rs has put_multipart, and test/src/router.rs registers it at /r2/put-multipart, but nothing in test/tests/r2.spec.ts requests that route. Multipart upload has no test that runs.

The route could not pass as written. Calling it gives:

TypeError: Part number must be between 1 and 10000 (inclusive). Actual value was: 0

It numbers its parts 0, 1, 2, and its sizes are 5MiB+100, 5MiB+200, 500, while every part except the last has to be the same size. Both points were raised in the comments of #273, which was closed without being merged.

Fix

  • test/src/r2.rs: number the parts from 1, make the first two parts the same size, and adjust the byte assertions to the new sizes.
  • test/tests/r2.spec.ts: add a put multipart test that calls the route.

No change to the worker crate, so no changeset.

Tests

npm test on macOS: with only the spec calling the route, put multipart fails with the error above; with the route fixed as well it passes. npm run lint and cargo fmt --all --check pass. One test fails for me with and without this change: socket.spec.ts "read", because port 8080 is taken on my machine.

I checked the equal-size rule in a separate Worker, not through this suite: the original route stops at the part number before it gets that far.

resume_multipart_upload has no test either. I left it out to keep this small, and can add a route for it here or in a follow-up if that is wanted.

Found while evaluating workers-rs for an existing TypeScript Worker: I wrote the same routes in both and compared the results. With 1-based parts of equal size, resumed by id across separate requests, workers-rs 0.9.0 matched JavaScript for upload, complete, reading across a part boundary, abort twice, a part sent to an aborted upload, and complete with a wrong etag. The one difference I found is in a follow-up PR stacked on this one.

The /r2/put-multipart route was registered but no spec requested it. It also could not pass: it numbered parts from 0, and its first two parts had different sizes.

Number the parts from 1, give the leading parts the same size, and call the route from r2.spec.ts.
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.

1 participant