Repository: influxdata/influxdb
File: influxdb3_wal/src/object_store.rs (Rust)

Code before:
    fn update_last_wal_num(&mut self, last_wal: WalFileSequenceNumber) {
        self.last_snapshotted_wal_sequence_number.replace(last_wal);
    }

    fn update_oldest_wal_num(&mut self, oldest: u64) {
        self.oldest_wal_file = Some(WalFileSequenceNumber::new(oldest));
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::{
        Field, FieldData, Gen1Duration, Row, SnapshotSequenceNumber, TableChunk, TableChunks,
    };
    use async_trait::async_trait;
    use indexmap::IndexMap;
    use influxdb3_id::{ColumnId, DbId, TableId};
    use iox_time::{MockProvider, Time};
    use object_store::memory::InMemory;
    use std::any::Any;
    use tokio::sync::oneshot::Receiver;

    #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
    async fn flush_for_empty_buffer_skips_notify() {
        let time_provider: Arc<dyn TimeProvider> =
            Arc::new(MockProvider::new(Time::from_timestamp_nanos(0)));
        let object_store: Arc<dyn ObjectStore> = Arc::new(InMemory::new());
        let notifier: Arc<dyn WalFileNotifier> = Arc::new(TestNotifier::default());
        let wal_config = WalConfig {
            max_write_buffer_size: 100,
            flush_interval: Duration::from_secs(1),
            snapshot_size: 2,
            gen1_duration: Gen1Duration::new_1m(),
        };
        let paths = vec![];
        let wal = WalObjectStore::new_without_replay(
            time_provider,
            Arc::clone(&object_store),
            "my_host",
            Arc::clone(&notifier),
            wal_config,
            None,
            None,
            &paths,
            10,
        );

        assert!(wal.flush_buffer(false).await.is_none());
        let notifier = notifier.as_any().downcast_ref::<TestNotifier>().unwrap();
        assert!(notifier.notified_writes.lock().is_empty());

Review comment (performance):
why remove this test? If covered elsewhere, probably better to have it gone as it's likely to be brittle given it's down in the weeds of creating the contents manually. Would definitely be better to have a refactored one that uses test helpers that build LP into batches, etc.

Code after:
    fn update_last_wal_num(&mut self, last_wal: WalFileSequenceNumber) {
        self.last_snapshotted_wal_sequence_number.replace(last_wal);
    }

    fn update_oldest_wal_num(&mut self, oldest: u64) {
        self.oldest_wal_file = Some(WalFileSequenceNumber::new(oldest));
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::{
        create, Field, FieldData, Gen1Duration, Row, SnapshotSequenceNumber, TableChunk,
        TableChunks,
    };
    use async_trait::async_trait;
    use indexmap::IndexMap;
    use influxdb3_id::{ColumnId, DbId, TableId};
    use iox_time::{MockProvider, Time};
    use object_store::memory::InMemory;
    use std::any::Any;
    use tokio::sync::oneshot::Receiver;

    #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
    async fn write_flush_delete_and_load() {
        let time_provider: Arc<dyn TimeProvider> =
            Arc::new(MockProvider::new(Time::from_timestamp_nanos(0)));
        let object_store: Arc<dyn ObjectStore> = Arc::new(InMemory::new());
        let notifier: Arc<dyn WalFileNotifier> = Arc::new(TestNotifier::default());
        let wal_config = WalConfig {
            max_write_buffer_size: 100,
            flush_interval: Duration::from_secs(1),
            snapshot_size: 2,
            gen1_duration: Gen1Duration::new_1m(),
        };
        let paths = vec![];
        let wal = WalObjectStore::new_without_replay(
            Arc::clone(&time_provider),
            Arc::clone(&object_store),
            "my_host",
            Arc::clone(&notifier),
            wal_config,
            None,
            None,
            &paths,
            1,
        );

        let db_name: Arc<str> = "db1".into();