Skip to content

Commit

Permalink
src/test: Using gtest-parallel to speedup unittests
Browse files Browse the repository at this point in the history
Unittests are run sequentially and could take a long while to run.

This commit is about using gtest-parallel on some of them which are
known to be very slow due to this sequentiality.

To enable the parallel features, the 'parallel' argument just have to be
added to the add_ceph_unittest() call like in :
    -add_ceph_unittest(unittest_throttle)
    +add_ceph_unittest(unittest_throttle parallel)

This commit impact the following tests :

Test name                          Before   After (in seconds)
unittest_erasure_code_shec_all:       212      43
unittest_throttle                      15       5
unittest_crush                          9       6
unittest_rbd_mirror                    79      21

Total                                 315      75

This commit saves 240 seconds (4 minutes) per build.

Note it exist several other long tests but can't be parallelized since
there is explicit dependencies in the order to run the subtests.
Those stay sequential.

Signed-off-by: Erwan Velu <[email protected]>
  • Loading branch information
Erwan Velu committed Jun 15, 2018
1 parent 42ff13c commit 13bc625
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions cmake/modules/AddCephTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ endfunction()

#sets uniform compiler flags and link libraries
function(add_ceph_unittest unittest_name)
add_ceph_test(${unittest_name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${unittest_name})
set(UNITTEST "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${unittest_name}")
# If the second argument is "parallel", it means we want a parallel run
if("${ARGV1}" STREQUAL "parallel")
set(UNITTEST ${CMAKE_SOURCE_DIR}/src/test/gtest-parallel/gtest-parallel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${unittest_name})
endif()
add_ceph_test(${unittest_name} "${UNITTEST}")
target_link_libraries(${unittest_name} ${UNITTEST_LIBS})
set_target_properties(${unittest_name} PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS})
endfunction()

2 changes: 1 addition & 1 deletion src/test/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ add_executable(unittest_throttle
Throttle.cc
$<TARGET_OBJECTS:unit-main>
)
add_ceph_unittest(unittest_throttle)
add_ceph_unittest(unittest_throttle parallel)
target_link_libraries(unittest_throttle global)

# unittest_lru
Expand Down
2 changes: 1 addition & 1 deletion src/test/crush/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ add_executable(unittest_crush
crush.cc
$<TARGET_OBJECTS:unit-main>
)
add_ceph_unittest(unittest_crush)
add_ceph_unittest(unittest_crush parallel)
target_link_libraries(unittest_crush global m ${BLKID_LIBRARIES})

add_ceph_test(crush_weights.sh ${CMAKE_CURRENT_SOURCE_DIR}/crush_weights.sh)
2 changes: 1 addition & 1 deletion src/test/erasure-code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ target_link_libraries(unittest_erasure_code_shec
add_executable(unittest_erasure_code_shec_all
TestErasureCodeShec_all.cc
)
add_ceph_unittest(unittest_erasure_code_shec_all)
add_ceph_unittest(unittest_erasure_code_shec_all parallel)
target_link_libraries(unittest_erasure_code_shec_all
global
${CMAKE_DL_LIBS}
Expand Down
2 changes: 1 addition & 1 deletion src/test/rbd_mirror/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ add_executable(unittest_rbd_mirror
image_sync/test_mock_SyncPointPruneRequest.cc
pool_watcher/test_mock_RefreshImagesRequest.cc
)
add_ceph_unittest(unittest_rbd_mirror)
add_ceph_unittest(unittest_rbd_mirror parallel)
set_target_properties(unittest_rbd_mirror PROPERTIES COMPILE_FLAGS
${UNITTEST_CXX_FLAGS})
add_dependencies(unittest_rbd_mirror
Expand Down

0 comments on commit 13bc625

Please sign in to comment.