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

fix: unit test failed and update rdsn #384

Merged
merged 5 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cache:
- apt

before_install:
- wget https://media.githubusercontent.com/media/XiaoMi/pegasus-common/master/build-depends.tar.gz
- wget https://github.com/XiaoMi/pegasus-common/releases/download/deps/build-depends.tar.gz
- tar xfz build-depends.tar.gz
- rm -f build-depends.tar.gz
- cd packages
Expand All @@ -35,8 +35,8 @@ install:

before_script:
- cd rdsn/thirdparty
- wget https://media.githubusercontent.com/media/XiaoMi/pegasus-common/master/pegasus-thirdparty-prebuild.tar.gz
- tar xfz pegasus-thirdparty-prebuild.tar.gz
- wget https://github.com/XiaoMi/pegasus-common/releases/download/deps/pegasus-thirdparty-prebuild.tar.gz
- tar xf pegasus-thirdparty-prebuild.tar.gz
- rm -f pegasus-thirdparty-prebuild.tar.gz
- cd ../..
- ulimit -c unlimited -S
Expand Down
2 changes: 1 addition & 1 deletion rdsn
Submodule rdsn updated 43 files
+4 −7 .travis.yml
+3 −0 include/dsn/dist/replication/replication.codes.h
+12 −2 include/dsn/dist/replication/replication_types.h
+2 −2 include/dsn/tool-api/http_server.h
+2 −2 include/dsn/utility/output_utils.h
+2 −2 scripts/linux/start_zk.sh
+7 −6 src/core/core/output_utils.cpp
+13 −0 src/core/tests/output_utils_test.cpp
+8 −8 src/core/tools/common/asio_net_provider.cpp
+1 −1 src/dist/http/CMakeLists.txt
+29 −22 src/dist/http/http_server.cpp
+2 −2 src/dist/http/server_info_http_services.cpp
+1 −1 src/dist/http/server_info_http_services.h
+1 −0 src/dist/http/test/CMakeLists.txt
+38 −0 src/dist/http/test/http_server_test.cpp
+32 −3 src/dist/replication/common/replication_types.cpp
+1 −0 src/dist/replication/lib/CMakeLists.txt
+1 −1 src/dist/replication/lib/duplication/test/CMakeLists.txt
+27 −2 src/dist/replication/lib/replica.h
+8 −1 src/dist/replication/lib/replica_context.cpp
+11 −0 src/dist/replication/lib/replica_context.h
+11 −3 src/dist/replication/lib/replica_init.cpp
+106 −0 src/dist/replication/lib/replica_split.cpp
+136 −12 src/dist/replication/lib/replica_stub.cpp
+38 −0 src/dist/replication/lib/replica_stub.h
+1 −0 src/dist/replication/meta_server/CMakeLists.txt
+122 −0 src/dist/replication/meta_server/duplication/meta_duplication_service.cpp
+10 −0 src/dist/replication/meta_server/duplication/meta_duplication_service.h
+15 −31 src/dist/replication/meta_server/meta_http_service.cpp
+1 −1 src/dist/replication/meta_server/meta_http_service.h
+18 −0 src/dist/replication/meta_server/meta_service.cpp
+1 −1 src/dist/replication/meta_server/meta_service_app.cpp
+1 −0 src/dist/replication/meta_server/server_state.h
+5 −1 src/dist/replication/replication.thrift
+1 −1 src/dist/replication/storage_engine/simple_kv/CMakeLists.txt
+278 −9 src/dist/replication/test/meta_test/unit_test/meta_duplication_service_test.cpp
+2 −1 src/dist/replication/test/meta_test/unit_test/meta_http_service_test.cpp
+1 −2 src/dist/replication/test/replica_test/unit_test/CMakeLists.txt
+24 −1 src/dist/replication/test/replica_test/unit_test/mock_utils.h
+93 −0 src/dist/replication/test/replica_test/unit_test/replica_split_test.cpp
+1 −1 src/dist/replication/test/simple_kv/CMakeLists.txt
+1 −1 src/tests/dsn/CMakeLists.txt
+1 −1 thirdparty/build-thirdparty.sh
7 changes: 6 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,13 @@ function usage_test()
echo " -h|--help print the help info"
echo " -m|--modules set the test modules: pegasus_unit_test pegasus_function_test"
echo " -k|--keep_onebox whether keep the onebox after the test[default false]"
echo " --on_travis run tests on travis without some time-cosuming function tests"
}
function run_test()
{
local test_modules=""
local clear_flags="1"
local on_traivs=""
while [[ $# > 0 ]]; do
key="$1"
case $key in
Expand All @@ -327,6 +329,9 @@ function run_test()
-k|--keep_onebox)
clear_flags=""
;;
--on_travis)
on_travis="--on_travis"
;;
*)
echo "Error: unknow option \"$key\""
echo
Expand All @@ -349,7 +354,7 @@ function run_test()

