def test_neg_set_ioclass_name(pyocf_ctx): """ Test whether it is possible to add ioclass with invaild name :param pyocf_ctx: basic pyocf context fixture :return: """ invalid_chars = [ chr(c) for c in range(256) if chr(c) not in string.printable ] invalid_chars += [",", '"'] # Start cache device cache_device = Volume(S.from_MiB(30)) cache = Cache.start_on_device(cache_device, cache_mode=CacheMode.WT, cache_line_size=CacheLineSize.LINE_4KiB) # Set invalid name and check if failed for name in RandomStringGenerator(len_range=Range(0, 1024), count=10000, extra_chars=invalid_chars): if not any(c for c in invalid_chars if c in name): continue with pytest.raises(OcfError, match="Error adding partition to cache"): cache.configure_partition(part_id=1, name=name, max_size=100, priority=1) print(f"\n{name}")
def test_neg_set_ioclass_name_len(pyocf_ctx): """ Test whether it is possible to add ioclass with too long name :param pyocf_ctx: basic pyocf context fixture :return: """ # Start cache device cache_device = Volume(S.from_MiB(30)) cache = Cache.start_on_device(cache_device, cache_mode=CacheMode.WT, cache_line_size=CacheLineSize.LINE_4KiB) # Set invalid name and check if failed for name in RandomStringGenerator(len_range=Range(1025, 4096), count=10000): with pytest.raises(OcfError, match="Error adding partition to cache"): cache.configure_partition(part_id=1, name=name, max_size=100, priority=1) print(f"\n{name}")
def enum_range(enum): return Range(enum_min(enum), enum_max(enum))