Skip to content

Commit 98715d6

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 59178cd commit 98715d6

File tree

4 files changed

+123
-3
lines changed

4 files changed

+123
-3
lines changed

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

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

471+
std::unordered_set<std::string> skipFunctionsLocalRunner = {};
472+
464473
int main(int argc, char** argv) {
465474
::testing::InitGoogleTest(&argc, argv);
466475

@@ -480,6 +489,7 @@ int main(int argc, char** argv) {
480489
std::shared_ptr<facebook::velox::memory::MemoryPool> rootPool{
481490
facebook::velox::memory::memoryManager()->addRootPool()};
482491
std::shared_ptr<ReferenceQueryRunner> referenceQueryRunner{nullptr};
492+
auto shouldAdjustTimestampToSessionTimezone = "true";
483493

484494
if (!FLAGS_presto_url.empty()) {
485495
// Add additional functions to skip since we are now querying Presto
@@ -492,13 +502,23 @@ int main(int argc, char** argv) {
492502
"expression_fuzzer",
493503
static_cast<std::chrono::milliseconds>(FLAGS_req_timeout_ms));
494504
LOG(INFO) << "Using Presto as the reference DB.";
505+
} else if (!FLAGS_local_runner_url.empty()) {
506+
shouldAdjustTimestampToSessionTimezone = "false";
507+
skipFunctions.insert(
508+
skipFunctionsLocalRunner.begin(), skipFunctionsLocalRunner.end());
509+
referenceQueryRunner = std::make_shared<VeloxQueryRunner>(
510+
rootPool.get(),
511+
FLAGS_local_runner_url,
512+
std::chrono::milliseconds(FLAGS_req_timeout_ms));
513+
LOG(INFO) << "Using LocalQueryRunner as the reference engine.";
495514
}
496515
FuzzerRunner::runFromGtest(
497516
initialSeed,
498517
skipFunctions,
499518
exprTransformers,
500519
{{"session_timezone", "America/Los_Angeles"},
501-
{"adjust_timestamp_to_session_timezone", "true"}},
520+
{"adjust_timestamp_to_session_timezone",
521+
shouldAdjustTimestampToSessionTimezone}},
502522
argTypesGenerators,
503523
argValuesGenerators,
504524
referenceQueryRunner,

0 commit comments

Comments
 (0)