Tests: Add garage integration tests #215

Closed
KokaKiwi wants to merge 8 commits from KokaKiwi/garage:integration-tests into main
Owner

Use the aws-sdk-s3 crate as S3 client implementation.

To test-run the suite:

$ cargo test -p garage --test integration

The integration test can be configured by setting some env vars:

  • GARAGE_TEST_INTEGRATION_PORT: Garage server port to run on (default: 49995)
    NB: The config will actually bind the specified port plus the two following (49996 and 49997 for default value)
  • GARAGE_TEST_INTEGRATION_PATH: Garage test runtime directory (default: /tmp/garage-integ-test-<PORT>)
  • GARAGE_TEST_INTEGRATION_EXE: Garage executable path (default: $CARGO_BIN_EXE_garage)
Use the [`aws-sdk-s3`](https://crates.io/crates/aws-sdk-s3) crate as S3 client implementation. To test-run the suite: ``` $ cargo test -p garage --test integration ``` The integration test can be configured by setting some env vars: - `GARAGE_TEST_INTEGRATION_PORT`: Garage server port to run on (default: 49995) **NB:** The config will actually bind the specified port plus the two following (49996 and 49997 for default value) - `GARAGE_TEST_INTEGRATION_PATH`: Garage test runtime directory (default: `/tmp/garage-integ-test-<PORT>`) - `GARAGE_TEST_INTEGRATION_EXE`: Garage executable path (default: `$CARGO_BIN_EXE_garage`)
KokaKiwi added 1 commit 2022-02-02 14:40:51 +00:00
continuous-integration/drone/pr Build is failing Details
539b256525
tests: Add garage integration tests (base)
KokaKiwi force-pushed integration-tests from 1fcf363a60 to ff064b8892 2022-02-02 15:29:45 +00:00 Compare
KokaKiwi force-pushed integration-tests from ff064b8892 to 06ad505cb5 2022-02-03 11:55:50 +00:00 Compare
KokaKiwi added 2 commits 2022-02-04 10:50:35 +00:00
continuous-integration/drone/push Build is failing Details
30f1608149
Upgrade cargo2nix
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is failing Details
f1679c6a08
Add integration tests to Drone
quentin approved these changes 2022-02-04 14:07:21 +00:00
quentin left a comment
Owner

LGTM, this is exactly what I imagined for a first version :-)
I have some questions to better understand your code, but I am OK to merge it.

Maybe we should wait until monday if Alex wants to review the code, but I pretty confident that we will be able to merge it very soon :-)

LGTM, this is exactly what I imagined for a first version :-) I have some questions to better understand your code, but I am OK to merge it. Maybe we should wait until monday if Alex wants to review the code, but I pretty confident that we will be able to merge it very soon :-)
@ -0,0 +1,3 @@
pub use process::*;
Owner

What does ext means? What is the purpose of this module?

What does `ext` means? What is the purpose of this module?
Author
Owner

common::ext is meant to contains some "extension" helpers traits, mainly for stuff contained in std::process structs actually.

`common::ext` is meant to contains some "extension" helpers traits, mainly for stuff contained in `std::process` structs actually.
KokaKiwi marked this conversation as resolved
@ -0,0 +184,4 @@
static INSTANCE_INIT: Once = Once::new();
#[static_init::destructor]
extern "C" fn terminate_instance() {
Owner

Why do you need extern "C" here?

Why do you need `extern "C"` here?
Author
Owner

It's required by the static_init::destructor attribute, as it register the function to be called by libc global ctor/dtor stuff

It's required by the `static_init::destructor` attribute, as it register the function to be called by libc global ctor/dtor stuff
KokaKiwi marked this conversation as resolved
@ -0,0 +200,4 @@
INSTANCE.write(instance);
});
unsafe { INSTANCE.assume_init_ref() }
Owner

Do you have any documentation explaining why unsafe is required in this function and the previous one?

Do you have any documentation explaining why `unsafe` is required in this function and the previous one?
Author
Owner

The unsafe blocks here are required because:

  1. INSTANCE is a mutable static, accessing/modifying is unsafe by definition: https://doc.rust-lang.org/nomicon/what-unsafe-does.html
  2. INSTANCE is of MaybeUninit<T> type, accessing its value is unsafe it could be uninitialized at the time it's accessed: std::mem::MaybeUninit::assume_init_ref (see Safety section)

I'll add some changes here to document why these unsafe blocks are actually sound ("safe")

The unsafe blocks here are required because: 1. `INSTANCE` is a mutable static, accessing/modifying is unsafe by definition: https://doc.rust-lang.org/nomicon/what-unsafe-does.html 2. `INSTANCE` is of `MaybeUninit<T>` type, accessing its value is unsafe it could be uninitialized at the time it's accessed: [`std::mem::MaybeUninit::assume_init_ref`](https://doc.rust-lang.org/std/mem/union.MaybeUninit.html#method.assume_init_ref) (see `Safety` section) I'll add some changes here to document why these unsafe blocks are actually sound ("safe")
KokaKiwi marked this conversation as resolved
@ -0,0 +1,11 @@
macro_rules! assert_bytes_eq {
Owner

Just curiosity here, but why did you define a macro instead of a function here?

Just curiosity here, but why did you define a macro instead of a function here?
Author
Owner

Simply because i wanted to keep the code convention about test assertions utilities: assert!, assert_eq! and assert_ne!

Simply because i wanted to keep the code convention about test assertions utilities: `assert!`, `assert_eq!` and `assert_ne!`
KokaKiwi marked this conversation as resolved
@ -0,0 +1,61 @@
use crate::common;
#[tokio::test]
async fn test_simple() {
Owner

happy to see that writing an integration test if very elegant and straightforwrd, gg :-)

happy to see that writing an integration test if very elegant and straightforwrd, gg :-)
KokaKiwi marked this conversation as resolved
Owner

You should also rebase your branch on main, LX merged a patch recently.

You should also rebase your branch on main, LX merged a patch recently.
KokaKiwi added 2 commits 2022-02-04 16:56:30 +00:00
continuous-integration/drone/push Build is failing Details
ae2f32baf1
Hide deleted key in bucket info (fix #211)
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone Build is passing Details
935670690f
Probably fix test-smoke
KokaKiwi force-pushed integration-tests from c6aedebb67 to 2e1b48424a 2022-02-07 13:50:34 +00:00 Compare
KokaKiwi self-assigned this 2022-02-10 10:43:08 +00:00
KokaKiwi force-pushed integration-tests from db3d23c4e5 to 71496c9f4e 2022-02-10 16:04:17 +00:00 Compare
KokaKiwi closed this pull request 2022-02-10 16:05:45 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
Required
Details

Pull request closed

Sign in to join this conversation.
No description provided.