mononoke: server: add support for force updating tunables and configerator and remove sleeps in tests
Summary: We have a number of sleeps in our integration tests. The two main reasons are configs & tunables that need reloading. Currently, we have no way of force-reloading those.
@@ -113,6 +113,12 @@ impl ConfigStore {
self.get_config_handle_with_deserializer(path, deserialize_raw)
}
+ /// By default configs are updated once in `poll_interval`. Call this to force update them.
+ /// Meant to be used in tests
+ pub fn force_update_configs(&self) {
+ self.updater_thread_iteration();
+ }
+
fn get_config_handle_with_deserializer<T>(
&self,
path: String,
@@ -169,6 +175,12 @@ impl ConfigStore {
fn updater_thread(&self, poll_interval: Duration) {
loop {
+ self.updater_thread_iteration();
+ thread::sleep(poll_interval);
+ }
+ }
+
+ fn updater_thread_iteration(&self) {
let clients = self.clients.lock().expect("lock poisoned");
// Don't loop when there are no active clients to care about
@@ -193,12 +205,6 @@ impl ConfigStore {
client_list.retain(|client| client.upgrade().is_some());
!client_list.is_empty()
});
-
- // Release clients before going to sleep.
- std::mem::drop(clients);
-
- thread::sleep(poll_interval);
- }
}
}
