-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple e2e testing framework, passthrough and corner case tests
Signed-off-by: Eloi DEMOLIS <eloi.demolis@clever-cloud.com> make tests.rs to a test module, allow unused code in e2e exclude e2e tests from tarpaulin use serial-test to run tests sequentially Repeated tests, to run the same function multiple times zombie crash test for #806 tests for #808 and #810 Invalid HTTP content-length test test for #810, HTTP variant of TCP crash on missing listeners Upgrade test (not working) test_issue_806 can yield an Undecided
- Loading branch information
Showing
21 changed files
with
1,797 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "sozu-e2e" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
sozu-lib = { path = "../lib" } | ||
sozu-command-lib = { path = "../command" } | ||
slab = "^0.4.7" | ||
mio = "^0.8.4" | ||
time = "^0.3.14" | ||
futures = "^0.3.24" | ||
libc = "^0.2.138" | ||
serial_test = "^0.10.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# End to end tests | ||
|
||
We want to check Sōzu's behavior in all corner cases for the CI. | ||
|
||
## Principles | ||
|
||
This crate contains thin wrappers around the Sōzu lib, that create: | ||
|
||
- a Sōzu worker with a very simple config, able to run a detached thread | ||
- mocked clients that send simple HTTP requests | ||
- mocked backends, sync and async, that reply dummy 200 OK responses (for instance) | ||
|
||
This crate provides the `Aggregator` trait, that allows to create simple aggregators. | ||
The aggregators keep track, for instance, of how many requests were received, | ||
and how many were sent, by a backend (just an example). | ||
|
||
These elements are instantiated in test functions. They aim at both normal behaviour | ||
(traffic passthrough) but also tackle corner cases, such as: | ||
|
||
- smooth soft stop | ||
- immediate hard stop | ||
- behaviour of the zombie checker | ||
- reconnection to a backend | ||
|
||
# How to run | ||
|
||
The tests are flagged with the usual macros, so they will run with all other tests when you do: | ||
|
||
cargo test | ||
|
||
All tests are run one at a time with the `#[serial]` macro. You can run just one using | ||
|
||
cargo test test_issue_810_timeout | ||
|
||
If you want to run all e2e tests at once, do: | ||
|
||
cd e2e | ||
cargo test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
pub fn http_ok_response<S: Into<String>>(content: S) -> String { | ||
let content = content.into(); | ||
let status_line = "HTTP/1.1 200 OK"; | ||
let length = content.len(); | ||
format!( | ||
"{}\r\nContent-Length: {}\r\n\r\n{}", | ||
status_line, length, content | ||
) | ||
} | ||
|
||
/// Creates an HTTP/1 raw request | ||
pub fn http_request<S1: Into<String>, S2: Into<String>, S3: Into<String>>( | ||
method: S1, | ||
uri: S2, | ||
content: S3, | ||
) -> String { | ||
let content = content.into(); | ||
let length = content.len(); | ||
format!( | ||
"{} {} HTTP/1.1\r\nHost: localhost\r\nConnection: keep-alive\r\nContent-Length: {}\r\n\r\n{}", | ||
method.into(), | ||
uri.into(), | ||
length, | ||
content, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
#![allow(dead_code)] | ||
|
||
mod http_utils; | ||
mod mock; | ||
mod sozu; | ||
#[cfg(test)] | ||
#[cfg(not(tarpaulin))] | ||
mod tests; | ||
|
||
const BUFFER_SIZE: usize = 4096; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/// Used to hold and accumulate any data on an asynchronous task | ||
pub trait Aggregator {} | ||
|
||
/// Gathers only data on sent and received requests | ||
#[derive(Debug, Clone)] | ||
pub struct SimpleAggregator { | ||
pub requests_received: usize, | ||
pub responses_sent: usize, | ||
} | ||
impl Aggregator for SimpleAggregator {} |
Oops, something went wrong.