Skip to content

Commit

Permalink
refactor(fuzzer): Unlink CacheFuzzer from GTest (#12386)
Browse files Browse the repository at this point in the history
Summary:
CacheFuzzer is not a test since it does not use any GTest features.
It is an executable similar to benchmarks.
We must move it from the tests folder into the fuzzer folder.

Fixes #12375

Pull Request resolved: #12386

Reviewed By: xiaoxmeng

Differential Revision: D69924290

Pulled By: mbasmanova

fbshipit-source-id: 79b1be13ef8e973b3da6cdd47d9e68a11c6fb94c
  • Loading branch information
xin-zhang2 authored and facebook-github-bot committed Feb 21, 2025
1 parent 88a05e3 commit 9c94e7f
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 83 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: cache_fuzzer
path: velox/_build/debug/velox/exec/tests/velox_cache_fuzzer_test
path: velox/_build/debug/velox/exec/fuzzer/velox_cache_fuzzer
retention-days: "${{ env.RETENTION }}"

- name: Upload table evolution fuzzer
Expand Down Expand Up @@ -762,24 +762,24 @@ jobs:

- name: Run Cache Fuzzer
run: |
mkdir -p /tmp/cache_fuzzer_test/logs/
chmod -R 777 /tmp/cache_fuzzer_test
chmod +x velox_cache_fuzzer_test
./velox_cache_fuzzer_test \
mkdir -p /tmp/cache_fuzzer/logs/
chmod -R 777 /tmp/cache_fuzzer
chmod +x velox_cache_fuzzer
./velox_cache_fuzzer \
--seed ${RANDOM} \
--duration_sec $DURATION \
--minloglevel=0 \
--stderrthreshold=2 \
--log_dir=/tmp/cache_fuzzer_test/logs \
--log_dir=/tmp/cache_fuzzer/logs \
&& echo -e "\n\Cache fuzzer run finished successfully."
- name: Archive Cache production artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: cache-fuzzer-test-logs
name: cache-fuzzer-logs
path: |
/tmp/cache_fuzzer_test
/tmp/cache_fuzzer
table-evolution-fuzzer-run:
name: Table Evolution Fuzzer
Expand Down
4 changes: 2 additions & 2 deletions velox/docs/develop/testing/cache-fuzzer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ During each iteration, the fuzzer performs the following actions steps by steps:
How to run
----------

Use velox_cache_fuzzer_test binary to run cache fuzzer:
Use velox_cache_fuzzer binary to run cache fuzzer:

::

velox/exec/tests/velox_cache_fuzzer_test
velox/exec/fuzzer/velox_cache_fuzzer

By default, the fuzzer will go through 10 interations. Use --steps
or --duration-sec flag to run fuzzer for longer. Use --seed to
Expand Down
11 changes: 9 additions & 2 deletions velox/exec/fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ target_link_libraries(
velox_functions_prestosql
velox_aggregates)

add_library(velox_cache_fuzzer CacheFuzzer.cpp)
add_library(velox_cache_fuzzer_lib CacheFuzzer.cpp)

# Cache Fuzzer
add_executable(velox_cache_fuzzer CacheFuzzerRunner.cpp)

target_link_libraries(
velox_cache_fuzzer velox_cache_fuzzer_lib velox_fuzzer_util)

target_link_libraries(
velox_cache_fuzzer velox_dwio_common velox_temp_path velox_vector_test_lib)
velox_cache_fuzzer_lib velox_dwio_common velox_temp_path
velox_vector_test_lib)
11 changes: 5 additions & 6 deletions velox/exec/fuzzer/CacheFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
#include "velox/exec/fuzzer/CacheFuzzer.h"

#include <boost/random/uniform_int_distribution.hpp>

#include <folly/executors/IOThreadPoolExecutor.h>
#include <gtest/gtest.h>

