From 82e5597b00f9b368ab1de7b6fa26dbf70948b9ed Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Fri, 16 May 2025 11:24:37 +0200 Subject: [PATCH 1/3] long fuzz tests ci on btree changes The idea is simple, if you modify the btree, we should verify fuzz tests with long number of iterations to decrease the chance of a regression --- .github/workflows/long_fuzz_tests_btree.yml | 44 +++++++++++++++++++++ core/storage/btree.rs | 41 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/workflows/long_fuzz_tests_btree.yml diff --git a/.github/workflows/long_fuzz_tests_btree.yml b/.github/workflows/long_fuzz_tests_btree.yml new file mode 100644 index 000000000..24f37582e --- /dev/null +++ b/.github/workflows/long_fuzz_tests_btree.yml @@ -0,0 +1,44 @@ +name: Run long fuzz tests on Btree + +on: + push: + paths: + - 'core/storage/btree.rs' + pull_request: + paths: + - 'core/storage/btree.rs' + +jobs: + run-long-tests: + runs-on: ubuntu-latest + timeout-minutes: 0 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, clippy + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Run ignored long tests + run: cargo test -- --ignored fuzz_long + env: + RUST_BACKTRACE: 1 \ No newline at end of file diff --git a/core/storage/btree.rs b/core/storage/btree.rs index ee3d8e698..6fe8c655c 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -6121,6 +6121,47 @@ mod tests { btree_insert_fuzz_run(64, 32, |rng| (rng.next_u32() % 32 * 1024) as usize); } + #[test] + #[ignore] + pub fn fuzz_long_btree_insert_fuzz_run_equal_size() { + for size in 1..8 { + tracing::info!("======= size:{} =======", size); + btree_insert_fuzz_run(2, 10_000, |_| size); + } + } + + #[test] + #[ignore] + pub fn fuzz_long_btree_index_insert_fuzz_run_equal_size() { + btree_index_insert_fuzz_run(2, 10_000); + } + + #[test] + #[ignore] + pub fn fuzz_long_btree_insert_fuzz_run_random() { + btree_insert_fuzz_run(128, 10_000, |rng| (rng.next_u32() % 4096) as usize); + } + + #[test] + #[ignore] + pub fn fuzz_long_btree_insert_fuzz_run_small() { + btree_insert_fuzz_run(1, 10_000, |rng| (rng.next_u32() % 128) as usize); + } + + #[test] + #[ignore] + pub fn fuzz_long_btree_insert_fuzz_run_big() { + btree_insert_fuzz_run(64, 10_000, |rng| { + 3 * 1024 + (rng.next_u32() % 1024) as usize + }); + } + + #[test] + #[ignore] + pub fn fuzz_long_btree_insert_fuzz_run_overflow() { + btree_insert_fuzz_run(64, 10_000, |rng| (rng.next_u32() % 32 * 1024) as usize); + } + #[allow(clippy::arc_with_non_send_sync)] fn setup_test_env(database_size: u32) -> (Rc, Arc>) { let page_size = 512; From 852cd48aa473de83c855611810febf31c85d50d5 Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Fri, 16 May 2025 11:30:58 +0200 Subject: [PATCH 2/3] uses install sqlite --- .github/workflows/long_fuzz_tests_btree.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/long_fuzz_tests_btree.yml b/.github/workflows/long_fuzz_tests_btree.yml index 24f37582e..1cd4f5fce 100644 --- a/.github/workflows/long_fuzz_tests_btree.yml +++ b/.github/workflows/long_fuzz_tests_btree.yml @@ -38,6 +38,7 @@ jobs: restore-keys: | ${{ runner.os }}-cargo- + - uses: "./.github/shared/install_sqlite" - name: Run ignored long tests run: cargo test -- --ignored fuzz_long env: From 12ebfc1fcfacad8f27df6d2deac9b66ef753bc70 Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Fri, 16 May 2025 11:52:57 +0200 Subject: [PATCH 3/3] wip --- .github/workflows/long_fuzz_tests_btree.yml | 43 +++++++-------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/.github/workflows/long_fuzz_tests_btree.yml b/.github/workflows/long_fuzz_tests_btree.yml index 1cd4f5fce..dbf8006ef 100644 --- a/.github/workflows/long_fuzz_tests_btree.yml +++ b/.github/workflows/long_fuzz_tests_btree.yml @@ -14,32 +14,17 @@ jobs: timeout-minutes: 0 steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt, clippy - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - - uses: "./.github/shared/install_sqlite" - - name: Run ignored long tests - run: cargo test -- --ignored fuzz_long - env: - RUST_BACKTRACE: 1 \ No newline at end of file + - uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: "v1-rust" # can be updated if we need to reset caches due to non-trivial change in the dependencies (for example, custom env var were set for single workspace project) + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Build + run: cargo build --verbose + - name: Run ignored long tests + run: cargo test -- --ignored fuzz_long + env: + RUST_BACKTRACE: 1 \ No newline at end of file