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
+84
-25
@@ -8,15 +8,21 @@ mod cache_revision_tests {
|
||||
let identity = cache_revision(&base);
|
||||
|
||||
let mut file_transport = base.clone();
|
||||
file_transport.web_services.push(crate::web_server::Service {
|
||||
id: "static-test".into(), name: "Static Test".into(),
|
||||
document_root: "/var/www/static-test".into(),
|
||||
..Default::default()
|
||||
});
|
||||
file_transport
|
||||
.web_services
|
||||
.push(crate::web_server::Service {
|
||||
id: "static-test".into(),
|
||||
name: "Static Test".into(),
|
||||
document_root: "/var/www/static-test".into(),
|
||||
..Default::default()
|
||||
});
|
||||
let mut zero_copy = file_transport.clone();
|
||||
zero_copy.web_services[0].sendfile = crate::web_server::SendfileMode::Auto;
|
||||
assert_eq!(cache_revision(&file_transport), cache_revision(&zero_copy));
|
||||
assert!(matches!(cache_invalidation(&file_transport, &zero_copy), CacheInvalidation::None));
|
||||
assert!(matches!(
|
||||
cache_invalidation(&file_transport, &zero_copy),
|
||||
CacheInvalidation::None
|
||||
));
|
||||
|
||||
let mut logging = base.clone();
|
||||
logging.logging.file.path = "/tmp/rustproxy-test-access.jsonl".into();
|
||||
@@ -88,24 +94,43 @@ mod cache_revision_tests {
|
||||
protocol_only.vhosts[0].http3_enabled = !base.vhosts[0].http3_enabled;
|
||||
}
|
||||
assert_ne!(
|
||||
(protocol_only.vhosts[0].http2_enabled, protocol_only.vhosts[0].http3_enabled),
|
||||
(
|
||||
protocol_only.vhosts[0].http2_enabled,
|
||||
protocol_only.vhosts[0].http3_enabled
|
||||
),
|
||||
(base.vhosts[0].http2_enabled, base.vhosts[0].http3_enabled),
|
||||
"{label} toggle did not change a transport switch"
|
||||
);
|
||||
assert_eq!(cache_revision(&protocol_only), identity, "{label} rotated cache");
|
||||
assert!(matches!(cache_invalidation(&base, &protocol_only), CacheInvalidation::None));
|
||||
assert!(matches!(cache_invalidation(&protocol_only, &base), CacheInvalidation::None));
|
||||
assert_eq!(
|
||||
cache_revision(&protocol_only),
|
||||
identity,
|
||||
"{label} rotated cache"
|
||||
);
|
||||
assert!(matches!(
|
||||
cache_invalidation(&base, &protocol_only),
|
||||
CacheInvalidation::None
|
||||
));
|
||||
assert!(matches!(
|
||||
cache_invalidation(&protocol_only, &base),
|
||||
CacheInvalidation::None
|
||||
));
|
||||
}
|
||||
let mut both_protocols = base.clone();
|
||||
both_protocols.vhosts[0].http2_enabled = !base.vhosts[0].http2_enabled;
|
||||
both_protocols.vhosts[0].http3_enabled = !base.vhosts[0].http3_enabled;
|
||||
assert_eq!(cache_revision(&both_protocols), identity);
|
||||
assert!(matches!(cache_invalidation(&base, &both_protocols), CacheInvalidation::None));
|
||||
assert!(matches!(
|
||||
cache_invalidation(&base, &both_protocols),
|
||||
CacheInvalidation::None
|
||||
));
|
||||
|
||||
let mut vhost_diagnostics = base.clone();
|
||||
vhost_diagnostics.vhosts[0].cache.expose_only_hits = Some(true);
|
||||
assert_eq!(cache_revision(&vhost_diagnostics), identity);
|
||||
assert!(matches!(cache_invalidation(&base, &vhost_diagnostics), CacheInvalidation::None));
|
||||
assert!(matches!(
|
||||
cache_invalidation(&base, &vhost_diagnostics),
|
||||
CacheInvalidation::None
|
||||
));
|
||||
|
||||
let mut cache = base.clone();
|
||||
cache.cache.max_entries += 1;
|
||||
@@ -118,12 +143,30 @@ mod cache_revision_tests {
|
||||
|
||||
let mut operational = base.clone();
|
||||
operational.vhosts[0].load_balancing.keepalive.enabled = false;
|
||||
operational.vhosts[0].load_balancing.keepalive.idle_timeout_seconds = 90;
|
||||
operational.vhosts[0].load_balancing.keepalive.max_idle_per_host = 32;
|
||||
operational.vhosts[0].load_balancing.keepalive.tcp_keepalive_seconds = 90;
|
||||
operational.vhosts[0].load_balancing.keepalive.pool_recycle_requests = 1_000;
|
||||
operational.vhosts[0].load_balancing.keepalive.pool_recycle_seconds = 1_800;
|
||||
operational.vhosts[0].load_balancing.keepalive.http1_max_buffer_bytes = 65_536;
|
||||
operational.vhosts[0]
|
||||
.load_balancing
|
||||
.keepalive
|
||||
.idle_timeout_seconds = 90;
|
||||
operational.vhosts[0]
|
||||
.load_balancing
|
||||
.keepalive
|
||||
.max_idle_per_host = 32;
|
||||
operational.vhosts[0]
|
||||
.load_balancing
|
||||
.keepalive
|
||||
.tcp_keepalive_seconds = 90;
|
||||
operational.vhosts[0]
|
||||
.load_balancing
|
||||
.keepalive
|
||||
.pool_recycle_requests = 1_000;
|
||||
operational.vhosts[0]
|
||||
.load_balancing
|
||||
.keepalive
|
||||
.pool_recycle_seconds = 1_800;
|
||||
operational.vhosts[0]
|
||||
.load_balancing
|
||||
.keepalive
|
||||
.http1_max_buffer_bytes = 65_536;
|
||||
operational.vhosts[0].backends[0].weight += 1;
|
||||
operational.vhosts[0].backends[0].max_concurrent_requests = 16;
|
||||
operational.vhosts[0].backends[0].queue_timeout_ms = 100;
|
||||
@@ -132,15 +175,26 @@ mod cache_revision_tests {
|
||||
operational.vhosts[0].user_agent_blocking = Default::default();
|
||||
operational.vhosts[0].proxy_timeouts.read_timeout_seconds = Some(180);
|
||||
assert_eq!(cache_revision(&operational), identity);
|
||||
assert_eq!(vhost_cache_revision(&operational.vhosts[0]), vhost_cache_revision(&base.vhosts[0]));
|
||||
assert!(matches!(cache_invalidation(&base, &operational), CacheInvalidation::None));
|
||||
assert!(matches!(cache_invalidation(&operational, &base), CacheInvalidation::None));
|
||||
assert_eq!(
|
||||
vhost_cache_revision(&operational.vhosts[0]),
|
||||
vhost_cache_revision(&base.vhosts[0])
|
||||
);
|
||||
assert!(matches!(
|
||||
cache_invalidation(&base, &operational),
|
||||
CacheInvalidation::None
|
||||
));
|
||||
assert!(matches!(
|
||||
cache_invalidation(&operational, &base),
|
||||
CacheInvalidation::None
|
||||
));
|
||||
|
||||
let mut vhost = base.clone();
|
||||
vhost.vhosts[0].backends[0].url = "http://127.0.0.1:9001".into();
|
||||
assert_eq!(cache_revision(&vhost), identity);
|
||||
let affected_id = base.vhosts[0].id.clone();
|
||||
assert!(matches!(cache_invalidation(&base, &vhost), CacheInvalidation::Scopes(ids) if ids == vec![affected_id]));
|
||||
assert!(
|
||||
matches!(cache_invalidation(&base, &vhost), CacheInvalidation::Scopes(ids) if ids == vec![affected_id])
|
||||
);
|
||||
|
||||
let mut multiple = base.clone();
|
||||
let mut another = multiple.vhosts[0].clone();
|
||||
@@ -149,10 +203,15 @@ mod cache_revision_tests {
|
||||
multiple.vhosts.push(another);
|
||||
let mut changed_one = multiple.clone();
|
||||
changed_one.vhosts[0].backends[0].url = "http://127.0.0.1:9002".into();
|
||||
assert!(matches!(cache_invalidation(&multiple, &changed_one), CacheInvalidation::Scopes(ids)
|
||||
if ids == vec![base.vhosts[0].id.clone()]));
|
||||
assert!(
|
||||
matches!(cache_invalidation(&multiple, &changed_one), CacheInvalidation::Scopes(ids)
|
||||
if ids == vec![base.vhosts[0].id.clone()])
|
||||
);
|
||||
let mut changed_global = multiple.clone();
|
||||
changed_global.transform.max_body_bytes += 1;
|
||||
assert!(matches!(cache_invalidation(&multiple, &changed_global), CacheInvalidation::All(_)));
|
||||
assert!(matches!(
|
||||
cache_invalidation(&multiple, &changed_global),
|
||||
CacheInvalidation::All(_)
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user