#include "velox/common/caching/FileIds.h"
#include "velox/common/caching/SsdCache.h"
#include "velox/common/file/FileSystems.h"
Expand Down Expand Up @@ -86,7 +85,7 @@ using namespace facebook::velox::cache;
using namespace facebook::velox::dwio::common;
using namespace facebook::velox::tests::utils;

namespace facebook::velox::exec::test {
namespace facebook::velox::exec {
namespace {

class CacheFuzzer {
Expand Down Expand Up @@ -474,7 +473,7 @@ void CacheFuzzer::read(uint32_t fileIdx, int32_t fragmentIdx) {
// Verify read content.
const auto* data = reinterpret_cast<const uint8_t*>(buffer);
for (int32_t sequence = 0; sequence < size; ++sequence) {
ASSERT_EQ(data[sequence], (offset + numRead + sequence) % 256);
VELOX_CHECK_EQ(data[sequence], (offset + numRead + sequence) % 256);
}
}
numRead += size;
Expand All @@ -489,7 +488,7 @@ void CacheFuzzer::read(uint32_t fileIdx, int32_t fragmentIdx) {
}
}
}
ASSERT_EQ(numRead, length);
VELOX_CHECK_EQ(numRead, length);
}

void CacheFuzzer::go() {
Expand Down Expand Up @@ -548,4 +547,4 @@ void cacheFuzzer(size_t seed) {
auto cacheFuzzer = CacheFuzzer(seed);
cacheFuzzer.go();
}
} // namespace facebook::velox::exec::test
} // namespace facebook::velox::exec
4 changes: 2 additions & 2 deletions velox/exec/fuzzer/CacheFuzzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include <cstddef>

namespace facebook::velox::exec::test {
namespace facebook::velox::exec {
/// Runs the async data cache fuzzer.
/// @param seed Random seed - Pass the same seed for reproducibility.
void cacheFuzzer(size_t seed);
} // namespace facebook::velox::exec::test
} // namespace facebook::velox::exec
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

#include <folly/init/Init.h>
#include <gflags/gflags.h>
#include <gtest/gtest.h>

#include "velox/exec/fuzzer/CacheFuzzerRunner.h"
#include "velox/common/file/FileSystems.h"
#include "velox/common/memory/Memory.h"
#include "velox/exec/fuzzer/CacheFuzzer.h"

DEFINE_int64(
seed,
Expand All @@ -27,8 +28,6 @@ DEFINE_int64(
"results (0 means start with random seed).");

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);

// Calls common init functions in the necessary order, initializing
// singletons, installing proper signal handlers for better debugging
// experience, and initialize glog and gflags.
Expand All @@ -37,8 +36,6 @@ int main(int argc, char** argv) {
facebook::velox::memory::MemoryManager::initialize({});

size_t initialSeed = FLAGS_seed == 0 ? std::time(nullptr) : FLAGS_seed;

using Runner = facebook::velox::exec::test::CacheRunner;

return Runner::run(initialSeed);
facebook::velox::filesystems::registerLocalFileSystem();
facebook::velox::exec::cacheFuzzer(initialSeed);
}
45 changes: 0 additions & 45 deletions velox/exec/fuzzer/CacheFuzzerRunner.h

This file was deleted.

10 changes: 0 additions & 10 deletions velox/exec/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,6 @@ target_link_libraries(
velox_memory_arbitration_fuzzer_test velox_memory_arbitration_fuzzer
GTest::gtest GTest::gtest_main)

# Cache Fuzzer
add_executable(velox_cache_fuzzer_test CacheFuzzerTest.cpp)

target_link_libraries(
velox_cache_fuzzer_test
velox_cache_fuzzer
velox_fuzzer_util
GTest::gtest
GTest::gtest_main)

add_executable(velox_exchange_fuzzer_test ExchangeFuzzer.cpp)

target_link_libraries(
Expand Down

0 comments on commit 9c94e7f

Please sign in to comment.