v0.34.0_1
This commit is contained in:
1 parent
9b3d6731cc
commit
00f29f92c8
68 files changed
+2599
-513
No files matched your search
+43
-5
@@ -533,7 +533,7 @@ mod tests {
|
||||
headers.insert("cookie", format!("{cookie}; {cookie}").parse().unwrap());
|
||||
assert!(pool.affinity(&headers).is_none());
|
||||
headers.insert("cookie", cookie.parse().unwrap());
|
||||
lock(&first.lease.member.state.health).healthy = false;
|
||||
first.lease.member.state.set_healthy_for_test(false);
|
||||
let next = pool
|
||||
.select("127.0.0.1".parse().unwrap(), &headers, false)
|
||||
.unwrap();
|
||||
@@ -542,7 +542,7 @@ mod tests {
|
||||
first.lease.member.definition.id
|
||||
);
|
||||
assert!(next.cookie.is_some());
|
||||
lock(&next.lease.member.state.health).healthy = false;
|
||||
next.lease.member.state.set_healthy_for_test(false);
|
||||
assert!(pool
|
||||
.select("127.0.0.1".parse().unwrap(), &headers, false)
|
||||
.is_none());
|
||||
@@ -611,9 +611,9 @@ mod tests {
|
||||
for _ in 0..8 {
|
||||
assert_eq!(select(&pool).lease.member.definition.id, "a");
|
||||
}
|
||||
lock(&pool.members[0].state.health).healthy = false;
|
||||
pool.members[0].state.set_healthy_for_test(false);
|
||||
assert_eq!(select(&pool).lease.member.definition.id, "b");
|
||||
lock(&pool.members[0].state.health).healthy = true;
|
||||
pool.members[0].state.set_healthy_for_test(true);
|
||||
assert_eq!(select(&pool).lease.member.definition.id, "a");
|
||||
}
|
||||
#[tokio::test]
|
||||
@@ -635,7 +635,7 @@ mod tests {
|
||||
.select("127.0.0.1".parse().unwrap(), &headers, false)
|
||||
.unwrap();
|
||||
assert_eq!(existing.lease.member.definition.id, "a");
|
||||
lock(&pool.members[0].state.health).healthy = false;
|
||||
pool.members[0].state.set_healthy_for_test(false);
|
||||
assert_eq!(
|
||||
pool.select("127.0.0.1".parse().unwrap(), &headers, false)
|
||||
.unwrap()
|
||||
@@ -764,4 +764,42 @@ mod tests {
|
||||
assert!(state.healthy());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn single_backend_fast_path_observes_capacity_and_health_without_affinity_cookie() {
|
||||
let pool = capacity_pool(1, 0);
|
||||
assert_eq!(pool.members.len(), 1);
|
||||
let peer = "127.0.0.1".parse().unwrap();
|
||||
let headers = HeaderMap::new();
|
||||
let first = pool.select(peer, &headers, false).expect("healthy backend");
|
||||
assert!(first.cookie.is_none());
|
||||
assert!(pool.select(peer, &headers, false).is_none());
|
||||
drop(first);
|
||||
pool.members[0].state.set_healthy_for_test(false);
|
||||
assert!(pool.select(peer, &headers, false).is_none());
|
||||
pool.members[0].state.set_healthy_for_test(true);
|
||||
assert!(pool.select(peer, &headers, false).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leases_reuse_immutable_backend_health_policies() {
|
||||
let pool = capacity_pool(0, 0);
|
||||
let first = select(&pool);
|
||||
let second = select(&pool);
|
||||
assert!(Arc::ptr_eq(&first.lease.health, &second.lease.health));
|
||||
assert!(Arc::ptr_eq(&first.lease.passive_health, &second.lease.passive_health));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn healthy_fast_path_tracks_active_and_passive_ejections() {
|
||||
let state = BackendState::new(HealthMode::Off);
|
||||
assert!(state.healthy());
|
||||
let active = settings(HealthMode::Off);
|
||||
let passive = PassiveHealth { enabled: true, fall: Some(1), rise: Some(1), ..Default::default() };
|
||||
state.observe_passive(&active, &passive, "connect_error", Duration::from_millis(2));
|
||||
assert!(!state.healthy());
|
||||
// Preserve quarantine rules; an active probe is not invented here.
|
||||
state.observe_passive(&active, &passive, "ok", Duration::from_millis(2));
|
||||
assert!(state.healthy());
|
||||
}
|
||||
} // mod tests
|
||||
Reference in new issue
Block a user