Skip to content

Commit

Permalink
refactor(tests): Simplify the runtime module unit tests (#2115)
Browse files Browse the repository at this point in the history
Now the test `core.corrupt_message` is disabled by `--gtest_filter`, it's a
bit of complex because it uses an external file
(i.e. `src/runtime/test/gtest.filter`), and it just disable
`core.corrupt_message` test case. This can be simplified by adding a
`DISABLED_` prefix, and make sure all other test cases can be ran normally.
  • Loading branch information
acelyc111 authored Sep 13, 2024
1 parent adb886d commit c90aa48
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ header:
- 'src/meta/test/suite2'
- 'src/nfs/test/nfs_test_file1'
- 'src/nfs/test/nfs_test_file2'
- 'src/runtime/test/gtest.filter'
# Used for tests and should be empty, or ignore all comment lines (otherwise would lead to error).
- 'src/utils/test/config-empty.ini'
# Binary files used for tests and could not be added with copyright info (otherwise would lead to error).
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ set(MY_BINPLACES
config-test-sim.ini
command.txt
run.sh
clear.sh
gtest.filter)
clear.sh)
dsn_add_test()
4 changes: 3 additions & 1 deletion src/runtime/test/corrupt_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
#include "runtime/test_utils.h"
#include "utils/error_code.h"

// TODO(yingchun): the tests are failed because the fault injector is not work well as expected.
// Now just disable the tests before we fix it.
// this only works with the fault injector
TEST(core, corrupt_message)
TEST(core, DISABLED_corrupt_message)
{
int req = 0;
const auto server = dsn::rpc_address::from_host_port("localhost", 20101);
Expand Down
3 changes: 0 additions & 3 deletions src/runtime/test/gtest.filter

This file was deleted.

13 changes: 6 additions & 7 deletions src/runtime/test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ if [ -z "${REPORT_DIR}" ]; then
REPORT_DIR="."
fi

while read -r -a line; do
test_case=${line[0]}
gtest_filter=${line[1]}
test_cases=(config-test.ini config-test-sim.ini)
for test_case in ${test_cases[*]}; do
output_xml="${REPORT_DIR}/dsn_runtime_tests_${test_case/.ini/.xml}"
echo "============ run dsn_runtime_tests ${test_case} with gtest_filter ${gtest_filter} ============"
echo "============ run dsn_runtime_tests ${test_case} ============"
./clear.sh
GTEST_OUTPUT="xml:${output_xml}" GTEST_FILTER=${gtest_filter} ./dsn_runtime_tests ${test_case} < command.txt
GTEST_OUTPUT="xml:${output_xml}" ./dsn_runtime_tests ${test_case} < command.txt

if [ $? -ne 0 ]; then
echo "run dsn_runtime_tests $test_case failed"
Expand All @@ -50,8 +49,8 @@ while read -r -a line; do
fi
exit 1
fi
echo "============ done dsn_runtime_tests ${test_case} with gtest_filter ${gtest_filter} ============"
done <gtest.filter
echo "============ done dsn_runtime_tests ${test_case} ============"
done

echo "============ done dsn_runtime_tests ============"

0 comments on commit c90aa48

Please sign in to comment.