Skip to content

Commit b224770

Browse files
committed
feat: Add bash script to build and run fuzz testing
1 parent 1345a53 commit b224770

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

fuzz-testing/run.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
# Usage: ./run.sh
21+
# Builds necessary JARs, generates data and queries, and runs fuzz tests for Comet Spark.
22+
# Environment variables:
23+
# SPARK_HOME - path to Spark installation
24+
# SPARK_MASTER - Spark master URL (default: local[*])
25+
# NUM_FILES - number of data files to generate (default: 2)
26+
# NUM_ROWS - number of rows per file (default: 200)
27+
# NUM_QUERIES - number of queries to generate (default: 500)
28+
29+
set -eux
30+
31+
DIR="$(cd "$(dirname "$0")" && pwd)"
32+
PARENT_DIR="${DIR}/.."
33+
MVN_CMD="${PARENT_DIR}/mvnw"
34+
SPARK_MASTER="${SPARK_MASTER:-local[*]}"
35+
PROJECT_VERSION=$("${MVN_CMD}" -f "${DIR}/pom.xml" -q help:evaluate -Dexpression=project.version -DforceStdout)
36+
COMET_SPARK_ARTIFACT_ID=$("${MVN_CMD}" -f "${PARENT_DIR}/spark/pom.xml" -q help:evaluate -Dexpression=project.artifactId -DforceStdout)
37+
COMET_SPARK_JAR="${PARENT_DIR}/spark/target/${COMET_SPARK_ARTIFACT_ID}-${PROJECT_VERSION}.jar"
38+
COMET_FUZZ_ARTIFACT_ID=$("${MVN_CMD}" -f "${DIR}/pom.xml" -q help:evaluate -Dexpression=project.artifactId -DforceStdout)
39+
COMET_FUZZ_JAR="${DIR}/target/${COMET_FUZZ_ARTIFACT_ID}-${PROJECT_VERSION}-jar-with-dependencies.jar"
40+
NUM_FILES="${NUM_FILES:-2}"
41+
NUM_ROWS="${NUM_ROWS:-200}"
42+
NUM_QUERIES="${NUM_QUERIES:-500}"
43+
44+
if [ ! -f "${COMET_SPARK_JAR}" ]; then
45+
echo "Building Comet Spark jar..."
46+
pushd "${PARENT_DIR}"
47+
make
48+
popd
49+
else
50+
echo "Building Fuzz testing jar..."
51+
"${MVN_CMD}" -f "${DIR}/pom.xml" package -DskipTests
52+
fi
53+
54+
echo "Generating data..."
55+
"${SPARK_HOME}/bin/spark-submit" \
56+
--master "${SPARK_MASTER}" \
57+
--class org.apache.comet.fuzz.Main \
58+
"${COMET_FUZZ_JAR}" \
59+
data --num-files="${NUM_FILES}" --num-rows="${NUM_ROWS}" \
60+
--exclude-negative-zero \
61+
--generate-arrays --generate-structs --generate-maps
62+
63+
echo "Generating queries..."
64+
"${SPARK_HOME}/bin/spark-submit" \
65+
--master "${SPARK_MASTER}" \
66+
--class org.apache.comet.fuzz.Main \
67+
"${COMET_FUZZ_JAR}" \
68+
queries --num-files="${NUM_FILES}" --num-queries="${NUM_QUERIES}"
69+
70+
echo "Running fuzz tests..."
71+
"${SPARK_HOME}/bin/spark-submit" \
72+
--master "${SPARK_MASTER}" \
73+
--conf spark.memory.offHeap.enabled=true \
74+
--conf spark.memory.offHeap.size=16G \
75+
--conf spark.plugins=org.apache.spark.CometPlugin \
76+
--conf spark.comet.enabled=true \
77+
--conf spark.shuffle.manager=org.apache.spark.sql.comet.execution.shuffle.CometShuffleManager \
78+
--conf spark.comet.exec.shuffle.enabled=true \
79+
--jars "${COMET_SPARK_JAR}" \
80+
--conf spark.driver.extraClassPath="${COMET_SPARK_JAR}" \
81+
--conf spark.executor.extraClassPath="${COMET_SPARK_JAR}" \
82+
--class org.apache.comet.fuzz.Main \
83+
"${COMET_FUZZ_JAR}" \
84+
run --num-files="${NUM_FILES}" --filename="queries.sql"

0 commit comments

Comments
 (0)