From 208c9160c93c01290e82c253fa7a3abafd7fd858 Mon Sep 17 00:00:00 2001 From: Huang-Ming Huang Date: Tue, 11 Apr 2023 09:13:46 -0500 Subject: [PATCH 1/2] fix resource not found buf --- .../include/eosio/prometheus_plugin/simple_rest_server.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/prometheus_plugin/include/eosio/prometheus_plugin/simple_rest_server.hpp b/plugins/prometheus_plugin/include/eosio/prometheus_plugin/simple_rest_server.hpp index f82492df28..c9bef7f05f 100644 --- a/plugins/prometheus_plugin/include/eosio/prometheus_plugin/simple_rest_server.hpp +++ b/plugins/prometheus_plugin/include/eosio/prometheus_plugin/simple_rest_server.hpp @@ -67,7 +67,7 @@ namespace eosio { namespace rest { try { auto res = self()->on_request(std::move(req)); if (!res) - not_found(target); + return not_found(target); return *res; } catch (std::exception& ex) { return server_error(ex.what()); } } From df88471be4524a5749ea4b24e28ad141ad2c79d9 Mon Sep 17 00:00:00 2001 From: Huang-Ming Huang Date: Tue, 11 Apr 2023 09:52:33 -0500 Subject: [PATCH 2/2] add test --- tests/TestHarness/queries.py | 2 ++ tests/plugin_http_api_test.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/TestHarness/queries.py b/tests/TestHarness/queries.py index e73c3ad06b..5521be8870 100644 --- a/tests/TestHarness/queries.py +++ b/tests/TestHarness/queries.py @@ -643,6 +643,8 @@ def processUrllibRequest(self, resource, command, payload={}, silentErrors=False rtn = ex.read() else: unhandledEnumType(returnType) + elif returnType==ReturnType.raw: + return ex.code else: return None diff --git a/tests/plugin_http_api_test.py b/tests/plugin_http_api_test.py index ad9b58ee41..686639c72e 100755 --- a/tests/plugin_http_api_test.py +++ b/tests/plugin_http_api_test.py @@ -1352,6 +1352,8 @@ def test_prometheusApi(self) : self.assertTrue(int(metrics["blocks_produced"]) > 1) self.assertTrue(int(metrics["last_irreversible"]) > 1) + ret = self.nodeos.processUrllibRequest(resource, "m", returnType = ReturnType.raw, method="GET", silentErrors= True, endpoint=endpointPrometheus) + self.assertTrue(ret == 404) def test_multipleRequests(self): """Test keep-alive ability of HTTP plugin. Handle multiple requests in a single session"""