From 91cc794e0c4314f980924acc91be969b51ecb112 Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Fri, 1 Nov 2024 14:55:05 -0400 Subject: [PATCH 1/3] Restore producer runtime options to default values after update_runtime_options test such that modified options do not affect other tests --- tests/plugin_http_api_test.py | 88 +++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/tests/plugin_http_api_test.py b/tests/plugin_http_api_test.py index 7b4f875ee1..c4dae43b52 100755 --- a/tests/plugin_http_api_test.py +++ b/tests/plugin_http_api_test.py @@ -887,42 +887,6 @@ def test_NetApi(self) : def test_ProducerApi(self) : resource = "producer" endpoint=self.endpoint("producer_rw") - # pause with empty parameter - command = "pause" - ret_json = self.nodeos.processUrllibRequest(resource, command, endpoint=endpoint) - self.assertEqual(ret_json["payload"]["result"], "ok") - # pause with empty content parameter - ret_json = self.nodeos.processUrllibRequest(resource, command, self.empty_content_dict, endpoint=endpoint) - self.assertEqual(ret_json["payload"]["result"], "ok") - # pause with invalid parameter - ret_json = self.nodeos.processUrllibRequest(resource, command, self.http_post_invalid_param, endpoint=endpoint) - self.assertEqual(ret_json["code"], 400) - self.assertEqual(ret_json["error"]["code"], 3200006) - - # resume with empty parameter - command = "resume" - ret_json = self.nodeos.processUrllibRequest(resource, command, endpoint=endpoint) - self.assertEqual(ret_json["payload"]["result"], "ok") - # resume with empty content parameter - ret_json = self.nodeos.processUrllibRequest(resource, command, self.empty_content_dict, endpoint=endpoint) - self.assertEqual(ret_json["payload"]["result"], "ok") - # resume with invalid parameter - ret_json = self.nodeos.processUrllibRequest(resource, command, self.http_post_invalid_param, endpoint=endpoint) - self.assertEqual(ret_json["code"], 400) - self.assertEqual(ret_json["error"]["code"], 3200006) - - endpoint=self.endpoint("producer_ro") - # paused with empty parameter - command = "paused" - ret_str = self.nodeos.processUrllibRequest(resource, command, returnType=ReturnType.raw, endpoint=endpoint).decode('ascii') - self.assertEqual(ret_str, "false") - # paused with empty content parameter - ret_str = self.nodeos.processUrllibRequest(resource, command, self.empty_content_dict, returnType=ReturnType.raw, endpoint=endpoint).decode('ascii') - self.assertEqual(ret_str, "false") - # paused with invalid parameter - ret_json = self.nodeos.processUrllibRequest(resource, command, self.http_post_invalid_param, endpoint=endpoint) - self.assertEqual(ret_json["code"], 400) - self.assertEqual(ret_json["error"]["code"], 3200006) # get_runtime_options with empty parameter command = "get_runtime_options" @@ -960,6 +924,18 @@ def test_ProducerApi(self) : "greylist_limit":100} ret_json = self.nodeos.processUrllibRequest(resource, command, payload, endpoint=endpoint) self.assertIn(ret_json["payload"]["result"], "ok") + # restore runtime options to default values such that future tests are not impacted + # by the modified values of last test (max_irreversible_block_age: 1 can make producer + # plugin stuck in speculative mode) + payload = {"max_transaction_time":499, + "max_irreversible_block_age":-1, + "cpu_effort_us":400000, + "max_scheduled_transaction_time_per_block_ms":10000, + "subjective_cpu_leeway_us":31000, + "incoming_defer_ratio":1.0, + "greylist_limit":1000} + ret_json = self.nodeos.processUrllibRequest(resource, command, payload, endpoint=endpoint) + self.assertIn(ret_json["payload"]["result"], "ok") # add_greylist_accounts with empty parameter command = "add_greylist_accounts" @@ -1176,6 +1152,46 @@ def test_ProducerApi(self) : ret_json = self.nodeos.processUrllibRequest(resource, command, payload, endpoint=endpoint) self.assertIn("trxs", ret_json["payload"]) + # place pause and resume tests at the end such that they are not impacted + # by update_runtime_options + + # pause with empty parameter + command = "pause" + ret_json = self.nodeos.processUrllibRequest(resource, command, endpoint=endpoint) + self.assertEqual(ret_json["payload"]["result"], "ok") + # pause with empty content parameter + ret_json = self.nodeos.processUrllibRequest(resource, command, self.empty_content_dict, endpoint=endpoint) + self.assertEqual(ret_json["payload"]["result"], "ok") + # pause with invalid parameter + ret_json = self.nodeos.processUrllibRequest(resource, command, self.http_post_invalid_param, endpoint=endpoint) + self.assertEqual(ret_json["code"], 400) + self.assertEqual(ret_json["error"]["code"], 3200006) + + # resume with empty parameter + command = "resume" + ret_json = self.nodeos.processUrllibRequest(resource, command, endpoint=endpoint) + self.assertEqual(ret_json["payload"]["result"], "ok") + # resume with empty content parameter + ret_json = self.nodeos.processUrllibRequest(resource, command, self.empty_content_dict, endpoint=endpoint) + self.assertEqual(ret_json["payload"]["result"], "ok") + # resume with invalid parameter + ret_json = self.nodeos.processUrllibRequest(resource, command, self.http_post_invalid_param, endpoint=endpoint) + self.assertEqual(ret_json["code"], 400) + self.assertEqual(ret_json["error"]["code"], 3200006) + + endpoint=self.endpoint("producer_ro") + # paused with empty parameter + command = "paused" + ret_str = self.nodeos.processUrllibRequest(resource, command, returnType=ReturnType.raw, endpoint=endpoint).decode('ascii') + self.assertEqual(ret_str, "false") + # paused with empty content parameter + ret_str = self.nodeos.processUrllibRequest(resource, command, self.empty_content_dict, returnType=ReturnType.raw, endpoint=endpoint).decode('ascii') + self.assertEqual(ret_str, "false") + # paused with invalid parameter + ret_json = self.nodeos.processUrllibRequest(resource, command, self.http_post_invalid_param, endpoint=endpoint) + self.assertEqual(ret_json["code"], 400) + self.assertEqual(ret_json["error"]["code"], 3200006) + # test all wallet api def test_WalletApi(self) : endpoint = self.base_wallet_cmd_str From 07381a9f5fd7ce392db52bc35dd2afc9f3b30467 Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Fri, 1 Nov 2024 15:02:42 -0400 Subject: [PATCH 2/3] Remove max_scheduled_transaction_time_per_block_ms and incoming_defer_ratio as they have not been options since Leap 5.0 --- tests/plugin_http_api_test.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/plugin_http_api_test.py b/tests/plugin_http_api_test.py index c4dae43b52..7514e2ceea 100755 --- a/tests/plugin_http_api_test.py +++ b/tests/plugin_http_api_test.py @@ -918,9 +918,7 @@ def test_ProducerApi(self) : payload = {"max_transaction_time":30, "max_irreversible_block_age":1, "cpu_effort_us":400000, - "max_scheduled_transaction_time_per_block_ms":10000, "subjective_cpu_leeway_us":0, - "incoming_defer_ratio":1.0, "greylist_limit":100} ret_json = self.nodeos.processUrllibRequest(resource, command, payload, endpoint=endpoint) self.assertIn(ret_json["payload"]["result"], "ok") @@ -930,9 +928,7 @@ def test_ProducerApi(self) : payload = {"max_transaction_time":499, "max_irreversible_block_age":-1, "cpu_effort_us":400000, - "max_scheduled_transaction_time_per_block_ms":10000, "subjective_cpu_leeway_us":31000, - "incoming_defer_ratio":1.0, "greylist_limit":1000} ret_json = self.nodeos.processUrllibRequest(resource, command, payload, endpoint=endpoint) self.assertIn(ret_json["payload"]["result"], "ok") From 3c1c4d8c156a23d52ad95bef1b2ca1d285c9e078 Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Fri, 1 Nov 2024 16:50:50 -0400 Subject: [PATCH 3/3] Set http category correctly for plugin_http_category_api_test due to code moving around --- tests/plugin_http_api_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/plugin_http_api_test.py b/tests/plugin_http_api_test.py index 7514e2ceea..85b9c8210a 100755 --- a/tests/plugin_http_api_test.py +++ b/tests/plugin_http_api_test.py @@ -886,7 +886,7 @@ def test_NetApi(self) : # test all producer api def test_ProducerApi(self) : resource = "producer" - endpoint=self.endpoint("producer_rw") + endpoint=self.endpoint("producer_ro") # get_runtime_options with empty parameter command = "get_runtime_options" @@ -1151,6 +1151,7 @@ def test_ProducerApi(self) : # place pause and resume tests at the end such that they are not impacted # by update_runtime_options + endpoint=self.endpoint("producer_rw") # pause and resume are in producer_rw category # pause with empty parameter command = "pause" ret_json = self.nodeos.processUrllibRequest(resource, command, endpoint=endpoint)