def test_health(self): self.assert_valid_command(['health']) self.assert_valid_command(['health', 'detail']) assert_equal({}, validate_command(sigdict, ['health', 'invalid'])) assert_equal({}, validate_command(sigdict, ['health', 'detail', 'toomany']))
def check_1_string_arg(self, prefix, command): assert_equal({}, validate_command(sigdict, [prefix, command])) self.assert_valid_command([prefix, command, 'string']) assert_equal({}, validate_command(sigdict, [prefix, command, 'string', 'toomany']))
def test_map(self): self.assert_valid_command(['osd', 'map', 'poolname', 'objectname']) assert_equal({}, validate_command(sigdict, ['osd', 'map'])) assert_equal({}, validate_command(sigdict, ['osd', 'map', 'poolname'])) assert_equal({}, validate_command(sigdict, ['osd', 'map', 'poolname', 'objectname', 'toomany']))
def test_crush_move(self): self.assert_valid_command(["osd", "crush", "move", "AZaz09-_.", "AZaz09-_.="]) self.assert_valid_command(["osd", "crush", "move", "0", "AZaz09-_.=", "AZaz09-_.="]) assert_equal({}, validate_command(sigdict, ["osd", "crush", "move"])) assert_equal({}, validate_command(sigdict, ["osd", "crush", "move", "AZaz09-_."])) assert_equal({}, validate_command(sigdict, ["osd", "crush", "move", "!!!", "AZaz09-_.="])) assert_equal({}, validate_command(sigdict, ["osd", "crush", "move", "AZaz09-_.", "!!!"]))
def test_reweight(self): self.assert_valid_command(["osd", "reweight", "1", "0.1"]) assert_equal({}, validate_command(sigdict, ["osd", "reweight"])) assert_equal({}, validate_command(sigdict, ["osd", "reweight", "1"])) assert_equal({}, validate_command(sigdict, ["osd", "reweight", "1", "2.0"])) assert_equal({}, validate_command(sigdict, ["osd", "reweight", "-1", "0.1"])) assert_equal({}, validate_command(sigdict, ["osd", "reweight", "1", "0.1", "toomany"]))
def test_lost(self): self.assert_valid_command(["osd", "lost", "1", "--yes-i-really-mean-it"]) self.assert_valid_command(["osd", "lost", "1"]) assert_equal({}, validate_command(sigdict, ["osd", "lost"])) assert_equal({}, validate_command(sigdict, ["osd", "lost", "1", "what?"])) assert_equal({}, validate_command(sigdict, ["osd", "lost", "-1", "--yes-i-really-mean-it"])) assert_equal({}, validate_command(sigdict, ["osd", "lost", "1", "--yes-i-really-mean-it", "toomany"]))
def test_pool_create(self): self.assert_valid_command(["osd", "pool", "create", "poolname", "128"]) self.assert_valid_command(["osd", "pool", "create", "poolname", "128", "128"]) self.assert_valid_command(["osd", "pool", "create", "poolname", "128", "128", "whatever"]) assert_equal({}, validate_command(sigdict, ["osd", "pool", "create"])) assert_equal({}, validate_command(sigdict, ["osd", "pool", "create", "poolname"])) assert_equal({}, validate_command(sigdict, ["osd", "pool", "create", "poolname", "-1"]))
def test_erasure_code_profile_set(self): self.assert_valid_command(["osd", "erasure-code-profile", "set", "name"]) self.assert_valid_command(["osd", "erasure-code-profile", "set", "name", "A=B"]) self.assert_valid_command(["osd", "erasure-code-profile", "set", "name", "A=B", "C=D"]) assert_equal({}, validate_command(sigdict, ["osd", "erasure-code-profile", "set"])) assert_equal({}, validate_command(sigdict, ["osd", "erasure-code-profile", "set", "^^^^"])) assert_equal({}, validate_command(sigdict, ["osd", "erasure-code-profile", "set", "name", "^^^^"]))
def test_quorum(self): assert_equal({}, validate_command(sigdict, ['quorum'])) assert_equal({}, validate_command(sigdict, ['quorum', 'invalid'])) self.assert_valid_command(['quorum', 'enter']) self.assert_valid_command(['quorum', 'exit']) assert_equal({}, validate_command(sigdict, ['quorum', 'enter', 'toomany']))
def test_crush_tunables(self): for tunable in ('legacy', 'argonaut', 'bobtail', 'optimal', 'default'): self.assert_valid_command(['osd', 'crush', 'tunables', tunable]) assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'tunables'])) assert_equal(None, validate_command(sigdict, ['osd', 'crush', 'default', 'toomany']))
def test_crush_rule(self): assert_equal({}, validate_command(sigdict, ['osd', 'crush'])) assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule'])) for subcommand in ('list', 'ls', 'dump'): self.assert_valid_command(['osd', 'crush', 'rule', subcommand]) assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule', subcommand, 'toomany']))
def test_set_state(self): self.assert_valid_command(['mds', 'set_state', '1', '2']) assert_equal({}, validate_command(sigdict, ['mds', 'set_state'])) assert_equal({}, validate_command(sigdict, ['mds', 'set_state', '-1'])) assert_equal({}, validate_command(sigdict, ['mds', 'set_state', '1', '-1'])) assert_equal({}, validate_command(sigdict, ['mds', 'set_state', '1', '21']))
def set_ratio(self, command): self.assert_valid_command(['pg', command, '0.0']) assert_equal({}, validate_command(sigdict, ['pg', command])) assert_equal({}, validate_command(sigdict, ['pg', command, '2.0']))
def check_crush_setter(self, setter): self.assert_valid_command(["osd", "crush", setter, "*", "2.3", "AZaz09-_.="]) self.assert_valid_command(["osd", "crush", setter, "osd.0", "2.3", "AZaz09-_.="]) self.assert_valid_command(["osd", "crush", setter, "0", "2.3", "AZaz09-_.="]) self.assert_valid_command(["osd", "crush", setter, "0", "2.3", "AZaz09-_.=", "AZaz09-_.="]) assert_equal({}, validate_command(sigdict, ["osd", "crush", setter, "osd.0"])) assert_in(validate_command(sigdict, ["osd", "crush", setter, "osd.0", "-1.0"]), [None, {}]) assert_equal({}, validate_command(sigdict, ["osd", "crush", setter, "osd.0", "1.0", "!!!"]))
def test_mds_set(self): self.assert_valid_command(['mds', 'set', 'allow_new_snaps']) self.assert_valid_command(['mds', 'set', 'allow_new_snaps', 'sure']) assert_equal({}, validate_command(sigdict, ['mds', 'set', 'invalid'])) assert_equal({}, validate_command( sigdict, ['mds', 'set', 'allow_new_snaps', 'sure', 'toomany']))
def test_crush_dump(self): self.assert_valid_command(['osd', 'crush', 'dump']) for format in ('json', 'json-pretty', 'xml', 'xml-pretty'): self.assert_valid_command(['osd', 'crush', 'dump', format]) assert_equal({}, validate_command(sigdict, ['osd', 'crush'])) assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'dump', 'json', 'toomany']))
def test_heap(self): assert_equal({}, validate_command(sigdict, ['heap'])) assert_equal({}, validate_command(sigdict, ['heap', 'invalid'])) self.assert_valid_command(['heap', 'dump']) self.assert_valid_command(['heap', 'start_profiler']) self.assert_valid_command(['heap', 'stop_profiler']) self.assert_valid_command(['heap', 'release']) self.assert_valid_command(['heap', 'stats'])
def test_put(self): self.assert_valid_command(['config-key', 'put', 'key']) self.assert_valid_command(['config-key', 'put', 'key', 'value']) assert_equal({}, validate_command(sigdict, ['config-key', 'put'])) assert_equal( {}, validate_command(sigdict, ['config-key', 'put', 'key', 'value', 'toomany']))
def test_rm(self): # Valid: single GID argument present self.assert_valid_command(["mds", "rm", "1"]) # Missing GID arg: invalid assert_equal({}, validate_command(sigdict, ["mds", "rm"])) # Extra arg: invalid assert_equal({}, validate_command(sigdict, ["mds", "rm", "1", "mds.42"]))
def test_pool_get(self): for var in ("size", "min_size", "crash_replay_interval", "pg_num", "pgp_num", "crush_ruleset"): self.assert_valid_command(["osd", "pool", "get", "poolname", var]) assert_equal({}, validate_command(sigdict, ["osd", "pool"])) assert_equal({}, validate_command(sigdict, ["osd", "pool", "get"])) assert_equal({}, validate_command(sigdict, ["osd", "pool", "get", "poolname"])) assert_equal({}, validate_command(sigdict, ["osd", "pool", "get", "poolname", "size", "toomany"])) assert_equal({}, validate_command(sigdict, ["osd", "pool", "get", "poolname", "invalid"]))
def test_tell(self): assert_equal({}, validate_command(sigdict, ["tell"])) assert_equal({}, validate_command(sigdict, ["tell", "invalid"])) for name in ("osd", "mon", "client", "mds"): assert_equal({}, validate_command(sigdict, ["tell", name])) assert_equal({}, validate_command(sigdict, ["tell", name + ".42"])) self.assert_valid_command(["tell", name + ".42", "something"]) self.assert_valid_command(["tell", name + ".42", "something", "something else"])
def test_heap(self): assert_equal({}, validate_command(sigdict, ["heap"])) assert_equal({}, validate_command(sigdict, ["heap", "invalid"])) self.assert_valid_command(["heap", "dump"]) self.assert_valid_command(["heap", "start_profiler"]) self.assert_valid_command(["heap", "stop_profiler"]) self.assert_valid_command(["heap", "release"]) self.assert_valid_command(["heap", "stats"])
def test_newfs(self): self.assert_valid_command(["mds", "newfs", "1", "2", "--yes-i-really-mean-it"]) self.assert_valid_command(["mds", "newfs", "1", "2"]) assert_equal({}, validate_command(sigdict, ["mds", "newfs"])) assert_equal({}, validate_command(sigdict, ["mds", "newfs", "1"])) assert_equal({}, validate_command(sigdict, ["mds", "newfs", "1", "2", "--yes-i-really-mean-it", "toomany"])) assert_equal({}, validate_command(sigdict, ["mds", "newfs", "-1", "2", "--yes-i-really-mean-it"])) assert_equal({}, validate_command(sigdict, ["mds", "newfs", "1", "-1", "--yes-i-really-mean-it"]))
def test_crush_tunables(self): for tunable in ('legacy', 'argonaut', 'bobtail', 'optimal', 'default'): self.assert_valid_command(['osd', 'crush', 'tunables', tunable]) assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'tunables'])) assert_equal( None, validate_command(sigdict, ['osd', 'crush', 'default', 'toomany']))
def test_rm(self): assert_equal({}, validate_command(sigdict, ["mds", "rm"])) assert_equal({}, validate_command(sigdict, ["mds", "rm", "1"])) for name in ("osd", "mon", "client", "mds"): self.assert_valid_command(["mds", "rm", "1", name + ".42"]) assert_equal({}, validate_command(sigdict, ["mds", "rm", "-1", name + ".42"])) assert_equal({}, validate_command(sigdict, ["mds", "rm", "-1", name])) assert_equal({}, validate_command(sigdict, ["mds", "rm", "1", name + ".42", "toomany"]))
def test_tier_cache_mode(self): for mode in ('none', 'writeback', 'invalidate+forward', 'readonly'): self.assert_valid_command( ['osd', 'tier', 'cache-mode', 'poolname', mode]) assert_equal({}, validate_command(sigdict, ['osd', 'tier', 'cache-mode'])) assert_equal({}, validate_command( sigdict, ['osd', 'tier', 'cache-mode', 'invalid']))
def test_create(self): uuid = '12345678123456781234567812345678' self.assert_valid_command(['osd', 'create']) self.assert_valid_command(['osd', 'create', uuid]) assert_equal({}, validate_command(sigdict, ['osd', 'create', 'invalid'])) assert_equal({}, validate_command(sigdict, ['osd', 'create', uuid, 'toomany']))
def test_pool_rmsnap(self): self.assert_valid_command(['osd', 'pool', 'rmsnap', 'poolname', 'snapname']) assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rmsnap'])) assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rmsnap', 'poolname'])) assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rmsnap', 'poolname', 'snapname', 'toomany']))
def test_tell(self): assert_equal({}, validate_command(sigdict, ['tell'])) assert_equal({}, validate_command(sigdict, ['tell', 'invalid'])) for name in ('osd', 'mon', 'client', 'mds'): assert_equal({}, validate_command(sigdict, ['tell', name])) assert_equal({}, validate_command(sigdict, ['tell', name + ".42"])) self.assert_valid_command(['tell', name + ".42", 'something']) self.assert_valid_command( ['tell', name + ".42", 'something', 'something else'])
def test_crush_link(self): self.assert_valid_command( ['osd', 'crush', 'link', 'name', 'AZaz09-_.=']) self.assert_valid_command( ['osd', 'crush', 'link', 'name', 'AZaz09-_.=', 'AZaz09-_.=']) assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'link'])) assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'link', 'name']))
def test_tier_remove_overlay(self): self.assert_valid_command(['osd', 'tier', 'remove-overlay', 'poolname']) assert_equal({}, validate_command(sigdict, ['osd', 'tier', 'remove-overlay'])) assert_equal({}, validate_command(sigdict, ['osd', 'tier', 'remove-overlay', 'poolname', 'toomany']))
def test_pool_rename(self): self.assert_valid_command(['osd', 'pool', 'rename', 'poolname', 'othername']) assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rename'])) assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rename', 'poolname'])) assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rename', 'poolname', 'othername', 'toomany']))
def test_blackist(self): for action in ("add", "rm"): self.assert_valid_command(["osd", "blacklist", action, "1.2.3.4/nonce"]) self.assert_valid_command(["osd", "blacklist", action, "1.2.3.4/nonce", "600.40"]) assert_equal({}, validate_command(sigdict, ["osd", "blacklist", action, "invalid", "600.40"])) assert_equal({}, validate_command(sigdict, ["osd", "blacklist", action, "1.2.3.4/nonce", "-1.0"])) assert_equal( {}, validate_command(sigdict, ["osd", "blacklist", action, "1.2.3.4/nonce", "600.40", "toomany"]) )
def test_put(self): self.assert_valid_command(['config-key', 'put', 'key']) self.assert_valid_command(['config-key', 'put', 'key', 'value']) assert_equal({}, validate_command(sigdict, ['config-key', 'put'])) assert_equal({}, validate_command(sigdict, ['config-key', 'put', 'key', 'value', 'toomany']))
def test_tier_cache_mode(self): for mode in ('none', 'writeback', 'invalidate+forward', 'readonly'): self.assert_valid_command(['osd', 'tier', 'cache-mode', 'poolname', mode]) assert_equal({}, validate_command(sigdict, ['osd', 'tier', 'cache-mode'])) assert_equal({}, validate_command(sigdict, ['osd', 'tier', 'cache-mode', 'invalid']))
def test_reweight_by_utilization(self): self.assert_valid_command(['osd', 'reweight-by-utilization']) self.assert_valid_command(['osd', 'reweight-by-utilization', '100']) assert_equal({}, validate_command( sigdict, ['osd', 'reweight-by-utilization', '50'])) assert_equal({}, validate_command( sigdict, ['osd', 'reweight-by-utilization', '100', 'toomany']))
def test_set_unset(self): for action in ('set', 'unset'): for flag in ('pause', 'noup', 'nodown', 'noout', 'noin', 'nobackfill', 'norecover', 'noscrub', 'nodeep-scrub'): self.assert_valid_command(['osd', action, flag]) assert_equal({}, validate_command(sigdict, ['osd', action])) assert_equal({}, validate_command(sigdict, ['osd', action, 'invalid'])) assert_equal({}, validate_command(sigdict, ['osd', action, 'pause', 'toomany']))
def test_add(self): self.assert_valid_command(['mon', 'add', 'name', '1.2.3.4:1234']) assert_equal({}, validate_command(sigdict, ['mon', 'add'])) assert_equal({}, validate_command(sigdict, ['mon', 'add', 'name'])) assert_equal({}, validate_command(sigdict, ['mon', 'add', 'name', '400.500.600.700'])) assert_equal({}, validate_command(sigdict, ['mon', 'add', 'name', '1.2.3.4:1234', 'toomany']))
def test_compat_rm_compat(self): self.assert_valid_command(['mds', 'compat', 'rm_compat', '1']) assert_equal({}, validate_command(sigdict, ['mds', 'compat', 'rm_compat'])) assert_equal({}, validate_command(sigdict, ['mds', 'compat', 'rm_compat', '-1'])) assert_equal({}, validate_command( sigdict, ['mds', 'compat', 'rm_compat', '1', '1']))
def test_caps(self): assert_equal({}, validate_command(sigdict, ['auth', 'caps'])) assert_equal({}, validate_command(sigdict, ['auth', 'caps', 'string'])) self.assert_valid_command(['auth', 'caps', 'string', 'more string'])
def test_debug(self): self.assert_valid_command(['pg', 'debug', 'unfound_objects_exist']) self.assert_valid_command(['pg', 'debug', 'degraded_pgs_exist']) assert_equal({}, validate_command(sigdict, ['pg', 'debug'])) assert_equal({}, validate_command(sigdict, ['pg', 'debug', 'invalid']))
def test_reweight_by_utilization(self): self.assert_valid_command(['osd', 'reweight-by-utilization']) self.assert_valid_command(['osd', 'reweight-by-utilization', '100']) assert_equal({}, validate_command(sigdict, ['osd', 'reweight-by-utilization', '50'])) assert_equal({}, validate_command(sigdict, ['osd', 'reweight-by-utilization', '100', 'toomany']))
def test_tell(self): self.assert_valid_command(['mds', 'tell', 'someone', 'something']) self.assert_valid_command(['mds', 'tell', 'someone', 'something', 'something else']) assert_equal({}, validate_command(sigdict, ['mds', 'tell'])) assert_equal({}, validate_command(sigdict, ['mds', 'tell', 'someone']))
def test_crush_rule_rm(self): self.assert_valid_command(['osd', 'crush', 'rule', 'rm', 'AZaz09-_.']) assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule', 'rm'])) assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule', 'rm', '!!!!'])) assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule', 'rm', 'AZaz09-_.', 'toomany']))
def test_tier_op(self): for op in ('add', 'remove', 'set-overlay'): self.assert_valid_command(['osd', 'tier', op, 'poolname', 'othername']) assert_equal({}, validate_command(sigdict, ['osd', 'tier', op])) assert_equal({}, validate_command(sigdict, ['osd', 'tier', op, 'poolname'])) assert_equal({}, validate_command(sigdict, ['osd', 'tier', op, 'poolname', 'othername', 'toomany']))
def test_crush_rm(self): for alias in ('rm', 'remove', 'unlink'): self.assert_valid_command(['osd', 'crush', alias, 'AZaz09-_.']) self.assert_valid_command( ['osd', 'crush', alias, 'AZaz09-_.', 'AZaz09-_.']) assert_equal({}, validate_command(sigdict, ['osd', 'crush', alias])) assert_equal( {}, validate_command(sigdict, [ 'osd', 'crush', alias, 'AZaz09-_.', 'AZaz09-_.', 'toomany' ]))
def test_rm(self): assert_equal({}, validate_command(sigdict, ['mds', 'rm'])) assert_equal({}, validate_command(sigdict, ['mds', 'rm', '1'])) for name in ('osd', 'mon', 'client', 'mds'): self.assert_valid_command(['mds', 'rm', '1', name + '.42']) assert_equal({}, validate_command(sigdict, ['mds', 'rm', '-1', name + '.42'])) assert_equal({}, validate_command(sigdict, ['mds', 'rm', '-1', name])) assert_equal({}, validate_command(sigdict, ['mds', 'rm', '1', name + '.42', 'toomany']))
def test_reweight(self): self.assert_valid_command(['osd', 'reweight', '1', '0.1']) assert_equal({}, validate_command(sigdict, ['osd', 'reweight'])) assert_equal({}, validate_command(sigdict, ['osd', 'reweight', '1'])) assert_equal({}, validate_command(sigdict, ['osd', 'reweight', '1', '2.0'])) assert_equal({}, validate_command(sigdict, ['osd', 'reweight', '-1', '0.1'])) assert_equal({}, validate_command(sigdict, ['osd', 'reweight', '1', '0.1', 'toomany']))