Add Postgres for lock management #70
Workflow file for this run
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: Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| test: | |
| name: Test ${{ matrix.kvstorage }} + ${{ matrix.locks }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - kvstorage: sqlite | |
| locks: memory | |
| - kvstorage: postgres | |
| locks: memory | |
| - kvstorage: postgres | |
| locks: postgres | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: s3dedup_test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Start MinIO | |
| run: | | |
| docker run -d \ | |
| --name minio \ | |
| -p 9000:9000 \ | |
| -e MINIO_ROOT_USER=minioadmin \ | |
| -e MINIO_ROOT_PASSWORD=minioadmin \ | |
| minio/minio server /data | |
| # Wait for MinIO to be ready | |
| sleep 10 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache cargo registry | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo index | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo build | |
| uses: actions/cache@v3 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Create db directory | |
| run: mkdir -p db | |
| - name: Set up MinIO bucket | |
| run: | | |
| # Install mc (MinIO client) | |
| wget -q https://dl.min.io/client/mc/release/linux-amd64/mc | |
| chmod +x mc | |
| ./mc alias set local http://localhost:9000 minioadmin minioadmin | |
| ./mc mb local/bucket1 || true | |
| - name: Run tests (SQLite) | |
| if: matrix.kvstorage == 'sqlite' | |
| run: cargo test --verbose | |
| env: | |
| RUST_LOG: debug | |
| - name: Run tests (Postgres + Memory Locks) | |
| if: matrix.kvstorage == 'postgres' && matrix.locks == 'memory' | |
| run: | | |
| # Create a test config for Postgres with memory locks | |
| cat > config.test.json << EOF | |
| { | |
| "logging": { | |
| "level": "debug", | |
| "json": false | |
| }, | |
| "buckets": [ | |
| { | |
| "name": "bucket1", | |
| "address": "0.0.0.0", | |
| "port": 3000, | |
| "kvstorage_type": "postgres", | |
| "postgres": { | |
| "host": "localhost", | |
| "port": 5432, | |
| "user": "postgres", | |
| "password": "postgres", | |
| "dbname": "s3dedup_test", | |
| "pool_size": 10 | |
| }, | |
| "locks_type": "memory", | |
| "s3storage_type": "minio", | |
| "minio": { | |
| "endpoint": "http://localhost:9000", | |
| "access_key": "minioadmin", | |
| "secret_key": "minioadmin", | |
| "force_path_style": true | |
| } | |
| } | |
| ] | |
| } | |
| EOF | |
| # Run tests | |
| cargo test --verbose | |
| env: | |
| RUST_LOG: debug | |
| DATABASE_URL: postgres://postgres:postgres@localhost:5432/s3dedup_test | |
| - name: Run tests (Postgres + Postgres Locks) | |
| if: matrix.kvstorage == 'postgres' && matrix.locks == 'postgres' | |
| run: | | |
| # Create a test config for Postgres with PostgreSQL locks | |
| cat > config.test.json << EOF | |
| { | |
| "logging": { | |
| "level": "debug", | |
| "json": false | |
| }, | |
| "buckets": [ | |
| { | |
| "name": "bucket1", | |
| "address": "0.0.0.0", | |
| "port": 3000, | |
| "kvstorage_type": "postgres", | |
| "postgres": { | |
| "host": "localhost", | |
| "port": 5432, | |
| "user": "postgres", | |
| "password": "postgres", | |
| "dbname": "s3dedup_test", | |
| "pool_size": 10 | |
| }, | |
| "locks_type": "postgres", | |
| "s3storage_type": "minio", | |
| "minio": { | |
| "endpoint": "http://localhost:9000", | |
| "access_key": "minioadmin", | |
| "secret_key": "minioadmin", | |
| "force_path_style": true | |
| } | |
| } | |
| ] | |
| } | |
| EOF | |
| # Run tests | |
| cargo test --verbose | |
| env: | |
| RUST_LOG: debug | |
| DATABASE_URL: postgres://postgres:postgres@localhost:5432/s3dedup_test | |
| - name: Clean up test databases | |
| if: always() | |
| run: rm -rf db/test_*.db* |