Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for SDK extras and fix execute #933

Merged
merged 3 commits into from
Dec 16, 2024
Merged

Conversation

wfchandler
Copy link
Contributor

@wfchandler wfchandler commented Dec 2, 2024

We've been relying on the CLI disk import tests to cover the extras disk importer in the SDK. However, the CLI does not use the execute method, and we missed that this was failing immediately due to the cancellation sender being dropped before the request could awaited.

Add tests for extras to validate that both options work. Also, add a method to DiskImport that does not accept cancellation and use that in execute.

Closes #930

let (fut, handle) = self.execute_with_control()?;

// Leak the handle so we don't cancel the request by dropping it.
mem::forget(handle);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this seems a bit inelegant. Did we consider other options such as a run_without_cancel function, ignoring cancelation from cancel_rx in run_with_cancel or returning a new Future here that holds onto the handle so that it isn't dropped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair, I've added a run method that doesn't take a cancel channel.

@ahl
Copy link
Collaborator

ahl commented Dec 3, 2024

Also: worth adding a test here?

@wfchandler wfchandler changed the title Don't cancel uploads run without control Add tests for SDK extras and fix execute Dec 5, 2024
@wfchandler
Copy link
Contributor Author

Also: worth adding a test here?

Yes, great point! I've added a high level test for this.

@wfchandler wfchandler requested a review from ahl December 5, 2024 17:43
@@ -0,0 +1,135 @@
use httpmock::MockServer;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add the license and copyright headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks

Currently `execute` will drop the import handle immediately,
inadvertently canceling the request.

Leak the handle, which will never be used, so that we allow the request
to run to completion.

Closes #930
We've been relying on the CLI disk import tests to cover the `extras`
disk importer in the SDK. However, the CLI does not use the `execute`
method, and we missed that this was failing immediately due to the
cancellation sender being dropped before the request could awaited.

Add tests for `extras` to validate that both options work. Also, add a
method to DiskImport that does not accept cancellation and use that in
`execute`.
@wfchandler
Copy link
Contributor Author

Rebased to resolve merge conflict.

@wfchandler wfchandler merged commit f0011ca into main Dec 16, 2024
16 checks passed
@wfchandler wfchandler deleted the wc/fix-disk-upload branch December 16, 2024 17:25
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.

disk_import().execute() fails with Error: Disk import canceled
2 participants