0.34.13_cleaup_code
This commit is contained in:
1 parent
ec46a96a29
commit
5c2e50ec06
87 files changed
+4890
-1338
No files matched your search
+52
-20
@@ -50,11 +50,19 @@ mod tests {
|
||||
analytics.push_lazy(|| {
|
||||
made.fetch_add(1, Ordering::Relaxed);
|
||||
Sample {
|
||||
vhost: "site".into(), route: None, method: "GET".into(),
|
||||
path: "/".into(), client_ip: None, status: 200,
|
||||
duration_ms: 1, request_bytes: 0, response_bytes: 1040,
|
||||
cache: "BYPASS", source: "reverse_proxy",
|
||||
user_agent: None, country: None,
|
||||
vhost: "site".into(),
|
||||
route: None,
|
||||
method: "GET".into(),
|
||||
path: "/".into(),
|
||||
client_ip: None,
|
||||
status: 200,
|
||||
duration_ms: 1,
|
||||
request_bytes: 0,
|
||||
response_bytes: 1040,
|
||||
cache: "BYPASS",
|
||||
source: "reverse_proxy",
|
||||
user_agent: None,
|
||||
country: None,
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -78,15 +86,27 @@ mod tests {
|
||||
let mut counters = Counters::default();
|
||||
for status in [100, 200, 302, 404, 503, 701] {
|
||||
counters.record(Sample {
|
||||
vhost: "test".into(), route: None, method: "GET".into(),
|
||||
path: "/".into(), client_ip: None, status,
|
||||
duration_ms: 1, request_bytes: 0, response_bytes: 1,
|
||||
cache: "BYPASS", source: "reverse_proxy",
|
||||
user_agent: None, country: None,
|
||||
vhost: "test".into(),
|
||||
route: None,
|
||||
method: "GET".into(),
|
||||
path: "/".into(),
|
||||
client_ip: None,
|
||||
status,
|
||||
duration_ms: 1,
|
||||
request_bytes: 0,
|
||||
response_bytes: 1,
|
||||
cache: "BYPASS",
|
||||
source: "reverse_proxy",
|
||||
user_agent: None,
|
||||
country: None,
|
||||
});
|
||||
}
|
||||
let labels: std::collections::HashSet<_> = counters.view().statuses.into_iter()
|
||||
.map(|entry| entry.value).collect();
|
||||
let labels: std::collections::HashSet<_> = counters
|
||||
.view()
|
||||
.statuses
|
||||
.into_iter()
|
||||
.map(|entry| entry.value)
|
||||
.collect();
|
||||
for label in ["1xx", "2xx", "3xx", "4xx", "5xx", "7xx"] {
|
||||
assert!(labels.contains(label));
|
||||
}
|
||||
@@ -113,12 +133,23 @@ mod tests {
|
||||
let analytics = Analytics::start(shutdown.clone());
|
||||
for id in 0..130 {
|
||||
analytics.push(Sample {
|
||||
vhost: if id % 2 == 0 { "left".into() } else { "right".into() },
|
||||
route: None, method: "GET".into(), path: "/small".into(),
|
||||
client_ip: None, status: 200, duration_ms: 1,
|
||||
request_bytes: 0, response_bytes: 1040,
|
||||
cache: "BYPASS", source: "reverse_proxy",
|
||||
user_agent: None, country: None,
|
||||
vhost: if id % 2 == 0 {
|
||||
"left".into()
|
||||
} else {
|
||||
"right".into()
|
||||
},
|
||||
route: None,
|
||||
method: "GET".into(),
|
||||
path: "/small".into(),
|
||||
client_ip: None,
|
||||
status: 200,
|
||||
duration_ms: 1,
|
||||
request_bytes: 0,
|
||||
response_bytes: 1040,
|
||||
cache: "BYPASS",
|
||||
source: "reverse_proxy",
|
||||
user_agent: None,
|
||||
country: None,
|
||||
});
|
||||
}
|
||||
tokio::time::timeout(std::time::Duration::from_secs(2), async {
|
||||
@@ -127,7 +158,9 @@ mod tests {
|
||||
{
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
}).await.expect("analytics should drain two batches");
|
||||
})
|
||||
.await
|
||||
.expect("analytics should drain two batches");
|
||||
let all = analytics.view(None).data;
|
||||
assert_eq!(all.requests, 130);
|
||||
assert_eq!(all.response_bytes, 130 * 1040);
|
||||
@@ -136,5 +169,4 @@ mod tests {
|
||||
assert_eq!(analytics.view(None).data.requests, 65);
|
||||
shutdown.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user