-
Notifications
You must be signed in to change notification settings - Fork 9
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
Mock S3 tests instead of using s3-server #131
Comments
Yeah, I think this one is important, as we would like to use rustls for everything if possible. |
Currently the only place this comes up is here: htsget-rs/htsget-search/src/storage/aws.rs Lines 247 to 252 in 4ed6d8e
If we wanted to remove this without any additional dependencies, we could refactor calls to the aws sdk into a trait, and mock a test implementation to only test the logic of our code, as suggested here. |
Indeed, we should just mock instead of running a server in the background, although isn't mocking per-method a bit tedious? We'll need to rejig those tests:
This issue outlines how to mock at a full |
I'm also thinking how to provide a simple method to mock a full S3 client. The auto-generated S3 trait may give you a kind of inspiration. Here is an example of how to implement the trait. |
Thanks for the detailed response, @Nugine! I'd be very interested in full S3 client mocking since I'd like to avoid having s3 servers running when running the testsuite (less complexity and less problems with deployment, operations, ports, etc..). |
@Nugine, I'm wondering if https://crates.io/crates/s3s-aws is your ongoing effort to "mock a full S3 client", I'm a bit on a holding pattern to see what to use that doesn't require a running s3 server with open ports in the background :) |
s3s-aws provides two different types:
Here is an example combining The logical call stack is like this:
It does not bind any port. The whole action happens in the test process. Note that However, |
Thanks a ton @Nugine, I just migrated the tests and they seem to work... could you please publish your latest 0.2.1-dev changes from your master so that I can pin it to a version from crates.io? I'm pointing it to your git repo for the moment on PR #150 but it'll probably break soon if it's not pinned. |
I released v0.3.0 just now. It contains several bug fixes and a small break change. Feel free to open issues if you find any problem. |
* fix(search) Bump up s3s-* crates as suggested in #131 (comment) * test(search): fix tests related to improperly formatted `folder` in URLs for S3 mock filesystem * fix(search): check that a key exists before formatting a URL, ensuring that pre-signed URLs are not generated for non-existent keys * fix(search): use KeyNotFound error when a key is not found * fix(search): use KeyNotFound for head and get object in AwsS3Storage * test(search): add set of tests targeting non-existent keys * build(search): remove unused dependencies --------- Co-authored-by: Marko Malenic <[email protected]>
See issues:
This only affects testing, but it pulls in vulnerable Rust deps and also OpenSSL which we really don't need nor want.
The text was updated successfully, but these errors were encountered: