Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
1cf60c46
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1cf60c46
编写于
5月 14, 2019
作者:
K
Kalen Krempely
提交者:
David Krieger
5月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gpconfig: Fix unit tests due to refactor
上级
b6137171
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
105 addition
and
87 deletion
+105
-87
gpMgmt/bin/gppylib/test/unit/test_unit_gpconfig.py
gpMgmt/bin/gppylib/test/unit/test_unit_gpconfig.py
+105
-87
未找到文件。
gpMgmt/bin/gppylib/test/unit/test_unit_gpconfig.py
浏览文件 @
1cf60c46
import
base64
import
base64
import
errno
import
imp
import
imp
import
os
import
os
import
pickle
import
pickle
import
shutil
import
sys
import
sys
import
tempfile
import
tempfile
from
StringIO
import
StringIO
from
gppylib.gparray
import
Segment
,
GpArray
,
SegmentPair
from
gppylib.gphostcache
import
GpHost
import
errno
from
gpconfig_modules.parse_guc_metadata
import
ParseGuc
from
pygresql.pg
import
DatabaseError
from
gparray
import
Segment
,
GpArray
,
SegmentPair
import
shutil
from
mock
import
*
from
gp_unittest
import
*
from
gp_unittest
import
*
from
gphostcache
import
GpHost
from
mock
import
*
from
gpconfig_modules.parse_guc_metadata
import
ParseGuc
from
pygresql.pg
import
DatabaseError
from
StringIO
import
StringIO
db_singleton_side_effect_list
=
[]
db_singleton_side_effect_list
=
[]
...
@@ -66,15 +65,18 @@ class GpConfig(GpTestCase):
...
@@ -66,15 +65,18 @@ class GpConfig(GpTestCase):
self
.
host_cache
.
get_hosts
.
return_value
=
[
self
.
host
]
self
.
host_cache
.
get_hosts
.
return_value
=
[
self
.
host
]
self
.
host_cache
.
ping_hosts
.
return_value
=
[]
self
.
host_cache
.
ping_hosts
.
return_value
=
[]
self
.
master_read_config
=
Mock
()
self
.
master_file
=
Mock
(
name
=
'master'
)
self
.
master_read_config
.
get_guc_value
.
return_value
=
"foo"
self
.
master_file
.
get_value
.
return_value
=
'foo'
self
.
master_read_config
.
get_seg_content_id
.
return_value
=
-
1
self
.
master_file
.
segInfo
.
getSegmentContentId
.
return_value
=
-
1
self
.
segment_read_config
=
Mock
()
self
.
master_file
.
segInfo
.
getSegmentDbId
.
return_value
=
0
self
.
segment_read_config
.
get_guc_value
.
return_value
=
"foo"
self
.
segment_read_config
.
get_seg_content_id
.
return_value
=
0
self
.
seg0_file
=
Mock
(
name
=
'seg0'
)
self
.
seg0_file
.
get_value
.
return_value
=
'foo'
self
.
seg0_file
.
segInfo
.
getSegmentContentId
.
return_value
=
0
self
.
seg0_file
.
segInfo
.
getSegmentDbId
.
return_value
=
1
self
.
pool
=
Mock
()
self
.
pool
=
Mock
()
self
.
pool
.
getCompletedItems
.
return_value
=
[
self
.
master_
read_config
,
self
.
segment_read_config
]
self
.
pool
.
getCompletedItems
.
return_value
=
[
self
.
master_
file
,
self
.
seg0_file
]
self
.
apply_patches
([
self
.
apply_patches
([
patch
(
'os.environ'
,
new
=
self
.
os_env
),
patch
(
'os.environ'
,
new
=
self
.
os_env
),
...
@@ -127,6 +129,8 @@ class GpConfig(GpTestCase):
...
@@ -127,6 +129,8 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_show_with_port_will_succeed
(
self
,
mock_stdout
):
def
test_option_show_with_port_will_succeed
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"port"
]
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"port"
]
# mocked database values
# select * from gp_toolkit.gp_param_setting('port'); ;
# select * from gp_toolkit.gp_param_setting('port'); ;
# paramsegment | paramname | paramvalue
# paramsegment | paramname | paramvalue
# --------------+-----------+------------
# --------------+-----------+------------
...
@@ -175,7 +179,7 @@ class GpConfig(GpTestCase):
...
@@ -175,7 +179,7 @@ class GpConfig(GpTestCase):
self
.
subject
.
do_main
()
self
.
subject
.
do_main
()
self
.
pool
.
addCommand
.
assert_called_once
_with
(
self
.
master_read_config
)
self
.
pool
.
addCommand
.
assert_called_once
(
)
self
.
pool
.
join
.
assert_called_once_with
()
self
.
pool
.
join
.
assert_called_once_with
()
self
.
pool
.
check_results
.
assert_called_once_with
()
self
.
pool
.
check_results
.
assert_called_once_with
()
self
.
pool
.
haltWork
.
assert_called_once_with
()
self
.
pool
.
haltWork
.
assert_called_once_with
()
...
@@ -186,8 +190,8 @@ class GpConfig(GpTestCase):
...
@@ -186,8 +190,8 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_f_will_report_absence_of_setting_on_master
(
self
,
mock_stdout
):
def
test_option_f_will_report_absence_of_setting_on_master
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"my_property_name"
,
"--file"
]
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"my_property_name"
,
"--file"
]
self
.
master_
read_config
.
get_guc
_value
.
return_value
=
None
self
.
master_
file
.
get
_value
.
return_value
=
None
self
.
seg
ment_read_config
.
get_guc
_value
.
return_value
=
"seg_value"
self
.
seg
0_file
.
get
_value
.
return_value
=
"seg_value"
self
.
subject
.
do_main
()
self
.
subject
.
do_main
()
...
@@ -197,8 +201,8 @@ class GpConfig(GpTestCase):
...
@@ -197,8 +201,8 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_f_will_report_absence_of_setting_on_segment
(
self
,
mock_stdout
):
def
test_option_f_will_report_absence_of_setting_on_segment
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"my_property_name"
,
"--file"
]
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"my_property_name"
,
"--file"
]
self
.
master_
read_config
.
get_guc
_value
.
return_value
=
"master_value"
self
.
master_
file
.
get
_value
.
return_value
=
"master_value"
self
.
seg
ment_read_config
.
get_guc
_value
.
return_value
=
None
self
.
seg
0_file
.
get
_value
.
return_value
=
None
self
.
subject
.
do_main
()
self
.
subject
.
do_main
()
...
@@ -208,8 +212,8 @@ class GpConfig(GpTestCase):
...
@@ -208,8 +212,8 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_f_will_report_absence_of_setting_on_both
(
self
,
mock_stdout
):
def
test_option_f_will_report_absence_of_setting_on_both
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"my_property_name"
,
"--file"
]
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"my_property_name"
,
"--file"
]
self
.
master_
read_config
.
get_guc
_value
.
return_value
=
None
self
.
master_
file
.
get
_value
.
return_value
=
None
self
.
seg
ment_read_config
.
get_guc
_value
.
return_value
=
None
self
.
seg
0_file
.
get
_value
.
return_value
=
None
self
.
subject
.
do_main
()
self
.
subject
.
do_main
()
...
@@ -219,12 +223,18 @@ class GpConfig(GpTestCase):
...
@@ -219,12 +223,18 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_f_will_report_difference_segments_out_of_sync
(
self
,
mock_stdout
):
def
test_option_f_will_report_difference_segments_out_of_sync
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"my_property_name"
,
"--file"
]
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"my_property_name"
,
"--file"
]
self
.
master_read_config
.
get_guc_value
.
return_value
=
'foo'
self
.
segment_read_config
.
get_guc_value
.
return_value
=
'bar'
self
.
master_file
.
get_value
.
return_value
=
'foo'
another_segment_read_config
=
Mock
()
self
.
seg0_file
.
get_value
.
return_value
=
'bar'
another_segment_read_config
.
get_guc_value
.
return_value
=
"baz"
another_segment_read_config
.
get_seg_content_id
.
return_value
=
1
seg_1
=
Mock
(
name
=
'seg1'
)
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
another_segment_read_config
)
seg_1
.
segInfo
.
getSegmentContentId
.
return_value
=
1
seg_1
.
segInfo
.
getSegmentDbId
.
return_value
=
2
seg_1
.
get_value
.
return_value
=
'baz'
# mocked values in the files
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
seg_1
)
self
.
host_cache
.
get_hosts
.
return_value
.
extend
([
self
.
host
,
self
.
host
])
self
.
host_cache
.
get_hosts
.
return_value
.
extend
([
self
.
host
,
self
.
host
])
self
.
subject
.
do_main
()
self
.
subject
.
do_main
()
...
@@ -238,12 +248,18 @@ class GpConfig(GpTestCase):
...
@@ -238,12 +248,18 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_f_will_report_difference_segments_out_of_sync_when_unset
(
self
,
mock_stdout
):
def
test_option_f_will_report_difference_segments_out_of_sync_when_unset
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"my_property_name"
,
"--file"
]
sys
.
argv
=
[
"gpconfig"
,
"--show"
,
"my_property_name"
,
"--file"
]
self
.
master_read_config
.
get_guc_value
.
return_value
=
'foo'
self
.
segment_read_config
.
get_guc_value
.
return_value
=
'bar'
self
.
master_file
.
get_value
.
return_value
=
'foo'
another_segment_read_config
=
Mock
()
self
.
seg0_file
.
get_value
.
return_value
=
'bar'
another_segment_read_config
.
get_guc_value
.
return_value
=
None
another_segment_read_config
.
get_seg_content_id
.
return_value
=
1
seg_1
=
Mock
(
name
=
'seg1'
)
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
another_segment_read_config
)
seg_1
.
segInfo
.
getSegmentContentId
.
return_value
=
1
seg_1
.
segInfo
.
getSegmentDbId
.
return_value
=
2
seg_1
.
get_value
.
return_value
=
None
# mocked values in the files
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
seg_1
)
self
.
host_cache
.
get_hosts
.
return_value
.
extend
([
self
.
host
,
self
.
host
])
self
.
host_cache
.
get_hosts
.
return_value
.
extend
([
self
.
host
,
self
.
host
])
self
.
subject
.
do_main
()
self
.
subject
.
do_main
()
...
@@ -258,6 +274,8 @@ class GpConfig(GpTestCase):
...
@@ -258,6 +274,8 @@ class GpConfig(GpTestCase):
db_singleton_side_effect_list
.
append
(
"some happy result"
)
db_singleton_side_effect_list
.
append
(
"some happy result"
)
entry
=
'my_property_name'
entry
=
'my_property_name'
sys
.
argv
=
[
"gpconfig"
,
"-c"
,
entry
,
"-v"
,
"100"
,
"-m"
,
"20"
]
sys
.
argv
=
[
"gpconfig"
,
"-c"
,
entry
,
"-v"
,
"100"
,
"-m"
,
"20"
]
# mocked database values
# 'SELECT name, setting, unit, short_desc, context, vartype, min_val, max_val FROM pg_settings'
# 'SELECT name, setting, unit, short_desc, context, vartype, min_val, max_val FROM pg_settings'
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
'context'
,
'vartype'
,
'min_val'
,
'max_val'
]])
'context'
,
'vartype'
,
'min_val'
,
'max_val'
]])
...
@@ -279,6 +297,8 @@ class GpConfig(GpTestCase):
...
@@ -279,6 +297,8 @@ class GpConfig(GpTestCase):
db_singleton_side_effect_list
.
append
(
"some happy result"
)
db_singleton_side_effect_list
.
append
(
"some happy result"
)
entry
=
'my_property_name'
entry
=
'my_property_name'
sys
.
argv
=
[
"gpconfig"
,
"-c"
,
entry
,
"-v"
,
"100"
,
"--masteronly"
]
sys
.
argv
=
[
"gpconfig"
,
"-c"
,
entry
,
"-v"
,
"100"
,
"--masteronly"
]
# mocked database values
# 'SELECT name, setting, unit, short_desc, context, vartype, min_val, max_val FROM pg_settings'
# 'SELECT name, setting, unit, short_desc, context, vartype, min_val, max_val FROM pg_settings'
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
'context'
,
'vartype'
,
'min_val'
,
'max_val'
]])
'context'
,
'vartype'
,
'min_val'
,
'max_val'
]])
...
@@ -329,17 +349,16 @@ class GpConfig(GpTestCase):
...
@@ -329,17 +349,16 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_file_compare_returns_same_value
(
self
,
mock_stdout
):
def
test_option_file_compare_returns_same_value
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"-s"
,
"my_property_name"
,
"--file-compare"
]
sys
.
argv
=
[
"gpconfig"
,
"-s"
,
"my_property_name"
,
"--file-compare"
]
self
.
master_read_config
.
get_guc_value
.
return_value
=
'foo'
self
.
master_read_config
.
get_seg_content_id
.
return_value
=
-
1
self
.
segment_read_config
.
get_guc_value
.
return_value
=
'foo'
seg_1
=
Mock
(
name
=
'seg1'
)
self
.
segment_read_config
.
get_seg_content_id
.
return_value
=
0
seg_1
.
segInfo
.
getSegmentContentId
.
return_value
=
1
seg_1
.
segInfo
.
getSegmentDbId
.
return_value
=
2
seg_1
.
get_value
.
return_value
=
'foo'
another_segment_read_config
=
Mock
()
# mocked values in the files
another_segment_read_config
.
get_guc_value
.
return_value
=
"foo"
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
seg_1
)
another_segment_read_config
.
get_seg_content_id
.
return_value
=
1
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
another_segment_read_config
)
# mocked database values
self
.
cursor
.
set_result_for_testing
([[
-
1
,
'my_property_name'
,
'foo'
],
self
.
cursor
.
set_result_for_testing
([[
-
1
,
'my_property_name'
,
'foo'
],
[
0
,
'my_property_name'
,
'foo'
],
[
0
,
'my_property_name'
,
'foo'
],
[
1
,
'my_property_name'
,
'foo'
]])
[
1
,
'my_property_name'
,
'foo'
]])
...
@@ -353,17 +372,19 @@ class GpConfig(GpTestCase):
...
@@ -353,17 +372,19 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_file_compare_works_with_unset_values
(
self
,
mock_stdout
):
def
test_option_file_compare_works_with_unset_values
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"-s"
,
"my_property_name"
,
"--file-compare"
]
sys
.
argv
=
[
"gpconfig"
,
"-s"
,
"my_property_name"
,
"--file-compare"
]
self
.
master_read_config
.
get_guc_value
.
return_value
=
None
self
.
master_read_config
.
get_seg_content_id
.
return_value
=
-
1
self
.
segment_read_config
.
get_guc
_value
.
return_value
=
None
self
.
master_file
.
get
_value
.
return_value
=
None
self
.
seg
ment_read_config
.
get_seg_content_id
.
return_value
=
0
self
.
seg
0_file
.
get_value
.
return_value
=
None
another_segment_read_config
=
Mock
(
)
seg_1
=
Mock
(
name
=
'seg1'
)
another_segment_read_config
.
get_guc_value
.
return_value
=
None
seg_1
.
segInfo
.
getSegmentContentId
.
return_value
=
1
another_segment_read_config
.
get_seg_content_id
.
return_value
=
1
seg_1
.
segInfo
.
getSegmentDbId
.
return_value
=
2
se
lf
.
pool
.
getCompletedItems
.
return_value
.
append
(
another_segment_read_config
)
se
g_1
.
get_value
.
return_value
=
None
# mocked values in the files
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
seg_1
)
# mocked database values
self
.
cursor
.
set_result_for_testing
([[
-
1
,
'my_property_name'
,
'foo'
],
self
.
cursor
.
set_result_for_testing
([[
-
1
,
'my_property_name'
,
'foo'
],
[
0
,
'my_property_name'
,
'foo'
],
[
0
,
'my_property_name'
,
'foo'
],
[
1
,
'my_property_name'
,
'foo'
]])
[
1
,
'my_property_name'
,
'foo'
]])
...
@@ -377,20 +398,16 @@ class GpConfig(GpTestCase):
...
@@ -377,20 +398,16 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_file_compare_returns_different_value
(
self
,
mock_stdout
):
def
test_option_file_compare_returns_different_value
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"-s"
,
"my_property_name"
,
"--file-compare"
]
sys
.
argv
=
[
"gpconfig"
,
"-s"
,
"my_property_name"
,
"--file-compare"
]
self
.
master_read_config
.
get_guc_value
.
return_value
=
'foo'
self
.
master_read_config
.
get_seg_content_id
.
return_value
=
-
1
self
.
master_read_config
.
get_seg_dbid
.
return_value
=
0
self
.
segment_read_config
.
get_guc_value
.
return_value
=
'foo'
seg_1
=
Mock
(
name
=
'seg1'
)
self
.
segment_read_config
.
get_seg_content_id
.
return_value
=
0
seg_1
.
segInfo
.
getSegmentContentId
.
return_value
=
1
self
.
segment_read_config
.
get_seg_dbid
.
return_value
=
1
seg_1
.
segInfo
.
getSegmentDbId
.
return_value
=
2
seg_1
.
get_value
.
return_value
=
'bar'
another_segment_read_config
=
Mock
()
# mocked values in the files
another_segment_read_config
.
get_guc_value
.
return_value
=
"bar"
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
seg_1
)
another_segment_read_config
.
get_seg_content_id
.
return_value
=
1
another_segment_read_config
.
get_seg_dbid
.
return_value
=
2
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
another_segment_read_config
)
# mocked database values
self
.
cursor
.
set_result_for_testing
([[
-
1
,
'my_property_name'
,
'foo'
],
self
.
cursor
.
set_result_for_testing
([[
-
1
,
'my_property_name'
,
'foo'
],
[
0
,
'my_property_name'
,
'foo'
],
[
0
,
'my_property_name'
,
'foo'
],
[
1
,
'my_property_name'
,
'foo'
]])
[
1
,
'my_property_name'
,
'foo'
]])
...
@@ -408,20 +425,16 @@ class GpConfig(GpTestCase):
...
@@ -408,20 +425,16 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_file_compare_with_unset_values_on_some_segments
(
self
,
mock_stdout
):
def
test_option_file_compare_with_unset_values_on_some_segments
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"-s"
,
"my_property_name"
,
"--file-compare"
]
sys
.
argv
=
[
"gpconfig"
,
"-s"
,
"my_property_name"
,
"--file-compare"
]
self
.
master_read_config
.
get_guc_value
.
return_value
=
'foo'
self
.
master_read_config
.
get_seg_content_id
.
return_value
=
-
1
self
.
master_read_config
.
get_seg_dbid
.
return_value
=
0
self
.
segment_read_config
.
get_guc_value
.
return_value
=
'foo'
seg2_file
=
Mock
(
name
=
'seg2'
)
self
.
segment_read_config
.
get_seg_content_id
.
return_value
=
0
seg2_file
.
segInfo
.
getSegmentContentId
.
return_value
=
1
self
.
segment_read_config
.
get_seg_dbid
.
return_value
=
1
seg2_file
.
segInfo
.
getSegmentDbId
.
return_value
=
2
seg2_file
.
get_value
.
return_value
=
None
another_segment_read_config
=
Mock
()
# mocked values in the files
another_segment_read_config
.
get_guc_value
.
return_value
=
None
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
seg2_file
)
another_segment_read_config
.
get_seg_content_id
.
return_value
=
1
another_segment_read_config
.
get_seg_dbid
.
return_value
=
2
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
another_segment_read_config
)
# mocked database values
self
.
cursor
.
set_result_for_testing
([[
-
1
,
'my_property_name'
,
'foo'
],
self
.
cursor
.
set_result_for_testing
([[
-
1
,
'my_property_name'
,
'foo'
],
[
0
,
'my_property_name'
,
'foo'
],
[
0
,
'my_property_name'
,
'foo'
],
[
1
,
'my_property_name'
,
'foo'
]])
[
1
,
'my_property_name'
,
'foo'
]])
...
@@ -439,20 +452,17 @@ class GpConfig(GpTestCase):
...
@@ -439,20 +452,17 @@ class GpConfig(GpTestCase):
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
@
patch
(
'sys.stdout'
,
new_callable
=
StringIO
)
def
test_option_file_compare_with_standby_master_with_different_file_value_will_report_failure
(
self
,
mock_stdout
):
def
test_option_file_compare_with_standby_master_with_different_file_value_will_report_failure
(
self
,
mock_stdout
):
sys
.
argv
=
[
"gpconfig"
,
"-s"
,
"my_property_name"
,
"--file-compare"
]
sys
.
argv
=
[
"gpconfig"
,
"-s"
,
"my_property_name"
,
"--file-compare"
]
standby_master
=
Mock
(
name
=
'standby_master'
)
standby_master
.
segInfo
.
getSegmentContentId
.
return_value
=
-
1
standby_master
.
segInfo
.
getSegmentDbId
.
return_value
=
2
standby_master
.
get_value
.
return_value
=
'bar'
# mocked values in the files
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
standby_master
)
# mocked database values
self
.
cursor
.
set_result_for_testing
([[
-
1
,
'my_property_name'
,
'foo'
]])
self
.
cursor
.
set_result_for_testing
([[
-
1
,
'my_property_name'
,
'foo'
]])
self
.
master_read_config
.
get_guc_value
.
return_value
=
'foo'
self
.
master_read_config
.
get_seg_content_id
.
return_value
=
-
1
self
.
master_read_config
.
get_seg_dbid
.
return_value
=
0
# standby mirror with bad file value
self
.
segment_read_config
.
get_guc_value
.
return_value
=
'foo'
self
.
segment_read_config
.
get_seg_content_id
.
return_value
=
0
self
.
segment_read_config
.
get_seg_dbid
.
return_value
=
1
standby_segment_read_config
=
Mock
()
standby_segment_read_config
.
get_guc_value
.
return_value
=
"bar"
standby_segment_read_config
.
get_seg_content_id
.
return_value
=
-
1
standby_segment_read_config
.
get_seg_dbid
.
return_value
=
2
self
.
pool
.
getCompletedItems
.
return_value
.
append
(
standby_segment_read_config
)
self
.
subject
.
do_main
()
self
.
subject
.
do_main
()
...
@@ -516,6 +526,8 @@ class GpConfig(GpTestCase):
...
@@ -516,6 +526,8 @@ class GpConfig(GpTestCase):
sys
.
argv
=
[
"gpconfig"
,
"--change"
,
"my_property_name"
,
"--value"
,
value
]
sys
.
argv
=
[
"gpconfig"
,
"--change"
,
"my_property_name"
,
"--value"
,
value
]
if
additional_args
:
if
additional_args
:
sys
.
argv
.
extend
(
additional_args
)
sys
.
argv
.
extend
(
additional_args
)
# mocked database values
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
'context'
,
vartype
,
'min_val'
,
'max_val'
]])
'context'
,
vartype
,
'min_val'
,
'max_val'
]])
...
@@ -564,6 +576,8 @@ class GpConfig(GpTestCase):
...
@@ -564,6 +576,8 @@ class GpConfig(GpTestCase):
db_singleton_side_effect_list
.
append
(
"some happy result"
)
db_singleton_side_effect_list
.
append
(
"some happy result"
)
entry
=
'my_property_name'
entry
=
'my_property_name'
sys
.
argv
=
[
"gpconfig"
,
"-c"
,
entry
,
"-v"
,
"100"
,
"--masteronly"
]
sys
.
argv
=
[
"gpconfig"
,
"-c"
,
entry
,
"-v"
,
"100"
,
"--masteronly"
]
# mocked database values
# 'SELECT name, setting, unit, short_desc, context, vartype, min_val, max_val FROM pg_settings'
# 'SELECT name, setting, unit, short_desc, context, vartype, min_val, max_val FROM pg_settings'
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
'context'
,
'vartype'
,
'min_val'
,
'max_val'
]])
'context'
,
'vartype'
,
'min_val'
,
'max_val'
]])
...
@@ -582,6 +596,8 @@ class GpConfig(GpTestCase):
...
@@ -582,6 +596,8 @@ class GpConfig(GpTestCase):
def
test_gpconfig_logs_successful_guc_change
(
self
):
def
test_gpconfig_logs_successful_guc_change
(
self
):
sys
.
argv
=
[
"gpconfig"
,
"-c"
,
'my_property_name'
,
"-v"
,
"100"
,
"--masteronly"
]
sys
.
argv
=
[
"gpconfig"
,
"-c"
,
'my_property_name'
,
"-v"
,
"100"
,
"--masteronly"
]
# mocked database values
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
'context'
,
'vartype'
,
'min_val'
,
'max_val'
]])
'context'
,
'vartype'
,
'min_val'
,
'max_val'
]])
...
@@ -591,9 +607,11 @@ class GpConfig(GpTestCase):
...
@@ -591,9 +607,11 @@ class GpConfig(GpTestCase):
def
test_gpconfig_logs_unsuccessful_guc_change
(
self
):
def
test_gpconfig_logs_unsuccessful_guc_change
(
self
):
sys
.
argv
=
[
"gpconfig"
,
"-c"
,
'my_property_name'
,
"-v"
,
"100"
,
"--masteronly"
]
sys
.
argv
=
[
"gpconfig"
,
"-c"
,
'my_property_name'
,
"-v"
,
"100"
,
"--masteronly"
]
# mocked database values
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
self
.
cursor
.
set_result_for_testing
([[
'my_property_name'
,
'setting'
,
'unit'
,
'short_desc'
,
'context'
,
'vartype'
,
'min_val'
,
'max_val'
]])
'context'
,
'vartype'
,
'min_val'
,
'max_val'
]])
self
.
seg
ment_read_config
.
was_successful
.
return_value
=
False
self
.
seg
0_file
.
was_successful
.
return_value
=
False
self
.
subject
.
do_main
()
self
.
subject
.
do_main
()
self
.
subject
.
LOGGER
.
error
.
assert_called_with
(
"finished with errors, parameter string '-c my_property_name -v 100 --masteronly'"
)
self
.
subject
.
LOGGER
.
error
.
assert_called_with
(
"finished with errors, parameter string '-c my_property_name -v 100 --masteronly'"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录