for module in `echo $test_modules`; do
pushd $ROOT/src/builder/bin/$module
REPORT_DIR=$REPORT_DIR ./run.sh
REPORT_DIR=$REPORT_DIR ./run.sh $on_travis
if [ $? != 0 ]; then
echo "run test \"$module\" in `pwd` failed"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions scripts/start_zk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if [ ! -f zookeeper-3.4.6.tar.gz ]; then
download_url="http://git.n.xiaomi.com/pegasus/packages/raw/master/zookeeper-3.4.6.tar.gz"
wget -T 5 -t 1 $download_url
if [ $? -ne 0 ]; then
download_url="https://github.com/xiaomi/pegasus-common/raw/master/zookeeper-3.4.6.tar.gz"
download_url="https://github.com/XiaoMi/pegasus-common/releases/download/deps/zookeeper-3.4.6.tar.gz"
wget -T 5 -t 1 $download_url
if [ $? -ne 0 ]; then
echo "ERROR: download zookeeper failed"
Expand All @@ -41,7 +41,7 @@ fi

if [ ! -d zookeeper-3.4.6 ]; then
echo "Decompressing zookeeper..."
tar xfz zookeeper-3.4.6.tar.gz
tar xf zookeeper-3.4.6.tar.gz
if [ $? -ne 0 ]; then
echo "ERROR: decompress zookeeper failed"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion scripts/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [ "$modified" ]; then
exit 1
fi

"${root}"/run.sh build -c --skip_thirdparty --disable_gperf && ./run.sh test
"${root}"/run.sh build -c --skip_thirdparty --disable_gperf && ./run.sh test --on_travis

if [ $? ]; then
echo "travis failed with exit code $?"
Expand Down
5 changes: 3 additions & 2 deletions src/server/config.min.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type = meta
name = meta
ports = @META_PORT@
pools = THREAD_POOL_DEFAULT,THREAD_POOL_META_SERVER,THREAD_POOL_META_STATE,THREAD_POOL_FD,THREAD_POOL_DLOCK
pools = THREAD_POOL_DEFAULT,THREAD_POOL_META_SERVER,THREAD_POOL_META_STATE,THREAD_POOL_FD,THREAD_POOL_DLOCK,THREAD_POOL_LOCAL_SERVICE

[apps.replica]
type = replica
Expand Down Expand Up @@ -34,7 +34,7 @@
stderr_start_level = LOG_LEVEL_ERROR

[threadpool..default]
worker_count = 1
worker_count = 4
worker_priority = THREAD_xPRIORITY_NORMAL
partitioned = false

Expand Down Expand Up @@ -87,6 +87,7 @@
server_load_balancer_type = greedy_load_balancer
min_live_node_count_for_unfreeze = 1
cold_backup_disabled = false
recover_from_replica_server = false

[replication]
allow_non_idempotent_write = true
Expand Down
4 changes: 4 additions & 0 deletions src/server/test/pegasus_write_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class pegasus_write_service_test : public pegasus_server_test_base

void test_multi_remove()
{
dsn::fail::setup();

dsn::apps::multi_remove_request request;
dsn::apps::multi_remove_response response;

Expand Down Expand Up @@ -123,6 +125,8 @@ class pegasus_write_service_test : public pegasus_server_test_base
ASSERT_EQ(err, 0);
verify_response(response, 0, decree);
}

dsn::fail::teardown();
}

