Skip to content

Commit

Permalink
Decouple the building of benchmarks and tests (#491)
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/torcharrow#491

Tests and benchmarks targets are now de-coupled.
That means they can be built independently.
Shared functionality is moved to a common utility library.

Resolves #1704

Pull Request resolved: #2439

Reviewed By: Yuhta

Differential Revision: D39484543

Pulled By: kgpai

fbshipit-source-id: 5ac888c81a6bbfbc5a1a1c4cfd41fa2c86199bc4
  • Loading branch information
leoluan2009 authored and facebook-github-bot committed Sep 15, 2022
1 parent 3dd1f01 commit 7b518c3
Show file tree
Hide file tree
Showing 192 changed files with 272 additions and 221 deletions.
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ endif()
if(${VELOX_ENABLE_BENCHMARKS} OR ${VELOX_ENABLE_BENCHMARKS_BASIC})
set(VELOX_ENABLE_DUCKDB ON)
set(VELOX_ENABLE_PARSE ON)
set(VELOX_BUILD_TEST_UTILS ON)
endif()

if(VELOX_ENABLE_S3)
Expand Down Expand Up @@ -313,12 +314,8 @@ if(VELOX_BUILD_TESTING AND NOT VELOX_ENABLE_DUCKDB)
)
endif()

# Benchmarks and tests at some places are coupled which is not great. See
# velox/vector/CMakeLists.txt. TODO: Decouple.
set(VELOX_DISABLE_GOOGLETEST OFF)
if(NOT VELOX_BUILD_TEST_UTILS
AND NOT VELOX_BUILD_TESTING
AND NOT VELOX_ENABLE_BENCHMARKS_BASIC)
if(NOT VELOX_BUILD_TEST_UTILS AND NOT VELOX_BUILD_TESTING)
set(VELOX_DISABLE_GOOGLETEST ON)
add_definitions(-DVELOX_DISABLE_GOOGLETEST)
endif()
Expand Down
2 changes: 1 addition & 1 deletion velox/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

add_subdirectory(basic)

if(${VELOX_ENABLE_BENCHMARKS})
add_subdirectory(tpch)
endif()
2 changes: 1 addition & 1 deletion velox/benchmarks/basic/Preproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "velox/functions/lib/benchmarks/FunctionBenchmarkBase.h"
#include "velox/functions/prestosql/Comparisons.h"
#include "velox/functions/prestosql/registration/RegistrationFunctions.h"
#include "velox/vector/tests/VectorTestBase.h"
#include "velox/vector/tests/utils/VectorTestBase.h"

using namespace facebook::velox;
using namespace facebook::velox::exec;
Expand Down
2 changes: 1 addition & 1 deletion velox/benchmarks/tpch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ target_link_libraries(
velox_tpch_benchmark
velox_aggregates
velox_exec
velox_exec_test_util
velox_exec_test_lib
velox_dwio_common
velox_dwio_common_exception
velox_dwio_parquet_reader
Expand Down
2 changes: 1 addition & 1 deletion velox/common/file/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
add_library(velox_read_benchmark_lib ReadBenchmark.cpp)

target_link_libraries(velox_read_benchmark_lib velox_file velox_exception
velox_exec_test_util ${FMT} ${FOLLY_WITH_DEPENDENCIES})
velox_exec_test_lib ${FMT} ${FOLLY_WITH_DEPENDENCIES})

add_executable(velox_read_benchmark ReadBenchmarkMain.cpp)

