mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-29 23:06:41 +00:00
Update failing tests (#2038)
* Fix failing tests from when they were not enabled * split into two * fix failing test
This commit is contained in:
parent
57e0099425
commit
8fda6593fe
3 changed files with 31 additions and 11 deletions
|
|
@ -104,11 +104,18 @@ int main(int argc, char* argv[]) {
|
|||
});
|
||||
|
||||
app.RegisterPost(
|
||||
R"(/(?:v1/models/([^/:]+)(?:/versions/(\d+))?:(classify|regress|predict))|score)",
|
||||
R"(/(?:v1/models/([^/:]+)(?:/versions/(\d+))?:(classify|regress|predict))|(?:score()()()))",
|
||||
[&env](const auto& name, const auto& version, const auto& action, auto& context) -> void {
|
||||
server::Predict(name, version, action, context, env);
|
||||
});
|
||||
|
||||
app.RegisterPost(
|
||||
R"(/score()()())",
|
||||
[&env](const auto& name, const auto& version, const auto& action, auto& context) -> void {
|
||||
server::Predict(name, version, action, context, env);
|
||||
}
|
||||
);
|
||||
|
||||
app.Bind(boost_address, config.http_port)
|
||||
.NumThreads(config.num_http_threads)
|
||||
.Run();
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ class HttpJsonPayloadTests(unittest.TestCase):
|
|||
'x-ms-client-request-id': 'This~is~my~id'
|
||||
}
|
||||
|
||||
url = "http://{0}:{1}/v1/models/{2}:predict".format(self.server_ip, self.server_port, 'default_model')
|
||||
url = "http://{0}:{1}/v1/models/{2}:predict".format(self.server_ip, self.server_port, 'default')
|
||||
test_util.test_log(url)
|
||||
r = requests.post(url, headers=request_headers, data=request_payload)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace onnxruntime {
|
|||
namespace server {
|
||||
namespace test {
|
||||
|
||||
static const std::string predict_regex = R"(/v1/models/([^/:]+)(?:/versions/(\d+))?:(classify|regress|predict))";
|
||||
static const std::string predict_regex = R"(/(?:v1/models/([^/:]+)(?:/versions/(\d+))?:(classify|regress|predict)))";
|
||||
using test_data = std::tuple<http::verb, std::string, std::string, std::string, std::string, http::status>;
|
||||
|
||||
void do_something(const std::string& name, const std::string& version,
|
||||
|
|
@ -35,7 +35,11 @@ TEST(HttpRouteTests, PostRouteTest) {
|
|||
std::make_tuple(http::verb::post, "/v1/models/abc:predict", "abc", "", "predict", http::status::ok),
|
||||
std::make_tuple(http::verb::post, "/v1/models/models/versions/45:predict", "models", "45", "predict", http::status::ok),
|
||||
std::make_tuple(http::verb::post, "/v1/models/??$$%%@@$^^/versions/45:predict", "??$$%%@@$^^", "45", "predict", http::status::ok),
|
||||
std::make_tuple(http::verb::post, "/v1/models/versions/versions/45:predict", "versions", "45", "predict", http::status::ok)};
|
||||
std::make_tuple(http::verb::post, "/v1/models/versions/versions/45:predict", "versions", "45", "predict", http::status::ok),
|
||||
std::make_tuple(http::verb::post, "/v1/models/versions:predict", "versions", "", "predict", http::status::ok),
|
||||
std::make_tuple(http::verb::post, "/v1/models/default:predict", "default", "", "predict", http::status::ok)
|
||||
};
|
||||
|
||||
|
||||
run_route(predict_regex, http::verb::post, actions, true);
|
||||
}
|
||||
|
|
@ -54,9 +58,9 @@ TEST(HttpRouteTests, PostRouteInvalidURLTest) {
|
|||
std::make_tuple(http::verb::post, "/models/abc/versions/2:predict", "", "", "", http::status::not_found),
|
||||
std::make_tuple(http::verb::post, "/v1/models/versions/2:predict", "", "", "", http::status::not_found),
|
||||
std::make_tuple(http::verb::post, "/v1/models/foo/versions/:predict", "", "", "", http::status::not_found),
|
||||
std::make_tuple(http::verb::post, "/v1/models/foo/versions:predict", "", "", "", http::status::not_found),
|
||||
std::make_tuple(http::verb::post, "v1/models/foo/versions/12:predict", "", "", "", http::status::not_found),
|
||||
std::make_tuple(http::verb::post, "/v1/models/abc/versions/23:foo", "", "", "", http::status::not_found)};
|
||||
std::make_tuple(http::verb::post, "/v1/models/abc/versions/23:foo", "", "", "", http::status::not_found)
|
||||
};
|
||||
|
||||
run_route(predict_regex, http::verb::post, actions, false);
|
||||
}
|
||||
|
|
@ -69,11 +73,20 @@ TEST(HttpRouteTests, PostRouteInvalidMethodTest) {
|
|||
std::make_tuple(http::verb::get, "/v1/models/abc/versions/23:predict", "abc", "23", "predict", http::status::method_not_allowed),
|
||||
std::make_tuple(http::verb::put, "/v1/models", "", "", "", http::status::method_not_allowed),
|
||||
std::make_tuple(http::verb::delete_, "/v1/models", "", "", "", http::status::method_not_allowed),
|
||||
std::make_tuple(http::verb::head, "/v1/models", "", "", "", http::status::method_not_allowed)};
|
||||
std::make_tuple(http::verb::head, "/v1/models", "", "", "", http::status::method_not_allowed)
|
||||
};
|
||||
|
||||
run_route(predict_regex, http::verb::post, actions, false);
|
||||
}
|
||||
|
||||
TEST(HttpRouteTests, PostRouteSpecialMethodTest){
|
||||
std::vector<test_data> actions{
|
||||
std::make_tuple(http::verb::post, "/score", "", "", "", http::status::ok)
|
||||
};
|
||||
|
||||
run_route(R"(/score()()())", http::verb::post, actions, true);
|
||||
}
|
||||
|
||||
void run_route(const std::string& pattern, http::verb method, const std::vector<test_data>& data, bool does_validate_data) {
|
||||
Routes routes;
|
||||
EXPECT_TRUE(routes.RegisterController(method, pattern, do_something));
|
||||
|
|
@ -92,11 +105,11 @@ void run_route(const std::string& pattern, http::verb method, const std::vector<
|
|||
http::status expected_status;
|
||||
|
||||
std::tie(test_method, url_string, expected_name, expected_version, expected_action, expected_status) = i;
|
||||
EXPECT_EQ(expected_status, routes.ParseUrl(test_method, url_string, name, version, action, fn));
|
||||
EXPECT_EQ(expected_status, routes.ParseUrl(test_method, url_string, name, version, action, fn)) << "On route " << url_string;
|
||||
if (does_validate_data) {
|
||||
EXPECT_EQ(name, expected_name);
|
||||
EXPECT_EQ(version, expected_version);
|
||||
EXPECT_EQ(action, expected_action);
|
||||
EXPECT_EQ(name, expected_name) << "On route " << url_string;
|
||||
EXPECT_EQ(version, expected_version) << "On route " << url_string;
|
||||
EXPECT_EQ(action, expected_action) << "On route " << url_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue