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

PoC: Rust-based integration test PoC #879

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mathiaspeters
Copy link
Contributor

@mathiaspeters mathiaspeters commented Oct 17, 2024

This PR is a PoC that should not be merged.

The purpose of this PR is to showcase two different methods of implementing rust-based integration tests for libtelio, to make discussing a related RFC easier.

The goal before anything related to this effort is merged is to not have any external dependencies that are not runnable and manageable directly from the test (starting a separate process from Rust to run separate binaries doesn't count), but to be able to start the RFC process, this PR only localizes the derp servers to rust. Because of that, the PoC vpn connection test cannot be run without at least the natlab vpn containers running

☑️ Definition of Done checklist

  • Commit history is clean (requirements)
  • README.md is updated
  • Functionality is covered by unit or integration tests

Copy link
Contributor

@tomasz-grz tomasz-grz left a comment

Choose a reason for hiding this comment

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

Nice work! Some quick initial thoughts before taking a deeper look

}

pub fn configure_ifc(ifc_name: &str, ip: IpAddr) {
run_command(
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this wouldn't work running the tests on macOS because it uses ifconfig for interface management. as far as I know there is no one cross-platform crate for doing so, only retrieving the configuration..

tun: None,
})
.unwrap();
self.dev.set_fwmark(11673110).unwrap();
Copy link
Contributor

@tomasz-grz tomasz-grz Oct 22, 2024

Choose a reason for hiding this comment

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

This also fails on macOS with

  --> systests/src/utils/test_client.rs:86:18
   |
86 |         self.dev.set_fwmark(11673110).unwrap();
   |                  ^^^^^^^^^^ method not found in `Device`

@@ -0,0 +1,59 @@
[package]
name = "systests"
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have a readme.md with some minimal instructions

mod tests;
mod utils;

fn main() {
Copy link
Contributor

@tomasz-grz tomasz-grz Oct 22, 2024

Choose a reason for hiding this comment

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

why don't we use the tests module approach here?

#[cfg(test)]
mod test_vpn {
    use super::*;

    #[test]
    fn test_vpn_poc_works() {
        test_vpn_poc();
    }
}

then we could get nicer test result reports like

thread 'test_vpn::test_vpn_poc_works' panicked at systests/src/tests/vpn.rs:51:5:
assertion failed: false
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Successfully executed 'ip link delete tun10'
Successfully executed 'ip rule del priority 32111'


failures:
    test_vpn::test_vpn_poc_works

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.22s

@lcruz99
Copy link
Contributor

lcruz99 commented Nov 22, 2024

I've been able to quickly run the tests with both methods.

Running the binary took half the time than with cargo test, despite the logs handling difference.

Great job!!

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.

3 participants