mirror of
https://github.com/telemt/telemt.git
synced 2026-11-02 22:02:00 +03:00
Hardswap Invariants in tests + Quota fixes
This commit is contained in:
@@ -102,28 +102,12 @@ impl MePool {
|
||||
));
|
||||
};
|
||||
let required = match contour {
|
||||
WriterContour::Active => self.required_writers_for_dc(
|
||||
WriterContour::Active | WriterContour::Warm => self.required_writers_for_dc(
|
||||
endpoints
|
||||
.iter()
|
||||
.filter(|endpoint| endpoint.is_ipv4() == writer.addr.is_ipv4())
|
||||
.count(),
|
||||
),
|
||||
WriterContour::Warm => self.required_writers_for_dc(
|
||||
endpoints
|
||||
.iter()
|
||||
.filter(|endpoint| {
|
||||
let endpoint_family = if endpoint.is_ipv4() {
|
||||
crate::network::IpFamily::V4
|
||||
} else {
|
||||
crate::network::IpFamily::V6
|
||||
};
|
||||
self.family_enabled_for_drain_coverage(
|
||||
endpoint_family,
|
||||
now_epoch_secs,
|
||||
)
|
||||
})
|
||||
.count(),
|
||||
),
|
||||
WriterContour::Draining => 0,
|
||||
};
|
||||
let current = writers
|
||||
@@ -134,18 +118,8 @@ impl MePool {
|
||||
&& candidate.generation == writer.generation
|
||||
&& WriterContour::from_u8(candidate.contour.load(Ordering::Acquire))
|
||||
== contour
|
||||
&& (contour == WriterContour::Warm
|
||||
|| candidate.addr.is_ipv4() == writer.addr.is_ipv4())
|
||||
&& candidate.addr.is_ipv4() == writer.addr.is_ipv4()
|
||||
&& endpoints.contains(&candidate.addr)
|
||||
&& (contour != WriterContour::Warm
|
||||
|| self.family_enabled_for_drain_coverage(
|
||||
if candidate.addr.is_ipv4() {
|
||||
crate::network::IpFamily::V4
|
||||
} else {
|
||||
crate::network::IpFamily::V6
|
||||
},
|
||||
now_epoch_secs,
|
||||
))
|
||||
})
|
||||
.count();
|
||||
if current >= required {
|
||||
|
||||
@@ -223,6 +223,11 @@ mod tests {
|
||||
WriterContour::Active,
|
||||
WriterOpenIntent::Replacement,
|
||||
writer_dc,
|
||||
if addr.is_ipv4() {
|
||||
crate::network::IpFamily::V4
|
||||
} else {
|
||||
crate::network::IpFamily::V6
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("replacement open must be admitted");
|
||||
|
||||
@@ -92,7 +92,16 @@ impl MePool {
|
||||
intent: WriterOpenIntent,
|
||||
) -> Result<PreparedWriter<'a>> {
|
||||
let Some(writer_open_reservation) = self
|
||||
.reserve_writer_open(contour, intent, writer_dc)
|
||||
.reserve_writer_open(
|
||||
contour,
|
||||
intent,
|
||||
writer_dc,
|
||||
if addr.is_ipv4() {
|
||||
crate::network::IpFamily::V4
|
||||
} else {
|
||||
crate::network::IpFamily::V6
|
||||
},
|
||||
)
|
||||
.await
|
||||
else {
|
||||
return Err(ProxyError::Proxy(format!(
|
||||
|
||||
Reference in New Issue
Block a user