From e5933dee7ecec9dfdef4da3110caa6ae48666695 Mon Sep 17 00:00:00 2001 From: Chaoguang Lin Date: Tue, 27 Jul 2021 17:28:59 +0000 Subject: [PATCH] Add test coverage for throttle --- bindings/python/tests/fdbcli_tests.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bindings/python/tests/fdbcli_tests.py b/bindings/python/tests/fdbcli_tests.py index 8004f77f30..05d5223d5c 100755 --- a/bindings/python/tests/fdbcli_tests.py +++ b/bindings/python/tests/fdbcli_tests.py @@ -401,6 +401,32 @@ def exclude(logger): output4 = run_fdbcli_command('exclude') assert no_excluded_process_output in output4 +# read the system key 'k', need to enable the option first +def read_system_key(k): + output = run_fdbcli_command('option', 'on', 'READ_SYSTEM_KEYS;', 'get', k) + if 'is' not in output: + # key not present + return None + _, value = output.split(' is ') + return value + +@enable_logging() +def throttle(logger): + # no throttled tags at the beginning + no_throttle_tags_output = 'There are no throttled tags' + assert run_fdbcli_command('throttle', 'list') == no_throttle_tags_output + # test 'throttle enable auto' + run_fdbcli_command('throttle', 'enable', 'auto') + # verify the change is applied by reading the system key + # not an elegant way, may change later + enable_flag = read_system_key('\\xff\\x02/throttledTags/autoThrottlingEnabled') + assert enable_flag == "`1'" + run_fdbcli_command('throttle', 'disable', 'auto') + enable_flag = read_system_key('\\xff\\x02/throttledTags/autoThrottlingEnabled') + # verify disabled + assert enable_flag == "`0'" + # TODO : test manual throttling, not easy to do now + if __name__ == '__main__': # fdbcli_tests.py assert len(sys.argv) == 4, "Please pass arguments: " @@ -420,6 +446,7 @@ if __name__ == '__main__': setclass() suspend() transaction() + throttle() else: assert process_number > 1, "Process number should be positive" coordinators()