aboutsummaryrefslogtreecommitdiffhomepage
path: root/pingora-proxy/tests/utils/server_utils.rs
diff options
context:
space:
mode:
authorKevin Guthrie <[email protected]>2024-11-18 10:43:52 -0500
committerYuchen Wu <[email protected]>2024-12-13 17:27:40 -0800
commit9850e92e33af870a0761c2473673f9a0ada61b0b (patch)
tree9f663f0694653c2764e1dc1d0d7fce99b34fd65b /pingora-proxy/tests/utils/server_utils.rs
parenta8a6e77eef2c0f4d2a45f00c5b0e316dd373f2f2 (diff)
downloadpingora-9850e92e33af870a0761c2473673f9a0ada61b0b.tar.gz
pingora-9850e92e33af870a0761c2473673f9a0ada61b0b.zip
Add the ability to trigger forced-miss behavior from the `cache_hit_filter` function
Diffstat (limited to 'pingora-proxy/tests/utils/server_utils.rs')
-rw-r--r--pingora-proxy/tests/utils/server_utils.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/pingora-proxy/tests/utils/server_utils.rs b/pingora-proxy/tests/utils/server_utils.rs
index f762f33..0c5a4e5 100644
--- a/pingora-proxy/tests/utils/server_utils.rs
+++ b/pingora-proxy/tests/utils/server_utils.rs
@@ -21,12 +21,12 @@ use http::HeaderValue;
use once_cell::sync::Lazy;
use pingora_cache::cache_control::CacheControl;
use pingora_cache::key::HashBinary;
-use pingora_cache::VarianceBuilder;
use pingora_cache::{
eviction::simple_lru::Manager, filters::resp_cacheable, lock::CacheLock, predictor::Predictor,
set_compression_dict_path, CacheMeta, CacheMetaDefaults, CachePhase, MemCache, NoCacheReason,
RespCacheable,
};
+use pingora_cache::{ForcedInvalidationKind, PurgeType, VarianceBuilder};
use pingora_core::apps::{HttpServerApp, HttpServerOptions};
use pingora_core::modules::http::compression::ResponseCompression;
use pingora_core::protocols::{l4::socket::SocketAddr, Digest};
@@ -415,12 +415,15 @@ impl ProxyHttp for ExampleProxyCache {
session: &Session,
_meta: &CacheMeta,
_ctx: &mut Self::CTX,
- ) -> Result<bool> {
- // allow test header to control force expiry
+ ) -> Result<Option<ForcedInvalidationKind>> {
+ // allow test header to control force expiry/miss
+ if session.get_header_bytes("x-force-miss") != b"" {
+ return Ok(Some(ForcedInvalidationKind::ForceMiss));
+ }
if session.get_header_bytes("x-force-expire") != b"" {
- return Ok(true);
+ return Ok(Some(ForcedInvalidationKind::ForceExpired));
}
- Ok(false)
+ Ok(None)
}
fn cache_vary_filter(