test: compaction correctness randomized harness + invariants (#580) #129
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: cargo | |
| on: | |
| push: | |
| branches: ["**"] | |
| pull_request: | |
| branches: ["**"] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| fmt: | |
| name: +nightly fmt | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install latest nightly | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: nightly | |
| override: true | |
| components: rustfmt, clippy | |
| - name: Run cargo fmt | |
| uses: actions-rs/cargo@v1 | |
| with: | |
| command: fmt | |
| args: -- --check | |
| build: | |
| name: clippy && test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.toml') }} | |
| cache-on-failure: false | |
| - name: Run cargo clippy | |
| uses: actions-rs/cargo@v1 | |
| with: | |
| command: clippy | |
| args: --workspace -- -D warnings | |
| - name: Run cargo test | |
| run: cargo test --verbose --workspace | |
| compaction-correctness-deterministic: | |
| name: compaction correctness (required deterministic baseline) | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.toml') }}-compaction-correctness-deterministic | |
| cache-on-failure: false | |
| - name: Run deterministic compaction correctness baseline (exclude randomized model) | |
| run: cargo test --package tonbo --lib compaction_correctness_ -- --skip compaction_correctness_model_randomized --nocapture | |
| compaction-correctness-randomized-expanded: | |
| name: compaction correctness (optional expanded randomized sst+reopen) | |
| runs-on: ubuntu-latest | |
| needs: build | |
| env: | |
| TONBO_COMPACTION_MODEL_SST: "1" | |
| TONBO_COMPACTION_REOPEN: "1" | |
| TONBO_COMPACTION_EAGER_FLUSH: "1" | |
| TONBO_COMPACTION_SEED: "1,13,57,101,1009" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.toml') }}-compaction-correctness-randomized-expanded | |
| cache-on-failure: false | |
| - name: Run expanded randomized model (sst+reopen enabled) | |
| run: cargo test --package tonbo --lib compaction_correctness_model_randomized -- --nocapture | |
| coverage: | |
| name: coverage (llvm-cov) | |
| runs-on: ubuntu-latest | |
| needs: build | |
| env: | |
| COVERAGE_LINES_MIN: "80" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust 1.90 + llvm-tools | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: "1.90" | |
| override: true | |
| components: llvm-tools-preview | |
| - name: Install cargo-llvm-cov | |
| uses: taiki-e/install-action@cargo-llvm-cov | |
| with: | |
| version: "0.6.12" | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.toml') }}-coverage | |
| cache-on-failure: false | |
| - name: Run coverage | |
| run: cargo llvm-cov --workspace --lcov --output-path lcov.info --fail-under-lines "$COVERAGE_LINES_MIN" | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-lcov | |
| path: lcov.info | |
| e2e-s3: | |
| name: e2e (s3 via LocalStack) | |
| runs-on: ubuntu-latest | |
| needs: build | |
| services: | |
| localstack: | |
| image: localstack/localstack:3.0.2 | |
| ports: | |
| - 4566:4566 | |
| env: | |
| SERVICES: s3 | |
| DEBUG: 0 | |
| options: >- | |
| --health-cmd "curl -f http://localhost:4566/health || exit 1" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 30 | |
| env: | |
| AWS_ACCESS_KEY_ID: test | |
| AWS_SECRET_ACCESS_KEY: test | |
| AWS_DEFAULT_REGION: us-east-1 | |
| TONBO_S3_ENDPOINT: http://localhost:4566 | |
| TONBO_S3_BUCKET: tonbo-e2e | |
| TONBO_S3_REGION: us-east-1 | |
| TONBO_S3_ACCESS_KEY: test | |
| TONBO_S3_SECRET_KEY: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.toml') }}-e2e-s3 | |
| cache-on-failure: false | |
| - name: Prepare LocalStack bucket | |
| run: | | |
| aws --endpoint-url="$TONBO_S3_ENDPOINT" s3api create-bucket --bucket "$TONBO_S3_BUCKET" --region "$TONBO_S3_REGION" || true | |
| - name: Run public API e2e (s3 + fs) | |
| run: | | |
| cargo test --package tonbo --lib public_api_e2e:: -- --nocapture | |
| e2e-s3-real: | |
| name: e2e (real S3) | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: ${{ vars.TONBO_S3_BUCKET != '' && vars.TONBO_S3_REGION != '' }} | |
| permissions: | |
| id-token: write | |
| contents: read | |
| env: | |
| AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Skip if AWS_ROLE_ARN not configured | |
| if: ${{ env.AWS_ROLE_ARN == '' }} | |
| run: | | |
| echo "AWS_ROLE_ARN not configured; skipping e2e-s3-real job." | |
| exit 0 | |
| - name: Configure AWS (OIDC) | |
| if: ${{ env.AWS_ROLE_ARN != '' }} | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ env.AWS_ROLE_ARN }} | |
| aws-region: ${{ vars.TONBO_S3_REGION }} | |
| - name: Ensure bucket exists | |
| if: ${{ env.AWS_ROLE_ARN != '' }} | |
| run: | | |
| if [ "${{ vars.TONBO_S3_REGION }}" = "us-east-1" ]; then | |
| aws s3api create-bucket --bucket "${{ vars.TONBO_S3_BUCKET }}" || true | |
| else | |
| aws s3api create-bucket --bucket "${{ vars.TONBO_S3_BUCKET }}" \ | |
| --region "${{ vars.TONBO_S3_REGION }}" \ | |
| --create-bucket-configuration LocationConstraint="${{ vars.TONBO_S3_REGION }}" || true | |
| fi | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.toml') }}-e2e-s3-real | |
| cache-on-failure: false | |
| - name: Run public API e2e (real S3) | |
| if: ${{ env.AWS_ROLE_ARN != '' }} | |
| env: | |
| TONBO_S3_BUCKET: ${{ vars.TONBO_S3_BUCKET }} | |
| TONBO_S3_REGION: ${{ vars.TONBO_S3_REGION }} | |
| TONBO_S3_ENDPOINT: https://s3.${{ vars.TONBO_S3_REGION }}.amazonaws.com | |
| TONBO_S3_ACCESS_KEY: ${{ env.AWS_ACCESS_KEY_ID }} | |
| TONBO_S3_SECRET_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
| TONBO_S3_SESSION_TOKEN: ${{ env.AWS_SESSION_TOKEN }} | |
| run: | | |
| cargo test --package tonbo --lib public_api_e2e:: -- --nocapture | |
| wasm: | |
| name: wasm edge worker | |
| runs-on: ubuntu-latest | |
| services: | |
| localstack: | |
| image: localstack/localstack:3.0.2 | |
| ports: | |
| - 4566:4566 | |
| env: | |
| SERVICES: s3 | |
| DEBUG: 0 | |
| options: >- | |
| --health-cmd "curl -f http://localhost:4566/health || exit 1" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 30 | |
| env: | |
| AWS_ACCESS_KEY_ID: test | |
| AWS_SECRET_ACCESS_KEY: test | |
| AWS_ENDPOINT_URL: http://localhost:4566 | |
| FUSIO_EDGE_S3_ENDPOINT: http://localhost:4566 | |
| FUSIO_EDGE_S3_BUCKET: fusio-test | |
| FUSIO_EDGE_S3_REGION: us-east-1 | |
| FUSIO_EDGE_S3_ACCESS_KEY: test | |
| FUSIO_EDGE_S3_SECRET_KEY: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust 1.90 + wasm target | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: "1.90" | |
| target: wasm32-unknown-unknown | |
| override: true | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.toml') }}-wasm | |
| cache-on-failure: false | |
| - name: Install wasm-bindgen-cli | |
| run: cargo install wasm-bindgen-cli --version 0.2.106 --locked | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Clean wasm target | |
| run: cargo clean --target wasm32-unknown-unknown | |
| - name: Prepare LocalStack bucket | |
| run: | | |
| aws --endpoint-url="$FUSIO_EDGE_S3_ENDPOINT" s3 mb s3://$FUSIO_EDGE_S3_BUCKET --region $FUSIO_EDGE_S3_REGION || true | |
| aws --endpoint-url="$FUSIO_EDGE_S3_ENDPOINT" s3api put-bucket-cors --bucket $FUSIO_EDGE_S3_BUCKET --cors-configuration '{"CORSRules":[{"AllowedOrigins":["*"],"AllowedMethods":["GET","PUT","HEAD"],"AllowedHeaders":["*"],"ExposeHeaders":["ETag","x-amz-request-id","x-amz-version-id"],"MaxAgeSeconds":300}]}' | |
| # - name: Build wasm edge_worker example | |
| # run: cargo build --target wasm32-unknown-unknown --no-default-features --features web --example edge_worker | |
| # - name: Generate wasm bindings | |
| # run: wasm-bindgen --target web --out-dir dist target/wasm32-unknown-unknown/debug/examples/edge_worker.wasm | |
| # - name: Run wasm edge_worker tests (browser) | |
| # run: wasm-pack test --chrome --headless --no-default-features --features web --test edge_worker |