Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
55a246a3
Unverified
Commit
55a246a3
authored
Feb 13, 2026
by
Yan Ru Pei
Committed by
GitHub
Feb 13, 2026
Browse files
test: flaky test_sliding_window cache stats test (#6166)
Signed-off-by:
PeaBrane
<
yanrpei@gmail.com
>
parent
f308a3d3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
16 deletions
+17
-16
lib/bindings/kvbm/src/block_manager/cache_stats.rs
lib/bindings/kvbm/src/block_manager/cache_stats.rs
+17
-16
No files found.
lib/bindings/kvbm/src/block_manager/cache_stats.rs
View file @
55a246a3
...
...
@@ -236,6 +236,21 @@ impl CacheStatsTracker {
}
}
#[cfg(test)]
impl
CacheStatsTracker
{
fn
new_with_capacity
(
max_recent_requests
:
usize
)
->
Self
{
Self
{
max_recent_requests
,
entries
:
Mutex
::
new
(
VecDeque
::
new
()),
aggregated
:
Mutex
::
new
(
AggregatedStats
::
default
()),
last_log_time
:
Mutex
::
new
(
Instant
::
now
()),
log_interval
:
Duration
::
from_secs
(
DEFAULT_LOG_INTERVAL_SECS
),
identifier
:
None
,
last_logged_values
:
Mutex
::
new
(
None
),
}
}
}
impl
Default
for
CacheStatsTracker
{
fn
default
()
->
Self
{
Self
::
new
(
None
)
...
...
@@ -248,14 +263,7 @@ mod tests {
#[test]
fn
test_cache_stats_tracking
()
{
// Use a small window size for testing
unsafe
{
std
::
env
::
set_var
(
"DYN_KVBM_CACHE_STATS_MAX_REQUESTS"
,
"10"
);
}
let
tracker
=
CacheStatsTracker
::
new
(
None
);
unsafe
{
std
::
env
::
remove_var
(
"DYN_KVBM_CACHE_STATS_MAX_REQUESTS"
);
}
let
tracker
=
CacheStatsTracker
::
new_with_capacity
(
10
);
// Record some cache hits
tracker
.record
(
5
,
3
,
10
);
// 50% host, 30% disk
...
...
@@ -271,14 +279,7 @@ mod tests {
#[test]
fn
test_sliding_window
()
{
// Use a small window size for testing
unsafe
{
std
::
env
::
set_var
(
"DYN_KVBM_CACHE_STATS_MAX_REQUESTS"
,
"3"
);
}
let
tracker
=
CacheStatsTracker
::
new
(
None
);
unsafe
{
std
::
env
::
remove_var
(
"DYN_KVBM_CACHE_STATS_MAX_REQUESTS"
);
}
let
tracker
=
CacheStatsTracker
::
new_with_capacity
(
3
);
// Add 5 entries, but max is 3
tracker
.record
(
10
,
5
,
10
);
// Entry 1: 100% host, 50% disk
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment