-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(runtime-config): Add some tests to make sure data is cached #6586
base: master
Are you sure you want to change the base?
Conversation
c979a7d
to
aa7dbf5
Compare
Good start but what we really want to check is that |
aa7dbf5
to
0fe75cd
Compare
@volokluev I added |
0fe75cd
to
b94afcb
Compare
b94afcb
to
b4e64ff
Compare
#[test] | ||
fn test_runtime_config_invalidates_cache_outside_deadline() { | ||
{ | ||
CONFIG.write().insert( | ||
"key3".to_string(), | ||
( | ||
Some("value3".to_string()), | ||
Deadline::new(Duration::from_secs(0)), | ||
), | ||
); | ||
} | ||
let config = get_str_config("key3"); | ||
assert_eq!(config.unwrap(), None); | ||
CONFIG.write().clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to set this deadline to maybe 1 sec from now, and sleep for 1 sec to retrieve it, like so
#[test]
fn test_runtime_config_invalidates_cache_outside_deadline() {
{
CONFIG.write().insert(
"key3".to_string(),
(
Some("value3".to_string()),
Deadline::new(Duration::from_secs(1)), // 1 instead of 0
),
);
}
thread::sleep(Duration::from_secs(900));
let config = get_str_config("key3");
assert_eq!(config.unwrap(), None);
CONFIG.write().clear();
}
But for some reason this fails, and the debugger shows that coarsetime::Instant::recent()
does not appear to be advancing
Overview
We ran into an incident where we accidentally did not store runtime config into our cache and retrieved it from redis every time the get_runtime_config is called. This pr tries to add a couple of tests to assert the caching behaviour.