void test_batched_writes()
Expand Down
2 changes: 1 addition & 1 deletion src/shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ set(MY_PROJ_LIBS

set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini")

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

SET(CMAKE_INSTALL_RPATH ".")
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
Expand Down
2 changes: 1 addition & 1 deletion src/test/function_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ else()
set(MY_PROJ_LIBS ${MY_PROJ_LIBS} gtest)
endif()

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

set(MY_BINPLACES "config.ini" "run.sh")

Expand Down
29 changes: 24 additions & 5 deletions src/test/function_test/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

exit_if_fail() {
if [ $1 != 0 ]; then
Expand All @@ -11,6 +11,23 @@ if [ -z $REPORT_DIR ]; then
REPORT_DIR="./"
fi

# If run function tests on traivs, we exclude some time-consuming tests
# incluing restore test, recovery test
on_travis="NO"
while [ $# -gt 0 ]; do
key="$1"
case $key in
--on_travis)
on_travis="YES"
;;
*)
echo "Error: unknow option \"$key\""
exit 1
;;
esac
shift
done

test_case=pegasus_function_test
config_file=config.ini
table_name=temp
Expand All @@ -31,7 +48,9 @@ GTEST_OUTPUT="xml:$REPORT_DIR/slog_log.xml" GTEST_FILTER="lost_log.*" ./$test_ca
exit_if_fail $? "run test slog_lost failed: $test_case $config_file $table_name"
GTEST_OUTPUT="xml:$REPORT_DIR/recall.xml" GTEST_FILTER="drop_and_recall.*" ./$test_case $config_file $table_name
exit_if_fail $? "run test recall failed: $test_case $config_file $table_name"
GTEST_OUTPUT="xml:$REPORT_DIR/restore.xml" GTEST_FILTER="restore_test.*" ./$test_case $config_file $table_name
exit_if_fail $? "run test restore_test failed: $test_case $config_file $table_name"
GTEST_OUTPUT="xml:$REPORT_DIR/recovery.xml" GTEST_FILTER="recovery_test.*" ./$test_case $config_file $table_name
exit_if_fail $? "run test recovery failed: $test_case $config_file $table_name"
if [ $on_travis == "NO" ]; then
GTEST_OUTPUT="xml:$REPORT_DIR/restore.xml" GTEST_FILTER="restore_test.*" ./$test_case $config_file $table_name
exit_if_fail $? "run test restore_test failed: $test_case $config_file $table_name"
GTEST_OUTPUT="xml:$REPORT_DIR/recovery.xml" GTEST_FILTER="recovery_test.*" ./$test_case $config_file $table_name
exit_if_fail $? "run test recovery failed: $test_case $config_file $table_name"
fi
27 changes: 17 additions & 10 deletions src/test/function_test/test_recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,24 @@ class recovery_test : public testing::Test
protected:
virtual void SetUp()
{
// THREAD_POOL_META_SERVER worker count should be greater than 1
// This function test update 'distributed_lock_service_type' to
// 'distributed_lock_service_simple', which executes in threadpool THREAD_POOL_META_SERVER
// As a result, failure detection lock executes in this pool
// if worker count = 1, it will lead to ERR_TIMEOUT when execute 'ddl_client->do_recovery'

// 1. restart onebox, modify the config
chdir(global_env::instance()._pegasus_root.c_str());
system("./run.sh clear_onebox");

system("cp src/server/config-server.ini config-server-test-recovery.ini");
system("sed -i \"/^meta_state_service_type/c meta_state_service_type = "
system("cp src/server/config.min.ini config-server-test-recovery.ini");
system("sed -i \"/^\\s*meta_state_service_type/c meta_state_service_type = "
"meta_state_service_simple\" config-server-test-recovery.ini");
system("sed -i \"/^distributed_lock_service_type/c distributed_lock_service_type = "
system("sed -i \"/^\\s*distributed_lock_service_type/c distributed_lock_service_type = "
"distributed_lock_service_simple\" config-server-test-recovery.ini");
system("sed -i \"/^server_list/c server_list = @LOCAL_IP@:34601\" "
system("sed -i \"/^\\s*server_list/c server_list = @LOCAL_IP@:34601\" "
"config-server-test-recovery.ini");
system("sed -i \"/^perf_counter_enable_logging/c perf_counter_enable_logging = false\" "
system("sed -i \"/^\\s*perf_counter_enable_logging/c perf_counter_enable_logging = false\" "
"config-server-test-recovery.ini");

system("./run.sh start_onebox -m 1 -r 3 --config_path config-server-test-recovery.ini");
Expand Down Expand Up @@ -158,11 +164,12 @@ class recovery_test : public testing::Test
void config_meta_to_do_cold_recovery()
{
char command[512];
snprintf(command,
512,
"cd %s && sed -i \"/^recover_from_replica_server/c recover_from_replica_server = "
"true\" onebox/meta1/config.ini",
global_env::instance()._pegasus_root.c_str());
snprintf(
command,
512,
"cd %s && sed -i \"/^\\s*recover_from_replica_server/c recover_from_replica_server = "
"true\" onebox/meta1/config.ini",
global_env::instance()._pegasus_root.c_str());
system(command);
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/function_test/test_restore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class restore_test : public testing::Test

// modify the config to enable backup, and restart onebox
system("./run.sh clear_onebox");
system("cp src/server/config-server.ini config-server-test-restore.ini");
system("sed -i \"/^cold_backup_disabled/c cold_backup_disabled = false\" "
system("cp src/server/config.min.ini config-server-test-restore.ini");
system("sed -i \"/^\\s*cold_backup_disabled/c cold_backup_disabled = false\" "
"config-server-test-restore.ini");
std::string cmd = "sed -i \"/^cold_backup_root/c cold_backup_root = " + cluster_name;
std::string cmd = "sed -i \"/^\\s*cold_backup_root/c cold_backup_root = " + cluster_name;
cmd = cmd + std::string("\" config-server-test-restore.ini");
system(cmd.c_str());
system("./run.sh start_onebox --config_path config-server-test-restore.ini");
Expand Down