Merge pull request #558 from imjfckm/fix-cache-lazy-startup

Fix handling of lazy_startup for cache
This commit is contained in:
Robert Baldyga 2020-11-05 14:02:41 +01:00 committed by GitHub
commit 4972deb312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -331,7 +331,7 @@ def test_cas_config_get_by_id_path_not_found(mock_listdir, mock_realpath):
),
(
[
"1 /dev/dummy0n1 WT cleaning_policy=acp",
"1 /dev/dummy0n1 WT cleaning_policy=acp,lazy_startup=true",
"2 /dev/dummy0n2 pt ioclass_file=mango.csv",
"3 /dev/dummy0n3 WA cache_line_size=16",
("4 /dev/dummyc wb cache_line_size=16,"

View File

@ -204,6 +204,8 @@ def test_cache_config_from_line_missing_ioclass_file(
"promotion_policy=Robert'); DROP TABLE Students;--",
"promotion_policy=awlays",
"promotion_policy=nnhit",
"lazy_startup=yes",
"lazy_startup=absolutely",
],
)
@mock.patch("os.path.exists")
@ -240,7 +242,10 @@ def test_cache_config_from_line_parameter_validation_01(
"ioclass_file=ioclass.csv,cache_line_size=4,cleaning_policy=nop",
"promotion_policy=nhit",
"promotion_policy=always",
"ioclass_file=ioclass.csv,cache_line_size=4,cleaning_policy=nop,promotion_policy=always",
"lazy_startup=true",
"lazy_startup=false",
("ioclass_file=ioclass.csv,cache_line_size=4,cleaning_policy=nop,promotion_policy=always,"
"lazy_startup=true"),
],
)
@mock.patch("os.path.exists")

View File

@ -253,7 +253,7 @@ class cas_config(object):
elif param_name == 'cache_line_size':
self.check_cache_line_size_valid(param_value)
elif param_name == "lazy_startup":
self.check_lazy_startup(param_value)
self.check_lazy_startup_valid(param_value)
else:
raise ValueError('{0} is invalid parameter name'.format(param_name))
@ -286,7 +286,7 @@ class cas_config(object):
cleaning_policy))
def check_lazy_startup_valid(self, lazy_startup):
if param_value.lower() not in ["true", "false"]:
if lazy_startup.lower() not in ["true", "false"]:
raise ValueError('{0} is invalid lazy_startup value'.format(lazy_startup))
def check_promotion_policy_valid(self, promotion_policy):