Expand Down
2 changes: 1 addition & 1 deletion velox/common/file/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ target_link_libraries(
velox_file_test
velox_file
velox_exception
velox_exec_test_util
velox_exec_test_lib
${FMT}
${FOLLY_WITH_DEPENDENCIES}
gtest
Expand Down
3 changes: 3 additions & 0 deletions velox/connectors/hive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ add_subdirectory(storage_adapters)

if(${VELOX_BUILD_TESTING})
add_subdirectory(tests)
endif()

if(${VELOX_ENABLE_BENCHMARKS})
add_subdirectory(benchmarks)
endif()
2 changes: 1 addition & 1 deletion velox/connectors/hive/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ target_link_libraries(
velox_parse_utils
velox_parse_expression
velox_exec
velox_exec_test_util
velox_exec_test_lib
velox_hive_connector
velox_hive_partition_function
velox_memory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "velox/type/Type.h"
#include "velox/vector/ComplexVector.h"
#include "velox/vector/fuzzer/VectorFuzzer.h"
#include "velox/vector/tests/VectorMaker.h"
#include "velox/vector/tests/utils/VectorMaker.h"

DEFINE_int64(fuzzer_seed, 99887766, "Seed for random input dataset generator");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ target_link_libraries(
velox_file
velox_hdfs
velox_core
velox_exec_test_util
velox_exec_test_lib
velox_hive_connector
velox_dwio_common_exception
velox_exec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ target_link_libraries(
velox_read_benchmark_lib
velox_s3fs
velox_exception
velox_exec_test_util
velox_exec_test_lib
${FMT}
${FOLLY_WITH_DEPENDENCIES})
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ target_link_libraries(
velox_file
velox_s3fs
velox_core
velox_exec_test_util
velox_exec_test_lib
velox_hive_connector
velox_dwio_common_exception
velox_exec
Expand Down
2 changes: 1 addition & 1 deletion velox/connectors/hive/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ target_link_libraries(
velox_dwio_common_exception
velox_vector_test_lib
velox_exec
velox_exec_test_util
velox_exec_test_lib
gtest
gtest_main)
2 changes: 1 addition & 1 deletion velox/connectors/hive/tests/HivePartitionFunctionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#include "velox/connectors/hive/HivePartitionFunction.h"
#include "gtest/gtest.h"
#include "velox/vector/tests/VectorMaker.h"
#include "velox/vector/tests/utils/VectorMaker.h"

using namespace facebook::velox;

Expand Down
4 changes: 2 additions & 2 deletions velox/connectors/tpch/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ target_link_libraries(
velox_tpch_connector_test
velox_tpch_connector
velox_vector_test_lib
velox_exec_test_util
velox_exec_test_lib
velox_aggregates
gtest
gtest_main)

add_executable(velox_tpch_speed_test SpeedTest.cpp)

target_link_libraries(velox_tpch_speed_test velox_tpch_connector velox_exec
velox_exec_test_util velox_memory ${FMT})
velox_exec_test_lib velox_memory ${FMT})
2 changes: 1 addition & 1 deletion velox/docs/develop/scalar-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ Testing
-------

Add a test using FunctionBaseTest from
velox/functions/prestosql/tests/FunctionBaseTest.h as a base class. Name your test
velox/functions/prestosql/tests/utils/FunctionBaseTest.h as a base class. Name your test
and the .cpp file <function-name>Test, e.g. CardinalityTest in
CardinalityTest.cpp or IsNullTest in IsNullTest.cpp.

Expand Down
2 changes: 1 addition & 1 deletion velox/duckdb/conversion/tests/DuckWrapperTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#include "velox/duckdb/conversion/DuckWrapper.h"
#include "velox/external/duckdb/duckdb.hpp"
#include "velox/vector/tests/VectorMaker.h"
#include "velox/vector/tests/utils/VectorMaker.h"

#include <gtest/gtest.h>

Expand Down
2 changes: 1 addition & 1 deletion velox/duckdb/functions/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ target_link_libraries(
velox_functions_prestosql
velox_functions_lib
velox_functions_test_lib
velox_exec_test_util
velox_exec_test_lib
gtest
gtest_main
${gflags_LIBRARIES})
2 changes: 1 addition & 1 deletion velox/duckdb/functions/tests/DuckFunctionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
#include "velox/duckdb/functions/DuckFunctions.h"
#include "velox/functions/prestosql/tests/FunctionBaseTest.h"
#include "velox/functions/prestosql/tests/utils/FunctionBaseTest.h"

using namespace facebook::velox;

Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/test/ColumnWriterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "velox/dwio/dwrf/writer/Writer.h"
#include "velox/type/Type.h"
#include "velox/vector/DictionaryVector.h"
#include "velox/vector/tests/VectorMaker.h"
#include "velox/vector/tests/utils/VectorMaker.h"

using namespace ::testing;
using namespace facebook::velox::dwio::common;
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/test/E2EWriterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "velox/dwio/type/fbhive/HiveTypeParser.h"
#include "velox/vector/FlatVector.h"
#include "velox/vector/fuzzer/VectorFuzzer.h"
#include "velox/vector/tests/VectorMaker.h"
#include "velox/vector/tests/utils/VectorMaker.h"

using namespace ::testing;
using namespace facebook::velox::dwio::common;
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/parquet/tests/ParquetReaderTestBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#pragma once

#include "velox/dwio/common/tests/utils/DataFiles.h"
#include "velox/vector/tests/VectorMaker.h"
#include "velox/vector/tests/utils/VectorMaker.h"

#include <gtest/gtest.h>

Expand Down
4 changes: 2 additions & 2 deletions velox/dwio/parquet/tests/duckdb_reader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ add_test(
target_link_libraries(
velox_dwio_duckdb_parquet_table_scan_test
velox_dwio_parquet_reader
velox_exec_test_util
velox_exec_test_lib
velox_exec
velox_hive_connector
velox_aggregates
Expand All @@ -48,7 +48,7 @@ add_test(
target_link_libraries(
velox_dwio_duckdb_parquet_tpch_test
velox_dwio_parquet_reader
velox_exec_test_util
velox_exec_test_lib
velox_exec
velox_hive_connector
velox_aggregates
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/parquet/tests/reader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ add_test(
target_link_libraries(
velox_dwio_parquet_tpch_test
velox_dwio_parquet_reader
velox_exec_test_util
velox_exec_test_lib
velox_exec
velox_hive_connector
velox_aggregates
Expand Down
4 changes: 2 additions & 2 deletions velox/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target_link_libraries(
velox_type
velox_vector
velox_exec
velox_exec_test_util
velox_exec_test_lib
velox_hive_connector
velox_memory)

Expand All @@ -46,6 +46,6 @@ target_link_libraries(
velox_type
velox_vector
velox_exec
velox_exec_test_util
velox_exec_test_lib
velox_hive_connector
velox_memory)
5 changes: 4 additions & 1 deletion velox/exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ target_link_libraries(

if(${VELOX_BUILD_TESTING})
add_subdirectory(tests)
add_subdirectory(benchmarks)
elseif(${VELOX_BUILD_TEST_UTILS})
add_subdirectory(tests/utils)
endif()

if(${VELOX_ENABLE_BENCHMARKS})
add_subdirectory(benchmarks)
endif()
2 changes: 1 addition & 1 deletion velox/exec/benchmarks/VectorHasherBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <folly/Benchmark.h>
#include <folly/init/Init.h>
#include "velox/exec/VectorHasher.h"
#include "velox/vector/tests/VectorMaker.h"
#include "velox/vector/tests/utils/VectorMaker.h"

using namespace facebook::velox;
using namespace facebook::velox::exec;
Expand Down
4 changes: 2 additions & 2 deletions velox/exec/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ target_link_libraries(
velox_test_util
velox_type
velox_serialization
velox_exec_test_util
velox_exec_test_lib
velox_functions_json
velox_vector
velox_vector_fuzzer
Expand Down Expand Up @@ -112,6 +112,6 @@ target_link_libraries(
velox_vector
velox_vector_test_lib
velox_exec
velox_exec_test_util
velox_exec_test_lib
velox_tpch_connector
velox_memory)
2 changes: 1 addition & 1 deletion velox/exec/tests/FunctionResolutionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "velox/functions/Udf.h"
#include "velox/functions/prestosql/registration/RegistrationFunctions.h"
#include "velox/functions/prestosql/tests/FunctionBaseTest.h"
#include "velox/functions/prestosql/tests/utils/FunctionBaseTest.h"

namespace {
using namespace facebook::velox;
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/FunctionSignatureBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#include <gtest/gtest.h>
#include "velox/expression/FunctionSignature.h"
#include "velox/functions/prestosql/tests/FunctionBaseTest.h"
#include "velox/functions/prestosql/tests/utils/FunctionBaseTest.h"

using namespace facebook::velox;
using namespace facebook::velox::exec;
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/HashBitRangeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

#include "velox/exec/HashBitRange.h"
#include "velox/vector/tests/VectorTestBase.h"
#include "velox/vector/tests/utils/VectorTestBase.h"

using namespace facebook::velox;
using namespace facebook::velox::exec;
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/HashPartitionFunctionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

#include "velox/exec/HashPartitionFunction.h"
#include "velox/vector/tests/VectorTestBase.h"
#include "velox/vector/tests/utils/VectorTestBase.h"

using namespace facebook::velox;
using namespace facebook::velox::exec;
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/HashTableTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "velox/exec/HashTable.h"
#include "velox/common/base/SelectivityInfo.h"
#include "velox/exec/VectorHasher.h"
#include "velox/vector/tests/VectorMaker.h"
#include "velox/vector/tests/utils/VectorMaker.h"

#include <gtest/gtest.h>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/OrderByTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "velox/exec/tests/utils/PlanBuilder.h"
#include "velox/exec/tests/utils/QueryAssertions.h"
#include "velox/exec/tests/utils/TempDirectoryPath.h"
#include "velox/vector/tests/VectorMaker.h"
#include "velox/vector/tests/utils/VectorMaker.h"

using namespace facebook::velox;
using namespace facebook::velox::exec;
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/PlanBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "velox/exec/WindowFunction.h"
#include "velox/functions/prestosql/registration/RegistrationFunctions.h"
#include "velox/parse/TypeResolver.h"
#include "velox/vector/tests/VectorTestBase.h"
#include "velox/vector/tests/utils/VectorTestBase.h"

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

Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/PlanNodeToStringTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "velox/exec/tests/utils/PlanBuilder.h"
#include "velox/functions/prestosql/registration/RegistrationFunctions.h"
#include "velox/parse/TypeResolver.h"
#include "velox/vector/tests/VectorTestBase.h"
#include "velox/vector/tests/utils/VectorTestBase.h"

#include <gtest/gtest.h>

Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/RoundRobinPartitionFunctionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#include "velox/exec/RoundRobinPartitionFunction.h"
#include <gtest/gtest.h>
#include "velox/vector/tests/VectorMaker.h"
#include "velox/vector/tests/utils/VectorMaker.h"

using namespace facebook::velox;

Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/SpillTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "velox/common/file/FileSystems.h"
#include "velox/exec/tests/utils/TempDirectoryPath.h"
#include "velox/serializers/PrestoSerializer.h"
#include "velox/vector/tests/VectorTestBase.h"
#include "velox/vector/tests/utils/VectorTestBase.h"

using namespace facebook::velox;
using namespace facebook::velox::exec;
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/UnorderedStreamReaderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "velox/exec/UnorderedStreamReader.h"
#include "velox/vector/fuzzer/VectorFuzzer.h"
#include "velox/vector/tests/VectorTestBase.h"
#include "velox/vector/tests/utils/VectorTestBase.h"

using namespace facebook::velox;

Expand Down
Loading

0 comments on commit 7b518c3

Please sign in to comment.