Skip to content

Commit

Permalink
ci: Refactor fuzz to integrate with test planner (#3936)
Browse files Browse the repository at this point in the history
* ci: Refactor fuzz to integrate with test planner

Signed-off-by: Xuanwo <[email protected]>

* Fix

Signed-off-by: Xuanwo <[email protected]>

* Handling write-min-size

Signed-off-by: Xuanwo <[email protected]>

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Jan 7, 2024
1 parent a8ba758 commit b5b42bc
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 329 deletions.
49 changes: 49 additions & 0 deletions .github/actions/fuzz_test/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Fuzz Test
description: 'Fuzz test given setup and service'
inputs:
setup:
description: "The setup action for test"
service:
description: "The service to test"
target:
description: "The fuzz target to test"

runs:
using: "composite"
steps:
- name: Setup
shell: bash
run: |
mkdir -p ./dynamic_fuzz_test &&
cat <<EOF >./dynamic_fuzz_test/action.yml
runs:
using: composite
steps:
- name: Setup Fuzz Test
uses: ./.github/services/${{ inputs.service }}/${{ inputs.setup }}
- name: Run Fuzz Test
shell: bash
working-directory: core/fuzz
run: cargo +nightly fuzz run ${{ inputs.target }} --features services-${{ inputs.service }} -- -max_total_time=120
env:
OPENDAL_TEST: ${{ inputs.service }}
EOF
- name: Run
uses: ./dynamic_fuzz_test
176 changes: 20 additions & 156 deletions .github/workflows/fuzz_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,175 +28,39 @@ on:
- "core/src/**"
- "core/fuzz/**"
- "!core/src/docs/**"
- "!core/src/services/**"
- "core/src/services/fs/**"
- "core/src/services/memory/**"
- "core/src/services/s3/**"
- ".github/workflows/fuzz_test.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
fuzz-build:
fuzz:
name: ${{ matrix.cases.service }} / ${{ matrix.cases.setup }} / ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
matrix:
target: [ "fuzz_reader", "fuzz_writer" ]
cases:
- { service: "memory", setup: "memory" }
- { service: "fs", setup: "local_fs" }
- { service: "s3", setup: "minio_s3" }
- { service: "azblob", setup: "azurite_azblob" }
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: ./.github/actions/setup
- name: Install libfuzz
shell: bash
run: sudo apt-get install -y libfuzzer-14-dev

- name: Install cargo fuzz
- name: Set Rust Fuzz
shell: bash
run: rustup install nightly && cargo +nightly install cargo-fuzz
- name: Build Fuzz Targets
shell: bash
working-directory: core/fuzz
run: cargo +nightly fuzz build
run: |
sudo apt-get install -y libfuzzer-14-dev
rustup install nightly
cargo +nightly install cargo-fuzz
- name: Fuzz
uses: ./.github/actions/fuzz_test
env:
CUSTOM_LIBFUZZER_PATH: /usr/lib/llvm-14/lib/libFuzzer.a

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: fuzz_targets
path: |
./target/x86_64-unknown-linux-gnu/release/fuzz_reader
./target/x86_64-unknown-linux-gnu/release/fuzz_reader_with_buffer
./target/x86_64-unknown-linux-gnu/release/fuzz_writer
fuzz-test-s3:
runs-on: ubuntu-latest
needs: fuzz-build
services:
minio:
image: wktk/minio-server
ports:
- 9000:9000
env:
MINIO_ACCESS_KEY: "minioadmin"
MINIO_SECRET_KEY: "minioadmin"
strategy:
fail-fast: true
matrix:
fuzz-targets: [fuzz_reader, fuzz_reader_with_buffer, fuzz_writer]
steps:
- name: Install libfuzzer
run: sudo apt-get install -y libfuzzer-14-dev
- name: Setup Test Bucket
env:
AWS_ACCESS_KEY_ID: "minioadmin"
AWS_SECRET_ACCESS_KEY: "minioadmin"
AWS_EC2_METADATA_DISABLED: "true"
run: aws --endpoint-url http://127.0.0.1:9000/ s3 mb s3://test
- name: Download Fuzz Targets
uses: actions/download-artifact@v3
with:
name: fuzz_targets
path: ./target
- name: Grant Execute Permissions
shell: bash
run: chmod +x ./target/${{ matrix.fuzz-targets }}
- name: Run Fuzz Test
shell: bash
run: ./target/${{ matrix.fuzz-targets }} -max_total_time=120
env:
OPENDAL_S3_TEST: on
OPENDAL_S3_BUCKET: test
OPENDAL_S3_ENDPOINT: "http://127.0.0.1:9000"
OPENDAL_S3_ACCESS_KEY_ID: minioadmin
OPENDAL_S3_SECRET_ACCESS_KEY: minioadmin
OPENDAL_S3_REGION: us-east-1

fuzz-test-fs:
runs-on: ubuntu-latest
needs: fuzz-build
strategy:
fail-fast: true
matrix:
fuzz-targets: [fuzz_reader, fuzz_reader_with_buffer, fuzz_writer]
steps:
- name: Install libfuzzer
run: sudo apt-get install -y libfuzzer-14-dev
- name: Download Fuzz Targets
uses: actions/download-artifact@v3
with:
name: fuzz_targets
path: ./target
- name: Grant Execute Permissions
shell: bash
run: chmod +x ./target/${{ matrix.fuzz-targets }}
- name: Run Fuzz Test
shell: bash
run: ./target/${{ matrix.fuzz-targets }} -max_total_time=120
env:
OPENDAL_FS_TEST: on
OPENDAL_FS_ROOT: ${{ runner.temp }}/

fuzz-test-memory:
runs-on: ubuntu-latest
needs: fuzz-build
strategy:
fail-fast: true
matrix:
fuzz-targets: [fuzz_reader, fuzz_reader_with_buffer, fuzz_writer]
steps:
- name: Install libfuzzer
run: sudo apt-get install -y libfuzzer-14-dev
- name: Download Fuzz Targets
uses: actions/download-artifact@v3
with:
name: fuzz_targets
path: ./target
- name: Grant Execute Permissions
shell: bash
run: chmod +x ./target/${{ matrix.fuzz-targets }}
- name: Run Fuzz Test
shell: bash
run: ./target/${{ matrix.fuzz-targets }} -max_total_time=120
env:
OPENDAL_MEMORY_TEST: on


fuzz-test-azure:
runs-on: ubuntu-latest
needs: fuzz-build
services:
azurite:
image: mcr.microsoft.com/azure-storage/azurite
ports:
- 10000:10000
strategy:
fail-fast: true
matrix:
fuzz-targets: [fuzz_reader, fuzz_reader_with_buffer, fuzz_writer]
steps:
- name: Install libfuzzer
run: sudo apt-get install -y libfuzzer-14-dev
- name: Setup test bucket
shell: bash
run: |
az storage container create \
--name test \
--connection-string "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;"
- name: Download Fuzz Targets
uses: actions/download-artifact@v3
with:
name: fuzz_targets
path: ./target
- name: Grant Execute Permissions
shell: bash
run: chmod +x ./target/${{ matrix.fuzz-targets }}
- name: Run Fuzz Test
shell: bash
run: ./target/${{ matrix.fuzz-targets }} -max_total_time=120
env:
OPENDAL_AZBLOB_TEST: on
OPENDAL_AZBLOB_CONTAINER: test
OPENDAL_AZBLOB_ENDPOINT: "http://127.0.0.1:10000/devstoreaccount1"
OPENDAL_AZBLOB_ACCOUNT_NAME: devstoreaccount1
OPENDAL_AZBLOB_ACCOUNT_KEY: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

setup: ${{ matrix.cases.setup }}
service: ${{ matrix.cases.service }}
target: ${{ matrix.target }}
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 53 additions & 4 deletions core/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,58 @@ license.workspace = true
[package.metadata]
cargo-fuzz = true

[features]
services-alluxio = ["opendal/services-alluxio"]
services-azblob = ["opendal/services-azblob"]
services-azdls = ["opendal/services-azdls"]
services-azfile = ["opendal/services-azfile"]
services-b2 = ["opendal/services-b2"]
services-cacache = ["opendal/services-cacache"]
services-cos = ["opendal/services-cos"]
services-dashmap = ["opendal/services-dashmap"]
services-dropbox = ["opendal/services-dropbox"]
services-etcd = ["opendal/services-etcd"]
services-foundationdb = ["opendal/services-foundationdb"]
services-fs = ["opendal/services-fs"]
services-ftp = ["opendal/services-ftp"]
services-gcs = ["opendal/services-gcs"]
services-gdrive = ["opendal/services-gdrive"]
services-ghac = ["opendal/services-ghac"]
services-gridfs = ["opendal/services-gridfs"]
services-hdfs = ["opendal/services-hdfs"]
services-http = ["opendal/services-http"]
services-huggingface = ["opendal/services-huggingface"]
services-ipfs = ["opendal/services-ipfs"]
services-ipmfs = ["opendal/services-ipmfs"]
services-libsql = ["opendal/services-libsql"]
services-memcached = ["opendal/services-memcached"]
services-memory = ["opendal/services-memory"]
services-mini-moka = ["opendal/services-mini-moka"]
services-moka = ["opendal/services-moka"]
services-mongodb = ["opendal/services-mongodb"]
services-mysql = ["opendal/services-mysql"]
services-obs = ["opendal/services-obs"]
services-onedrive = ["opendal/services-onedrive"]
services-oss = ["opendal/services-oss"]
services-persy = ["opendal/services-persy"]
services-postgresql = ["opendal/services-postgresql"]
services-redb = ["opendal/services-redb"]
services-redis = ["opendal/services-redis"]
services-rocksdb = ["opendal/services-rocksdb"]
services-s3 = ["opendal/services-s3"]
services-seafile = ["opendal/services-seafile"]
services-sftp = ["opendal/services-sftp"]
services-sled = ["opendal/services-sled"]
services-sqlite = ["opendal/services-sqlite"]
services-supabase = ["opendal/services-supabase"]
services-swift = ["opendal/services-swift"]
services-tikv = ["opendal/services-tikv"]
services-upyun = ["opendal/services-upyun"]
services-vercel-artifacts = ["opendal/services-vercel-artifacts"]
services-wasabi = ["opendal/services-wasabi"]
services-webdav = ["opendal/services-webdav"]
services-webhdfs = ["opendal/services-webhdfs"]

[dependencies]
anyhow = "1.0.71"
arbitrary = { version = "1.3.0", features = ["derive"] }
Expand All @@ -34,16 +86,13 @@ dotenvy = "0.15.6"
libfuzzer-sys = "0.4"
opendal = { path = "..", features = ["tests"] }
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = [
"env-filter",
"tracing-log",
] }
uuid = { version = "1", features = ["v4"] }

[[bin]]
name = "fuzz_reader_with_buffer"
path = "fuzz_reader_with_buffer.rs"

[[bin]]
name = "fuzz_reader"
path = "fuzz_reader.rs"
Expand Down
Loading

0 comments on commit b5b42bc

Please sign in to comment.