This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move zookeeper module from src/dist/replication to src/zook…
…eeper (#549)
- Loading branch information
Showing
31 changed files
with
258 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
config-test.ini distributed_lock_service_zookeeper.simple_lock_unlock | ||
config-test.ini -distributed_lock_service_zookeeper.simple_lock_unlock | ||
config-test.ini * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ set(MY_PROJ_LIBS "") | |
set(MY_BINPLACES "") | ||
|
||
dsn_add_static_library() | ||
|
||
add_subdirectory(tests) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
set(MY_PROJ_NAME dsn.zookeeper.tests) | ||
|
||
# Source files under CURRENT project directory will be automatically included. | ||
# You can manually set MY_PROJ_SRC to include source files under other directories. | ||
set(MY_PROJ_SRC "") | ||
|
||
# Search mode for source files under CURRENT project directory? | ||
# "GLOB_RECURSE" for recursive search | ||
# "GLOB" for non-recursive search | ||
set(MY_SRC_SEARCH_MODE "GLOB") | ||
|
||
set(MY_PROJ_LIBS | ||
dsn.replication.zookeeper_provider | ||
dsn_runtime | ||
zookeeper_mt | ||
gtest | ||
) | ||
|
||
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) | ||
|
||
# Extra files that will be installed | ||
set(MY_BINPLACES | ||
"${CMAKE_CURRENT_SOURCE_DIR}/run.sh" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/clear.sh" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/config-test.ini" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/gtest.filter" | ||
) | ||
|
||
dsn_add_test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
rm -rf client core* log.* *.log data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
[apps..default] | ||
run = true | ||
count = 1 | ||
;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 | ||
;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536 | ||
;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 | ||
|
||
[apps.client] | ||
type = test | ||
arguments = localhost 20101 | ||
run = true | ||
ports = | ||
count = 1 | ||
delay_seconds = 1 | ||
pools = THREAD_POOL_DEFAULT, THREAD_POOL_DLOCK, THREAD_POOL_REPLICATION, THREAD_POOL_REPLICATION_LONG | ||
|
||
[apps.server] | ||
type = test | ||
arguments = | ||
ports = 20101 | ||
run = false | ||
count = 0 | ||
pools = THREAD_POOL_DEFAULT, THREAD_POOL_REPLICATION | ||
|
||
[apps.add_server] | ||
type = adder | ||
arguments = | ||
ports = 20201 | ||
run = true | ||
count = 3 | ||
pools = THREAD_POOL_DEFAULT, THREAD_POOL_DLOCK | ||
|
||
[core] | ||
;tool = simulator | ||
tool = nativerun | ||
|
||
;toollets = tracer, profiler | ||
;fault_injector | ||
pause_on_start = false | ||
|
||
logging_start_level = LOG_LEVEL_INFORMATION | ||
logging_factory_name = dsn::tools::simple_logger | ||
|
||
|
||
[tools.simple_logger] | ||
fast_flush = true | ||
short_header = false | ||
stderr_start_level = LOG_LEVEL_WARNING | ||
|
||
[tools.simulator] | ||
random_seed = 0 | ||
|
||
[tools.screen_logger] | ||
short_header = false | ||
|
||
[network] | ||
; how many network threads for network library (used by asio) | ||
io_service_worker_count = 2 | ||
|
||
[task..default] | ||
is_trace = true | ||
is_profile = true | ||
allow_inline = false | ||
rpc_call_channel = RPC_CHANNEL_TCP | ||
rpc_message_header_format = dsn | ||
rpc_timeout_milliseconds = 5000 | ||
|
||
[task.LPC_AIO_IMMEDIATE_CALLBACK] | ||
is_trace = false | ||
is_profile = false | ||
allow_inline = false | ||
|
||
[task.LPC_RPC_TIMEOUT] | ||
is_trace = false | ||
is_profile = false | ||
|
||
; specification for each thread pool | ||
[threadpool..default] | ||
worker_count = 2 | ||
|
||
[threadpool.THREAD_POOL_DEFAULT] | ||
partitioned = false | ||
worker_priority = THREAD_xPRIORITY_NORMAL | ||
|
||
[threadpool.THREAD_POOL_TEST_SERVER] | ||
partitioned = false | ||
|
||
[threadpool.THREAD_POOL_FDS_SERVICE] | ||
worker_count = 8 | ||
|
||
[threadpool.THREAD_POOL_DLOCK] | ||
partitioned = true | ||
|
||
[zookeeper] | ||
hosts_list = localhost:12181 | ||
timeout_ms = 30000 | ||
logfile = zoolog.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
config-test.ini distributed_lock_service_zookeeper.simple_lock_unlock | ||
config-test.ini -distributed_lock_service_zookeeper.simple_lock_unlock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2015 Microsoft Corporation | ||
* | ||
* -=- Robust Distributed System Nucleus (rDSN) -=- | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
#include <iostream> | ||
|
||
#ifndef _WIN32 | ||
#include <sys/types.h> | ||
#include <signal.h> | ||
#endif | ||
|
||
#include <gtest/gtest.h> | ||
#include <dsn/service_api_cpp.h> | ||
|
||
int g_test_count = 0; | ||
int g_test_ret = 0; | ||
|
||
extern void lock_test_init(); | ||
|
||
class test_client : public ::dsn::service_app | ||
{ | ||
public: | ||
test_client(const dsn::service_app_info *info) : ::dsn::service_app(info) {} | ||
|
||
::dsn::error_code start(const std::vector<std::string> &args) | ||
{ | ||
int argc = args.size(); | ||
char *argv[20]; | ||
for (int i = 0; i < argc; ++i) { | ||
argv[i] = (char *)(args[i].c_str()); | ||
} | ||
testing::InitGoogleTest(&argc, argv); | ||
g_test_ret = RUN_ALL_TESTS(); | ||
g_test_count = 1; | ||
return ::dsn::ERR_OK; | ||
} | ||
|
||
::dsn::error_code stop(bool cleanup = false) { return ::dsn::ERR_OK; } | ||
}; | ||
|
||
GTEST_API_ int main(int argc, char **argv) | ||
{ | ||
testing::InitGoogleTest(&argc, argv); | ||
|
||
// register all possible services | ||
dsn::service_app::register_factory<test_client>("test"); | ||
lock_test_init(); | ||
|
||
// specify what services and tools will run in config file, then run | ||
if (argc < 2) | ||
dsn_run_config("config-test.ini", false); | ||
else | ||
dsn_run_config(argv[1], false); | ||
|
||
while (g_test_count == 0) { | ||
std::this_thread::sleep_for(std::chrono::seconds(1)); | ||
} | ||
|
||
#ifndef ENABLE_GCOV | ||
dsn_exit(g_test_ret); | ||
#endif | ||
return g_test_ret; | ||
} |
Oops, something went wrong.