From 7882ddfafb1c9eace8e53be2a58db3080b648038 Mon Sep 17 00:00:00 2001 From: WenyXu Date: Tue, 4 Jun 2024 12:36:49 +0000 Subject: [PATCH] chore: add fuzz tests with kafka --- .../setup-greptimedb-cluster/action.yml | 5 +- .../kafka-values.yaml | 28 +++++ .../actions/setup-kafka-cluster/action.yml | 24 ++++ .github/workflows/develop.yml | 105 ++++++++++++++++++ 4 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 .github/actions/setup-greptimedb-cluster/kafka-values.yaml create mode 100644 .github/actions/setup-kafka-cluster/action.yml diff --git a/.github/actions/setup-greptimedb-cluster/action.yml b/.github/actions/setup-greptimedb-cluster/action.yml index eaf0032c77..109265470f 100644 --- a/.github/actions/setup-greptimedb-cluster/action.yml +++ b/.github/actions/setup-greptimedb-cluster/action.yml @@ -22,6 +22,9 @@ inputs: etcd-endpoints: default: "etcd.etcd-cluster.svc.cluster.local:2379" description: "Etcd endpoints" + values-filename: + default: "values.yaml" + runs: using: composite @@ -57,7 +60,7 @@ runs: greptime/greptimedb-cluster \ --create-namespace \ -n my-greptimedb \ - --values ./.github/actions/setup-greptimedb-cluster/values.yaml \ + --values ./.github/actions/setup-greptimedb-cluster/${{ inputs.values-filename }} \ --wait \ --wait-for-jobs - name: Wait for GreptimeDB diff --git a/.github/actions/setup-greptimedb-cluster/kafka-values.yaml b/.github/actions/setup-greptimedb-cluster/kafka-values.yaml new file mode 100644 index 0000000000..76946bb9e0 --- /dev/null +++ b/.github/actions/setup-greptimedb-cluster/kafka-values.yaml @@ -0,0 +1,28 @@ +meta: + config: |- + [runtime] + read_rt_size = 8 + write_rt_size = 8 + bg_rt_size = 8 + + [wal] + provider = "kafka" + broker_endpoints = ["kafka.kafka-cluster.svc.cluster.local:9092"] + num_topics = 3 +datanode: + config: |- + [runtime] + read_rt_size = 8 + write_rt_size = 8 + bg_rt_size = 8 + + [wal] + provider = "kafka" + broker_endpoints = ["kafka.kafka-cluster.svc.cluster.local:9092"] + linger = "2ms" +frontend: + config: |- + [runtime] + read_rt_size = 8 + write_rt_size = 8 + bg_rt_size = 8 \ No newline at end of file diff --git a/.github/actions/setup-kafka-cluster/action.yml b/.github/actions/setup-kafka-cluster/action.yml new file mode 100644 index 0000000000..b8a7339423 --- /dev/null +++ b/.github/actions/setup-kafka-cluster/action.yml @@ -0,0 +1,24 @@ +name: Setup Kafka cluster +description: Deploy Kafka cluster on Kubernetes +inputs: + controller-replicas: + default: 3 + description: "Kafka controller replicas" + namespace: + default: "kafka-cluster" + +runs: + using: composite + steps: + - name: Install Kafka cluster + shell: bash + run: | + helm upgrade \ + --install kafka oci://registry-1.docker.io/bitnamicharts/kafka \ + --set controller.replicaCount=${{ inputs.controller-replicas }} \ + --set controller.resources.requests.cpu=50m \ + --set controller.resources.requests.memory=128Mi \ + --set listeners.controller.protocol=PLAINTEXT \ + --set listeners.client.protocol=PLAINTEXT \ + --create-namespace \ + -n ${{ inputs.namespace }} diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 52975fa746..98edc1f5e7 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -372,6 +372,111 @@ jobs: docker rm $(docker ps -a -q) docker system prune -f + distributed-fuzztest-with-kafka: + name: Fuzz Test with Kafka (Distributed, Disk) + runs-on: ubuntu-latest + needs: build-greptime-ci + strategy: + matrix: + target: [ "fuzz_create_table", "fuzz_alter_table", "fuzz_create_database", "fuzz_create_logical_table", "fuzz_alter_logical_table", "fuzz_insert", "fuzz_insert_logical_table" ] + steps: + - uses: actions/checkout@v4 + - name: Setup Kind + uses: ./.github/actions/setup-kind + - name: Setup Etcd cluser + uses: ./.github/actions/setup-etcd-cluster + - name: Setup Kafka cluser + uses: ./.github/actions/setup-kafka-cluster + # Prepares for fuzz tests + - uses: arduino/setup-protoc@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + with: + # Shares across multiple jobs + shared-key: "fuzz-test-targets" + - name: Set Rust Fuzz + shell: bash + run: | + sudo apt-get install -y libfuzzer-14-dev + rustup install nightly + cargo +nightly install cargo-fuzz + # Downloads ci image + - name: Download pre-built binariy + uses: actions/download-artifact@v4 + with: + name: bin + path: . + - name: Unzip binary + run: | + tar -xvf ./bin.tar.gz + rm ./bin.tar.gz + - name: Build and push GreptimeDB image + uses: ./.github/actions/build-and-push-ci-image + - name: Wait for etcd + run: | + kubectl wait \ + --for=condition=Ready \ + pod -l app.kubernetes.io/instance=etcd \ + --timeout=120s \ + -n etcd-cluster + - name: Wait for kafka + run: | + kubectl wait \ + --for=condition=Ready \ + pod -l app.kubernetes.io/instance=kafka \ + --timeout=120s \ + -n kafka-cluster + - name: Print etcd info + shell: bash + run: kubectl get all --show-labels -n etcd-cluster + # Setup cluster for test + - name: Setup GreptimeDB cluster + uses: ./.github/actions/setup-greptimedb-cluster + with: + image-registry: localhost:5001 + values-filename: "kafka-values.yaml" + - name: Port forward (mysql) + run: | + kubectl port-forward service/my-greptimedb-frontend 4002:4002 -n my-greptimedb& + - name: Fuzz Test + uses: ./.github/actions/fuzz-test + env: + CUSTOM_LIBFUZZER_PATH: /usr/lib/llvm-14/lib/libFuzzer.a + GT_MYSQL_ADDR: 127.0.0.1:4002 + with: + target: ${{ matrix.target }} + max-total-time: 120 + - name: Describe Nodes + if: failure() + shell: bash + run: | + kubectl describe nodes + - name: Export kind logs + if: failure() + shell: bash + run: | + kind export logs /tmp/kind + - name: Upload logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: fuzz-tests-with-kafka-kind-logs-${{ matrix.target }} + path: /tmp/kind + retention-days: 3 + - name: Delete cluster + if: success() + shell: bash + run: | + kind delete cluster + docker stop $(docker ps -a -q) + docker rm $(docker ps -a -q) + docker system prune -f + sqlness: name: Sqlness Test (${{ matrix.mode.name }}) needs: build