Skip to content

Commit 8400ee3

Browse files
peterenescumeta-codesync[bot]
authored andcommitted
feat: Support VeloxQueryRunner in Github Expression Fuzzer (facebookincubator#15483)
Summary: Pull Request resolved: facebookincubator#15483 Add Regression Fuzzer (i.e. Expression Fuzzer with LocalRunnerService as a source-of-truth) to Fuzzer Job test suite. This fuzzer sends serialized plans to a thrift service build on the base commit to test solely on new changes. Differential Revision: D86911550
1 parent f387e3a commit 8400ee3

File tree

4 files changed

+124
-3
lines changed

4 files changed

+124
-3
lines changed

.github/workflows/linux-build-base.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ jobs:
102102
"-DVELOX_ENABLE_WAVE=ON"
103103
"-DVELOX_MONO_LIBRARY=ON"
104104
"-DVELOX_BUILD_SHARED=ON"
105+
"-DVELOX_ENABLE_REMOTE_FUNCTIONS=ON"
105106
)
106107
if [[ "${USE_CLANG}" = "true" ]]; then
107108
scripts/setup-centos9.sh install_clang15; export CC=/usr/bin/clang-15; export CXX=/usr/bin/clang++-15; CUDA_FLAGS="-ccbin /usr/lib64/llvm15/bin/clang++-15";

.github/workflows/scheduled.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ jobs:
222222
-DVELOX_MONO_LIBRARY=ON
223223
-DVELOX_BUILD_PYTHON_PACKAGE=ON
224224
-DVELOX_PYTHON_LEGACY_ONLY=ON
225+
-DVELOX_ENABLE_REMOTE_FUNCTIONS=ON
225226
${{ inputs.extraCMakeFlags }}
226227
run: |
227228
make python-venv
@@ -383,6 +384,13 @@ jobs:
383384
path: velox/_build/debug/velox/exec/fuzzer/velox_spatial_join_fuzzer
384385
retention-days: ${{ env.RETENTION }}
385386

387+
- name: Upload local runner service runner
388+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
389+
with:
390+
name: local_runner_service_runner
391+
path: velox/_build/debug/velox/exec/fuzzer/velox_local_runner_service_runner
392+
retention-days: ${{ env.RETENTION }}
393+
386394
presto-fuzzer-run:
387395
name: Presto Fuzzer
388396
if: ${{ needs.compile.outputs.presto_bias != 'true' }}
@@ -459,6 +467,96 @@ jobs:
459467
path: |
460468
/tmp/fuzzer_repro
461469
470+
presto-fuzzer-with-local-runner-run:
471+
name: Presto Fuzzer with Local Runner
472+
if: ${{ needs.compile.outputs.presto_bias != 'true' }}
473+
runs-on: ubuntu-latest
474+
container: ghcr.io/facebookincubator/velox-dev:centos9
475+
needs: compile
476+
timeout-minutes: 120
477+
steps:
478+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
479+
if: github.event_name == 'pull_request'
480+
id: changes
481+
with:
482+
filters: |
483+
presto:
484+
- 'velox/expression/!(test)**'
485+
- 'velox/exec/!(test)**'
486+
- 'velox/common/!(test)**'
487+
- 'velox/core/!(test)**'
488+
- 'velox/vector/!(test)**'
489+
490+
- name: Set presto specific fuzzer duration
491+
env:
492+
# Run for 30 minutes instead of 15, when files relevant to presto are touched
493+
pr_duration: ${{ steps.changes.outputs.presto == 'true' && 1800 || 900 }}
494+
# Run for 60 minutes if its a scheduled run
495+
other_duration: ${{ inputs.duration || (github.event_name == 'push' && 1800 || 3600) }}
496+
is_pr: ${{ github.event_name == 'pull_request' }}
497+
run: |
498+
if [ "$is_pr" == "true" ]; then
499+
duration=$pr_duration
500+
else
501+
duration=$other_duration
502+
fi
503+
504+
echo "DURATION=$duration" >> $GITHUB_ENV
505+
506+
- name: Download presto fuzzer
507+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
508+
with:
509+
name: presto
510+
511+
- name: Download local runner service runner
512+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
513+
with:
514+
name: local_runner_service_runner
515+
516+
- name: Run Presto Fuzzer with Local Runner
517+
run: |
518+
mkdir -p /tmp/fuzzer_repro/logs/
519+
chmod -R 777 /tmp/fuzzer_repro
520+
chmod +x velox_expression_fuzzer_test
521+
chmod +x velox_local_runner_service_runner
522+
# Start LocalRunnerService in the background
523+
./velox_local_runner_service_runner > /tmp/fuzzer_repro/logs/local_runner_service.log 2>&1 &
524+
LOCAL_RUNNER_PID=$!
525+
echo "Started LocalRunnerService with PID: ${LOCAL_RUNNER_PID}"
526+
# Sleep for 10 seconds to allow service to start
527+
sleep 10
528+
random_seed=${RANDOM}
529+
echo "Random seed: ${random_seed}"
530+
./velox_expression_fuzzer_test \
531+
--seed ${random_seed} \
532+
--enable_variadic_signatures \
533+
--velox_fuzzer_enable_complex_types \
534+
--velox_fuzzer_enable_decimal_type \
535+
--lazy_vector_generation_ratio 0.2 \
536+
--common_dictionary_wraps_generation_ratio=0.3 \
537+
--velox_fuzzer_enable_column_reuse \
538+
--velox_fuzzer_enable_expression_reuse \
539+
--max_expression_trees_per_step 2 \
540+
--retry_with_try \
541+
--enable_dereference \
542+
--duration_sec $DURATION \
543+
--minloglevel=0 \
544+
--stderrthreshold=2 \
545+
--log_dir=/tmp/fuzzer_repro/logs \
546+
--repro_persist_path=/tmp/fuzzer_repro \
547+
--local_runner_service_url=http://127.0.0.1:9091 \
548+
&& echo -e "\n\nFuzzer run finished successfully."
549+
# Stop the LocalRunnerService
550+
kill $LOCAL_RUNNER_PID || true
551+
552+
- name: Archive production artifacts
553+
if: ${{ !cancelled() }}
554+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
555+
with:
556+
name: presto-fuzzer-with-local-runner-failure-artifacts
557+
path: |
558+
/tmp/fuzzer_repro
559+
462560
presto-sot-fuzzer-run:
463561
name: Expression Fuzzer with Presto SOT
464562
needs: compile

