Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Incubator Pegasus
提交
072e5c9b
Incubator Pegasus
项目概览
apache
/
Incubator Pegasus
通知
9
Star
5
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Incubator Pegasus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
072e5c9b
编写于
5月 29, 2020
作者:
Z
zhao liwei
提交者:
GitHub
5月 29, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix bug in function_test/test_restore (#542)
上级
bdd21a05
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
20 deletion
+33
-20
rdsn
rdsn
+1
-1
src/test/function_test/test_restore.cpp
src/test/function_test/test_restore.cpp
+32
-19
未找到文件。
rdsn
@
88dd590d
比较
30362560
...
88dd590d
Subproject commit
30362560829fcc819bd37d9b0f437edb6c8fdf76
Subproject commit
88dd590d94f6417b9f42cd322f70ab5f2add837d
src/test/function_test/test_restore.cpp
浏览文件 @
072e5c9b
...
...
@@ -19,10 +19,8 @@ public:
virtual
void
SetUp
()
override
{
pegasus_root_dir
=
global_env
::
instance
().
_pegasus_root
;
working_root_dir
=
global_env
::
instance
().
_working_dir
;
chdir
(
pegasus_root_dir
.
c_str
());
cluster_name
=
dsn
::
utils
::
filesystem
::
path_combine
(
pegasus_root_dir
,
backup_data_dir
);
system
(
"pwd"
);
// modify the config to enable backup, and restart onebox
...
...
@@ -39,9 +37,22 @@ public:
system
(
"./run.sh start_onebox --config_path config-server-test-restore.ini"
);
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
3
));
// First of all, we are in the path of pegasus root, for example: /home/mi/pegasus.
// And we can get the provider_dir which actually is `block_service/local_service`,
// from config-server-test-restore.ini.
// With cluster_name = mycluster and policy_name = policy_1, we can get the absolute
// path of policy: /home/mi/pegasus/onebox/block_service/local_service/mycluster/policy_1
cmd
=
"grep -A 5 block_service."
+
backup_provider_name
+
" config-server-test-restore.ini | grep args | cut -f2,3 -d'/'"
;
std
::
stringstream
ss
;
assert
(
dsn
::
utils
::
pipe_execute
(
cmd
.
c_str
(),
ss
)
==
0
);
std
::
string
provider_dir
=
ss
.
str
().
substr
(
0
,
ss
.
str
().
length
()
-
1
);
policy_dir
=
"onebox/"
+
provider_dir
+
'/'
+
dsn
::
utils
::
filesystem
::
path_combine
(
cluster_name
,
policy_name
);
std
::
vector
<
dsn
::
rpc_address
>
meta_list
;
replica_helper
::
load_meta_servers
(
meta_list
,
PEGASUS_CLUSTER_SECTION_NAME
.
c_str
(),
"mycluster"
);
meta_list
,
PEGASUS_CLUSTER_SECTION_NAME
.
c_str
(),
cluster_name
.
c_str
()
);
ddl_client
=
std
::
make_shared
<
replication_ddl_client
>
(
meta_list
);
error_code
err
=
...
...
@@ -56,7 +67,8 @@ public:
old_app_id
=
app_id
;
}
ASSERT_GE
(
app_id
,
0
);
pg_client
=
pegasus
::
pegasus_client_factory
::
get_client
(
"mycluster"
,
app_name
.
c_str
());
pg_client
=
pegasus
::
pegasus_client_factory
::
get_client
(
cluster_name
.
c_str
(),
app_name
.
c_str
());
ASSERT_NE
(
pg_client
,
nullptr
);
write_data
();
...
...
@@ -78,8 +90,6 @@ public:
chdir
(
global_env
::
instance
().
_pegasus_root
.
c_str
());
system
(
"./run.sh clear_onebox"
);
system
(
"./run.sh start_onebox -w"
);
std
::
string
cmd
=
"rm -rf "
+
backup_data_dir
;
system
(
cmd
.
c_str
());
chdir
(
global_env
::
instance
().
_working_dir
.
c_str
());
}
...
...
@@ -108,6 +118,13 @@ public:
int
err
=
PERR_OK
;
std
::
cout
<<
"start to get "
<<
kv_pair_cnt
<<
" key-value pairs, using get()..."
<<
std
::
endl
;
new_pg_client
=
pegasus
::
pegasus_client_factory
::
get_client
(
cluster_name
.
c_str
(),
new_app_name
.
c_str
());
if
(
nullptr
==
new_pg_client
)
{
std
::
cout
<<
"error to create client for "
<<
new_app_name
<<
std
::
endl
;
return
false
;
}
int64_t
start
=
dsn_now_ms
();
for
(
int
i
=
1
;
i
<=
kv_pair_cnt
;
i
++
)
{
std
::
string
index
=
std
::
to_string
(
i
);
...
...
@@ -115,10 +132,10 @@ public:
std
::
string
s_key
=
sort_key_prefix
+
"_"
+
index
;
std
::
string
value
=
value_prefix
+
"_"
+
index
;
std
::
string
value_new
;
err
=
pg_client
->
get
(
h_key
,
s_key
,
value_new
);
err
=
new_
pg_client
->
get
(
h_key
,
s_key
,
value_new
);
if
(
err
!=
PERR_OK
)
{
std
::
cout
<<
"get <"
<<
h_key
<<
">, <"
<<
s_key
<<
"> failed, with err = "
<<
pg_client
->
get_error_string
(
err
)
<<
"> failed, with err = "
<<
new_
pg_client
->
get_error_string
(
err
)
<<
std
::
endl
;
return
false
;
}
...
...
@@ -136,8 +153,6 @@ public:
bool
restore
()
{
system
(
"./run.sh clear_onebox"
);
system
(
"./run.sh start_onebox"
);
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
3
));
time_stamp
=
get_first_backup_timestamp
();
std
::
cout
<<
"first backup_timestamp = "
<<
time_stamp
<<
std
::
endl
;
...
...
@@ -147,7 +162,7 @@ public:
time_stamp
,
app_name
,
old_app_id
,
app_name
,
new_
app_name
,
false
);
if
(
err
!=
ERR_OK
)
{
std
::
cout
<<
"restore failed, err = "
<<
err
.
to_string
()
<<
std
::
endl
;
...
...
@@ -178,9 +193,9 @@ public:
p_confs
.
clear
();
app_id
=
0
,
partition_cnt
=
0
;
err
=
ddl_client
->
list_app
(
app_name
,
app_id
,
partition_cnt
,
p_confs
);
err
=
ddl_client
->
list_app
(
new_
app_name
,
app_id
,
partition_cnt
,
p_confs
);
if
(
err
!=
ERR_OK
)
{
std
::
cout
<<
"list app failed, app_name = "
<<
app_name
std
::
cout
<<
"list app failed, app_name = "
<<
new_
app_name
<<
", with err = "
<<
err
.
to_string
()
<<
std
::
endl
;
continue
;
}
...
...
@@ -232,7 +247,6 @@ public:
int64_t
get_first_backup_timestamp
()
{
std
::
string
policy_dir
=
dsn
::
utils
::
filesystem
::
path_combine
(
cluster_name
,
policy_name
);
std
::
string
cmd
=
"cd "
+
policy_dir
+
"; "
"ls -c > restore_app_from_backup_test_tmp; "
"tail -n 1 restore_app_from_backup_test_tmp; "
...
...
@@ -256,7 +270,6 @@ public:
bool
find_second_backup_timestamp
()
{
std
::
string
policy_dir
=
dsn
::
utils
::
filesystem
::
path_combine
(
cluster_name
,
policy_name
);
std
::
vector
<
std
::
string
>
dirs
;
::
dsn
::
utils
::
filesystem
::
get_subdirectories
(
policy_dir
,
dirs
,
false
);
return
(
dirs
.
size
()
>=
2
);
...
...
@@ -264,11 +277,13 @@ public:
public:
pegasus_client
*
pg_client
;
pegasus_client
*
new_pg_client
;
std
::
shared_ptr
<
replication_ddl_client
>
ddl_client
;
std
::
string
pegasus_root_dir
;
std
::
string
working_root
_dir
;
std
::
string
policy
_dir
;
std
::
string
cluster_name
;
const
std
::
string
cluster_name
=
"mycluster"
;
const
std
::
string
new_app_name
=
"backup_test_new"
;
int32_t
old_app_id
;
int64_t
time_stamp
;
...
...
@@ -277,7 +292,6 @@ public:
static
const
int
backup_interval_seconds
;
static
const
int
backup_history_count_to_keep
;
static
const
std
::
string
start_time
;
static
const
std
::
string
backup_data_dir
;
static
const
std
::
string
app_name
;
...
...
@@ -298,7 +312,6 @@ const std::string restore_test::backup_provider_name = "local_service";
const
int
restore_test
::
backup_interval_seconds
=
1
;
const
int
restore_test
::
backup_history_count_to_keep
=
6
;
const
std
::
string
restore_test
::
start_time
=
"24:0"
;
const
std
::
string
restore_test
::
backup_data_dir
=
"backup_data"
;
const
std
::
string
restore_test
::
app_name
=
"backup_test"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录