From ec1fcfba57a907838caef5b1029ea5e95c348175 Mon Sep 17 00:00:00 2001
From: Chaoguang Lin <chaoguang.lin@snowflake.com>
Date: Fri, 16 Jul 2021 19:45:23 +0000
Subject: [PATCH] Add test coverage for profile command

---
 bindings/python/tests/fdbcli_tests.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/bindings/python/tests/fdbcli_tests.py b/bindings/python/tests/fdbcli_tests.py
index 36f9ec34a9..e9fe08b44f 100755
--- a/bindings/python/tests/fdbcli_tests.py
+++ b/bindings/python/tests/fdbcli_tests.py
@@ -475,6 +475,29 @@ def wait_for_database_available(logger):
         time.sleep(1)
 
 
+@enable_logging()
+def profile(logger):
+    # profile list should return the same list as kill
+    addresses = get_fdb_process_addresses()
+    output1 = run_fdbcli_command('profile', 'list')
+    assert output1.split('\n') == addresses
+    # check default output
+    default_profile_client_get_output = 'Client profiling rate is set to default and size limit is set to default.'
+    output2 = run_fdbcli_command('profile', 'client', 'get')
+    assert output2 == default_profile_client_get_output
+    # TODO: this test is now failing, the implementation needs to be fixed
+    # set rate and size limit
+    # run_fdbcli_command('profile', 'client', 'set', '0.5', 'default')
+    # output3 = run_fdbcli_command('profile', 'client', 'get')
+    # logger.debug(output3)
+    # output3_list = output3.split(' ')
+    # assert float(output3_list[6]) == 0.5
+    # assert output3_list[-1] == '1000000000.'
+    # change back to default value and check
+    run_fdbcli_command('profile', 'client', 'set', 'default', 'default')
+    assert run_fdbcli_command('profile', 'client', 'get') == default_profile_client_get_output
+
+
 if __name__ == '__main__':
     parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
                             description="""
@@ -512,6 +535,7 @@ if __name__ == '__main__':
         kill()
         lockAndUnlock()
         maintenance()
+        profile()
         setclass()
         suspend()
         transaction()