velox/exec/fuzzer/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ add_library(
3131
# ExpressionFuzzerTest. More information can be found here:
3232
# https://github.com/facebookincubator/velox/issues/15414
3333
if(VELOX_ENABLE_REMOTE_FUNCTIONS)
34-
target_sources(velox_fuzzer_util PRIVATE VeloxQueryRunner.cpp)
35-
target_link_libraries(velox_fuzzer_util FBThrift::thriftcpp2)
34+
target_sources(velox_fuzzer_util VeloxQueryRunner.cpp)
3635
endif()
3736

3837
target_link_libraries(
@@ -231,6 +230,9 @@ if(VELOX_ENABLE_REMOTE_FUNCTIONS)
231230

232231
target_compile_options(local_runner_service_thrift PRIVATE -Wno-error=deprecated-declarations)
233232

233+
# Link velox_fuzzer_util with local_runner_service_thrift for VeloxQueryRunner
234+
target_link_libraries(velox_fuzzer_util local_runner_service_thrift FBThrift::thriftcpp2)
235+
234236
# LocalRunnerService Library
235237
add_library(velox_local_runner_service_lib LocalRunnerService.cpp)
236238

velox/expression/fuzzer/ExpressionFuzzerTest.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <unordered_set>
1919

2020
#include "velox/exec/fuzzer/PrestoQueryRunner.h"
21+
#include "velox/exec/fuzzer/VeloxQueryRunner.h"
2122
#include "velox/expression/fuzzer/ArgTypesGenerator.h"
2223
#include "velox/expression/fuzzer/ArgValuesGenerators.h"
2324
#include "velox/expression/fuzzer/ExpressionFuzzer.h"
@@ -46,6 +47,12 @@ DEFINE_string(
4647
"source of truth. Otherwise, use the Velox simplified expression evaluation. Example: "
4748
"--presto_url=http://127.0.0.1:8080");
4849

50+
DEFINE_string(
51+
local_runner_url,
52+
"",
53+
"URI for thrift requests to LocalRunnerService. Defaults to localhost on port 9091. "
54+
"Example: --local_runner_url=http://127.0.0.1:9091");
55+
4956
DEFINE_uint32(
5057
req_timeout_ms,
5158
10000,
@@ -435,6 +442,8 @@ std::unordered_set<std::string> skipFunctionsSOT = {
435442
"jarowinkler_similarity", // https://github.com/facebookincubator/velox/issues/15736
436443
};
437444

445+
std::unordered_set<std::string> skipFunctionsLocalRunner = {};
446+
438447
int main(int argc, char** argv) {
439448
::testing::InitGoogleTest(&argc, argv);
440449

@@ -454,6 +463,7 @@ int main(int argc, char** argv) {
454463
std::shared_ptr<facebook::velox::memory::MemoryPool> rootPool{
455464
facebook::velox::memory::memoryManager()->addRootPool()};
456465
std::shared_ptr<ReferenceQueryRunner> referenceQueryRunner{nullptr};
466+
auto shouldAdjustTimestampToSessionTimezone = "true";
457467

458468
if (!FLAGS_presto_url.empty()) {
459469
// Add additional functions to skip since we are now querying Presto
@@ -466,13 +476,23 @@ int main(int argc, char** argv) {
466476
"expression_fuzzer",
467477
static_cast<std::chrono::milliseconds>(FLAGS_req_timeout_ms));
468478
LOG(INFO) << "Using Presto as the reference DB.";
479+
} else if (!FLAGS_local_runner_url.empty()) {
480+
shouldAdjustTimestampToSessionTimezone = "false";
481+
skipFunctions.insert(
482+
skipFunctionsLocalRunner.begin(), skipFunctionsLocalRunner.end());
483+
referenceQueryRunner = std::make_shared<VeloxQueryRunner>(
484+
rootPool.get(),
485+
FLAGS_local_runner_url,
486+
std::chrono::milliseconds(FLAGS_req_timeout_ms));
487+
LOG(INFO) << "Using LocalQueryRunner as the reference engine.";
469488
}
470489
FuzzerRunner::runFromGtest(
471490
initialSeed,
472491
skipFunctions,
473492
exprTransformers,
474493
{{"session_timezone", "America/Los_Angeles"},
475-
{"adjust_timestamp_to_session_timezone", "true"}},
494+
{"adjust_timestamp_to_session_timezone",
495+
shouldAdjustTimestampToSessionTimezone}},
476496
argTypesGenerators,
477497
argValuesGenerators,
478498
referenceQueryRunner,

0 commit comments

Comments
 (0)