implemented rtt threshold i guess
This commit is contained in:
parent
816a6daed1
commit
82b944a748
3 changed files with 13 additions and 6 deletions
|
@ -35,7 +35,8 @@
|
||||||
endpoints:[
|
endpoints:[
|
||||||
(label: "The code doesn't match!", endpoint: "http://example.com/", code: 204),
|
(label: "The code doesn't match!", endpoint: "http://example.com/", code: 204),
|
||||||
(label: "The body doesn't match!", endpoint: "http://example.com/", body: "asdf"),
|
(label: "The body doesn't match!", endpoint: "http://example.com/", body: "asdf"),
|
||||||
(label: "Slow reponse time", endpoint: "http://slowwly.robertomurray.co.uk/delay/2000/url/"),
|
(label: "Slow reponse time", endpoint: "http://slowwly.robertomurray.co.uk/delay/2000/url/", max_rtt: 1337),
|
||||||
|
(label: "Plethora of issues!", endpoint: "http://slowwly.robertomurray.co.uk/delay/1000/url/", body: "asdf", code: 418, max_rtt: 50),
|
||||||
(label: "Here's an error:", endpoint: "https://some-invalid-website.arpa")
|
(label: "Here's an error:", endpoint: "https://some-invalid-website.arpa")
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
|
|
@ -9,6 +9,7 @@ pub struct EndpointConfig {
|
||||||
pub body: Option<String>,
|
pub body: Option<String>,
|
||||||
pub body_hash: Option<String>,
|
pub body_hash: Option<String>,
|
||||||
pub follow_redirects: Option<bool>,
|
pub follow_redirects: Option<bool>,
|
||||||
|
pub max_rtt: Option<i64>,
|
||||||
pub should_err: Option<bool>,
|
pub should_err: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ fn get_result(
|
||||||
error = append_err_msg(
|
error = append_err_msg(
|
||||||
error,
|
error,
|
||||||
format!(
|
format!(
|
||||||
"Status code mismatch: {} != {}.",
|
"Status code mismatch: {} != {}",
|
||||||
res.status().as_u16(),
|
res.status().as_u16(),
|
||||||
code
|
code
|
||||||
),
|
),
|
||||||
|
@ -84,12 +84,17 @@ fn get_result(
|
||||||
} else if !body.is_empty() && res_body != body {
|
} else if !body.is_empty() && res_body != body {
|
||||||
error = append_err_msg(
|
error = append_err_msg(
|
||||||
error,
|
error,
|
||||||
format!("Body mismatch: {} != {}.", res_body.len(), body.len()),
|
format!("Body mismatch: {} != {}", res_body.len(), body.len()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if rtt.num_seconds() >= 2 {
|
if let Some(max_rtt) = endpoint.max_rtt {
|
||||||
error = append_err_msg(error, format!("RTT too long: {}", rtt_string));
|
if rtt.num_milliseconds() > max_rtt {
|
||||||
|
error = append_err_msg(
|
||||||
|
error,
|
||||||
|
format!("RTT too long: {} > {}s", rtt_string, max_rtt as f64 / 1000.),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if error.is_some() {
|
if error.is_some() {
|
||||||
|
@ -122,7 +127,7 @@ fn get_url(base: &Option<String>, path: &String, port: Option<u16>) -> Result<St
|
||||||
|
|
||||||
fn append_err_msg(optional: Option<String>, to_append: String) -> Option<String> {
|
fn append_err_msg(optional: Option<String>, to_append: String) -> Option<String> {
|
||||||
Some(match optional {
|
Some(match optional {
|
||||||
Some(e) => format!("{} {}", e, to_append),
|
Some(e) => format!("{}\n{}", e, to_append),
|
||||||
None => to_append,
|
None => to_append,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue