Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for util unit tests #288

Merged
merged 44 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e54b23e
Add tests for util/datetime into listfile (#155)
tsayukov Aug 6, 2024
d069898
Wrap other tests with 'add_ydb_util_tests'
tsayukov Aug 7, 2024
3e9713a
Add tests for util/generic into listfile (#158)
tsayukov Aug 7, 2024
d742035
Add tests for util/memory into listfile (#159)
tsayukov Aug 7, 2024
1137eba
Add tests for util/random into listfile (#161)
tsayukov Aug 7, 2024
8e32c0f
Add tests for util/stream into listfile (#162)
tsayukov Aug 7, 2024
b910b57
Add tests for util/string into listfile (#163)
tsayukov Aug 7, 2024
fcc2203
Add tests for util/system into listfile (#164)
tsayukov Aug 7, 2024
57cfadc
Add tests for util/thread into listfile (#165)
tsayukov Aug 7, 2024
e3f91c8
Fix progname_ut test (#164)
tsayukov Aug 7, 2024
461ed2b
Fix src_location_ut and src_root_ut (#164)
tsayukov Aug 7, 2024
bbdc622
Fix thread_ut (#164)
tsayukov Aug 7, 2024
0dd83b6
Temporary comment broken tests
tsayukov Aug 7, 2024
fa026cc
Rename wrapper function to 'add_ydb_multiple_tests' and move to testi…
tsayukov Aug 8, 2024
de02d8b
Improve 'add_ydb_multiple_tests'
tsayukov Aug 8, 2024
8b41926
Simplify 'add_ydb_multiple_tests' command
tsayukov Aug 12, 2024
71f2646
Fix __FILE__ expansion bug (#164)
tsayukov Aug 13, 2024
13a8df7
Simplify 'add_ydb_multiple_tests' command again
tsayukov Aug 13, 2024
a16fe02
Remove unnecessary CCACHE_PATH check
tsayukov Aug 13, 2024
0dba8f4
Fix cached variable's type
tsayukov Aug 14, 2024
1eee66e
Remove 'add_ydb_multiple_tests' command
tsayukov Aug 14, 2024
d8ffc2f
Add info about filtering of legacy tests
tsayukov Aug 14, 2024
9ac7ed9
Fix util/system/direct_io_ut (#164)
tsayukov Aug 7, 2024
af4fca4
Fix fstat_ut (#164)
tsayukov Aug 7, 2024
1d96b56
Fix type_name_ut (#164)
tsayukov Aug 7, 2024
b749b9a
Fix fstat_ut (#164)
tsayukov Aug 7, 2024
eebe4b0
Fix string_transparent_hash_ut (#158)
tsayukov Aug 7, 2024
043286f
Fix common_ops_ut (#161)
tsayukov Aug 8, 2024
24e3e28
Revert "Fix util/system/direct_io_ut (#164)"
tsayukov Aug 22, 2024
298518e
Add WORKING_DIRECTORY parameter to testing commands
tsayukov Aug 22, 2024
b3ea0c8
Revert "Fix fstat_ut (#164)"
tsayukov Aug 22, 2024
4821446
Revert "Fix fstat_ut (#164)"
tsayukov Aug 22, 2024
01697eb
Add OUTPUT_DIRECTORY parameter to testing command
tsayukov Aug 22, 2024
640a783
Revert "Fix type_name_ut (#164)"
tsayukov Aug 22, 2024
a71c29e
Revert "Fix string_transparent_hash_ut (#158)"
tsayukov Aug 22, 2024
fe8b6ef
Revert "Fix common_ops_ut (#161)"
tsayukov Aug 22, 2024
798dc88
Disable type_name_ut test (#164)
tsayukov Aug 22, 2024
4b26d73
Temporary comment string_transparent_hash_ut test (#158)
tsayukov Aug 22, 2024
79af1e2
Add TEST_ARG parameter to testing command
tsayukov Aug 22, 2024
0bed8c3
Exclude broken test (#161)
tsayukov Aug 22, 2024
c73e65f
Add config presets for testing
tsayukov Aug 22, 2024
da93098
Fix ARCADIA_BUILD_ROOT (#164)
tsayukov Aug 25, 2024
6372cf9
Convert ARCADIA_[BUILD_]ROOT to native path (#164)
tsayukov Aug 25, 2024
45bd7a2
Revert "Fix ARCADIA_BUILD_ROOT (#164)"
tsayukov Aug 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
run: |
mkdir -p ../build
rm -rf ../build/*
cmake -DYDB_SDK_TESTS=On -DYDB_SDK_EXAMPLES=On --preset release
cmake --preset release-test-with-ccache-basedir
- name: Build
shell: bash
run: |
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ set(YDB-CPP-SDK_AVAILABLE_COMPONENTS "" CACHE INTERNAL "")
set(YDB-CPP-SDK_COMPONENT_TARGETS "" CACHE INTERNAL "")
file(READ "src/client/resources/ydb_sdk_version.txt" YDB_SDK_VERSION)

#[=============================================================================[
NOTE: if `ccache` is used with the environment variable `CCACHE_BASEDIR`,
these cached variable should be set manually by passing them to `cmake` as
`-DARCADIA_ROOT=source/path/relative/to/build/dir` and
`-DARCADIA_BUILD_ROOT=.`, because in that case the macro `__FILE__` will be
expanded to a relative path, even if the source code file was specified as
an absolute path, and we have to know the proper prefix of that path.
See details: https://ccache.dev/manual/3.1.html#_compiling_in_different_directories
#]=============================================================================]
set(ARCADIA_ROOT ${YDB_SDK_SOURCE_DIR} CACHE INTERNAL "The source root directory")
set(ARCADIA_BUILD_ROOT ${YDB_SDK_BINARY_DIR} CACHE INTERNAL "The build root directory")

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

Expand Down
51 changes: 33 additions & 18 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@
"displayName": "Default Release Config",
"description": "Default release build configuration using Ninja generator and Clang compiler",
"binaryDir": "${sourceDir}/../build"
},
{
"name": "release-test",
"inherits": "release",
"displayName": "Default Release Test Config",
"description": "Default release build configuration with all tests and examples",
"cacheVariables": {
"YDB_SDK_TESTS": "TRUE",
"YDB_SDK_EXAMPLES": "TRUE"
}
},
{
"name": "release-test-with-ccache-basedir",
"inherits": "release-test",
"displayName": "Release Test Config CCACHE_BASEDIR Case",
"description": "Only for the case when using CCACHE_BASEDIR",
"cacheVariables": {
"ARCADIA_ROOT": "../ydb-cpp-sdk",
"ARCADIA_BUILD_ROOT": "."
}
}
],
"buildPresets": [
Expand All @@ -51,51 +71,46 @@
],
"testPresets": [
{
"name": "release",
"configurePreset": "release",
"displayName": "Default Release Tests",
"name": "common",
"hidden": true,
"output": {
"outputOnFailure": true
},
"execution": {
"timeout": 1200
},
}
},
{
"name": "release",
"inherits": "common",
"configurePreset": "release-test",
"displayName": "Default Release Tests",
"environment": {
"YDB_ENDPOINT": "localhost:2136",
"YDB_DATABASE": "/local"
}
},
{
"name": "release-unit",
"configurePreset": "release",
"inherits": "common",
"configurePreset": "release-test",
"displayName": "Default Unit Release Tests",
"filter" : {
"include": {
"label": "unit"
}
},
"output": {
"outputOnFailure": true
},
"execution": {
"timeout": 1200
}
},
{
"name": "release-integration",
"configurePreset": "release",
"inherits": "common",
"configurePreset": "release-test",
"displayName": "Default Integration Release Tests",
"output": {
"outputOnFailure": true
},
"filter" : {
"include": {
"label": "integration"
}
},
"execution": {
"timeout": 1200
},
"environment": {
"YDB_ENDPOINT": "localhost:2136",
"YDB_DATABASE": "/local"
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,14 @@ Running integration tests only:

```bash
ctest -j$(nproc) --preset release-integration
```
```

Note that some tests use a legacy test library instead of GoogleTest, see `./<test_target> --help` for details. If you need to run only certain test cases, here is an alternative for `--gtest_filter` option:

```bash
cat <<EOF | ./<test_target> --filter-file /dev/fd/0
-ExcludedTestCase
+IncludedTestCase
+IncludedTestCase::TestName
EOF
```
4 changes: 1 addition & 3 deletions cmake/ccache.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if (NOT CCACHE_PATH)
find_program(CCACHE_PATH ccache)
endif()
find_program(CCACHE_PATH ccache)
if (NOT CCACHE_PATH)
message(AUTHOR_WARNING
"Ccache is not found, that will increase the re-compilation time; "
Expand Down
83 changes: 54 additions & 29 deletions cmake/testing.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function(add_yunittest)
set(opts "")
set(oneval_args NAME TEST_TARGET)
set(oneval_args NAME TEST_TARGET WORKING_DIRECTORY)
set(multival_args TEST_ARG)
cmake_parse_arguments(YUNITTEST_ARGS
"${opts}"
Expand All @@ -13,13 +13,19 @@ function(add_yunittest)
get_property(SPLIT_TYPE TARGET ${YUNITTEST_ARGS_TEST_TARGET} PROPERTY SPLIT_TYPE)

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/run_testpack")
add_test(NAME ${YUNITTEST_ARGS_NAME} COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/run_testpack" ${YUNITTEST_ARGS_TEST_ARG})
add_test(NAME ${YUNITTEST_ARGS_NAME}
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/run_testpack" ${YUNITTEST_ARGS_TEST_ARG}
WORKING_DIRECTORY ${YUNITTEST_ARGS_WORKING_DIRECTORY}
)
set_property(TEST ${YUNITTEST_ARGS_NAME} PROPERTY ENVIRONMENT "source_root=${YDB_SDK_SOURCE_DIR};build_root=${YDB_SDK_BINARY_DIR};test_split_factor=${SPLIT_FACTOR};test_split_type=${SPLIT_TYPE}")
return()
endif()

if (${SPLIT_FACTOR} EQUAL 1)
add_test(NAME ${YUNITTEST_ARGS_NAME} COMMAND ${YUNITTEST_ARGS_TEST_TARGET} ${YUNITTEST_ARGS_TEST_ARG})
add_test(NAME ${YUNITTEST_ARGS_NAME}
COMMAND ${YUNITTEST_ARGS_TEST_TARGET} ${YUNITTEST_ARGS_TEST_ARG}
WORKING_DIRECTORY ${YUNITTEST_ARGS_WORKING_DIRECTORY}
)
return()
endif()

Expand All @@ -29,8 +35,12 @@ function(add_yunittest)
math(EXPR LastIdx "${SPLIT_FACTOR} - 1")
foreach(Idx RANGE ${LastIdx})
add_test(NAME ${YUNITTEST_ARGS_NAME}_${Idx}
COMMAND Python3::Interpreter ${YDB_SDK_SOURCE_DIR}/scripts/split_unittest.py --split-factor ${SPLIT_FACTOR} ${FORK_MODE_ARG} --shard ${Idx}
$<TARGET_FILE:${YUNITTEST_ARGS_TEST_TARGET}> ${YUNITTEST_ARGS_TEST_ARG})
COMMAND Python3::Interpreter ${YDB_SDK_SOURCE_DIR}/scripts/split_unittest.py
--split-factor ${SPLIT_FACTOR} ${FORK_MODE_ARG}
--shard ${Idx}
$<TARGET_FILE:${YUNITTEST_ARGS_TEST_TARGET}> ${YUNITTEST_ARGS_TEST_ARG}
WORKING_DIRECTORY ${YUNITTEST_ARGS_WORKING_DIRECTORY}
)
endforeach()
endfunction()

Expand Down Expand Up @@ -59,15 +69,23 @@ endfunction()

function(add_ydb_test)
set(opts GTEST)
set(oneval_args NAME)
set(multival_args INCLUDE_DIRS SOURCES LINK_LIBRARIES LABELS)
set(oneval_args NAME WORKING_DIRECTORY OUTPUT_DIRECTORY)
set(multival_args INCLUDE_DIRS SOURCES LINK_LIBRARIES LABELS TEST_ARG)
cmake_parse_arguments(YDB_TEST
"${opts}"
"${oneval_args}"
"${multival_args}"
${ARGN}
)

if (YDB_TEST_WORKING_DIRECTORY AND NOT EXISTS "${YDB_TEST_WORKING_DIRECTORY}")
file(MAKE_DIRECTORY "${YDB_TEST_WORKING_DIRECTORY}")
endif()

if (YDB_TEST_OUTPUT_DIRECTORY AND NOT EXISTS "${YDB_TEST_OUTPUT_DIRECTORY}")
file(MAKE_DIRECTORY "${YDB_TEST_OUTPUT_DIRECTORY}")
endif()

add_executable(${YDB_TEST_NAME})
target_include_directories(${YDB_TEST_NAME} PRIVATE ${YDB_TEST_INCLUDE_DIRS})
target_link_libraries(${YDB_TEST_NAME} PRIVATE ${YDB_TEST_LINK_LIBRARIES})
Expand Down Expand Up @@ -96,56 +114,63 @@ function(add_ydb_test)

set_property(
TARGET
${YDB_TEST_NAME}
${YDB_TEST_NAME}
PROPERTY
SPLIT_FACTOR
1
SPLIT_FACTOR
1
)
if (YDB_TEST_GTEST)
add_yunittest(
NAME
${YDB_TEST_NAME}
${YDB_TEST_NAME}
TEST_TARGET
${YDB_TEST_NAME}
${YDB_TEST_NAME}
TEST_ARG
${YDB_TEST_TEST_ARG}
WORKING_DIRECTORY
${YDB_TEST_WORKING_DIRECTORY}
)
else()
add_yunittest(
NAME
${YDB_TEST_NAME}
${YDB_TEST_NAME}
TEST_TARGET
${YDB_TEST_NAME}
${YDB_TEST_NAME}
TEST_ARG
--print-before-suite
--print-before-test
--fork-tests
--print-times
--show-fails
--print-before-suite
--print-before-test
--fork-tests
--print-times
--show-fails
${YDB_TEST_TEST_ARG}
WORKING_DIRECTORY
${YDB_TEST_WORKING_DIRECTORY}
)
endif()

set_yunittest_property(
TEST
${YDB_TEST_NAME}
${YDB_TEST_NAME}
PROPERTY
LABELS
MEDIUM
${YDB_TEST_LABELS}
LABELS
MEDIUM
${YDB_TEST_LABELS}
)

set_yunittest_property(
TEST
${YDB_TEST_NAME}
${YDB_TEST_NAME}
PROPERTY
PROCESSORS
1
PROCESSORS
1
)

set_yunittest_property(
TEST
${YDB_TEST_NAME}
${YDB_TEST_NAME}
PROPERTY
TIMEOUT
600
TIMEOUT
600
)

vcs_info(${YDB_TEST_NAME})
Expand Down
Loading
Loading