Skip to content

Commit 010fb8d

Browse files
committed
Fix flaky batcher-config test (#10810)
### Related * Introduced in #10620 ### What Environment variables are annoying
1 parent 50a64d5 commit 010fb8d

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

crates/top/re_sdk/src/recording_stream.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3121,8 +3121,22 @@ mod tests {
31213121

31223122
const CONFIG_CHANGE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(1);
31233123

3124+
fn clear_environment() {
3125+
// SAFETY: only used in tests.
3126+
#[allow(unsafe_code)]
3127+
unsafe {
3128+
std::env::remove_var("RERUN_CHUNK_MAX_ROWS_IF_UNSORTED");
3129+
std::env::remove_var("RERUN_FLUSH_NUM_BYTES");
3130+
std::env::remove_var("RERUN_FLUSH_NUM_ROWS");
3131+
std::env::remove_var("RERUN_FLUSH_TICK_SECS");
3132+
std::env::remove_var("RERUN_MAX_CHUNK_ROWS_IF_UNSORTED");
3133+
}
3134+
}
3135+
31243136
#[test]
31253137
fn test_sink_dependent_batcher_config() {
3138+
clear_environment();
3139+
31263140
let (tx, rx) = std::sync::mpsc::channel();
31273141

31283142
let rec = RecordingStreamBuilder::new("rerun_example_test_batcher_config")
@@ -3138,14 +3152,18 @@ mod tests {
31383152
let new_config = rx
31393153
.recv_timeout(CONFIG_CHANGE_TIMEOUT)
31403154
.expect("no config change message received within timeout");
3141-
assert_eq!(new_config, ChunkBatcherConfig::DEFAULT); // buffered sink uses the default config.
3155+
assert_eq!(
3156+
new_config,
3157+
ChunkBatcherConfig::from_env().unwrap(),
3158+
"Buffered sink should uses the config from the environment"
3159+
);
31423160

31433161
// Change sink to our custom sink. Will it take over the setting?
31443162
let injected_config = ChunkBatcherConfig {
31453163
flush_tick: std::time::Duration::from_secs(123),
31463164
flush_num_bytes: 123,
31473165
flush_num_rows: 123,
3148-
..ChunkBatcherConfig::DEFAULT
3166+
..new_config
31493167
};
31503168
rec.set_sink(Box::new(BatcherConfigTestSink {
31513169
config: injected_config.clone(),
@@ -3176,6 +3194,8 @@ mod tests {
31763194

31773195
#[test]
31783196
fn test_explicit_batcher_config() {
3197+
clear_environment();
3198+
31793199
// This environment variable should *not* override the explicit config.
31803200
let _scoped_env_guard = ScopedEnvVarSet::new("RERUN_FLUSH_TICK_SECS", "456");
31813201
let explicit_config = ChunkBatcherConfig {

0 commit comments

Comments
 (0)