@@ -102,8 +102,10 @@ TEST_CASE("profile_data_exporter: ConvertToJson")
102102 std::vector<Experiment> experiments{experiment};
103103
104104 std::string version{" 1.2.3" };
105+ cb::BackendKind service_kind = cb::BackendKind::TRITON;
106+ std::string endpoint{" " };
105107
106- exporter.ConvertToJson (experiments, version);
108+ exporter.ConvertToJson (experiments, version, service_kind, endpoint );
107109
108110 std::string json{R"(
109111 {
@@ -125,7 +127,9 @@ TEST_CASE("profile_data_exporter: ConvertToJson")
125127 "window_boundaries" : [ 1, 5, 6 ]
126128 }
127129 ],
128- "version" : "1.2.3"
130+ "version" : "1.2.3",
131+ "service_kind": "triton",
132+ "endpoint": ""
129133 }
130134 )" };
131135
@@ -244,4 +248,80 @@ TEST_CASE("profile_data_exporter: OutputToFile")
244248 }
245249}
246250
251+ TEST_CASE (" profile_data_exporter: AddServiceKind" )
252+ {
253+ MockProfileDataExporter exporter{};
254+ exporter.ClearDocument ();
255+
256+ cb::BackendKind service_kind;
257+ std::string json{" " };
258+
259+ SUBCASE (" Backend kind: TRITON" )
260+ {
261+ service_kind = cb::BackendKind::TRITON;
262+ json = R"( { "service_kind": "triton" })" ;
263+ }
264+
265+ SUBCASE (" Backend kind: TENSORFLOW_SERVING" )
266+ {
267+ service_kind = cb::BackendKind::TENSORFLOW_SERVING;
268+ json = R"( { "service_kind": "tfserving" })" ;
269+ }
270+
271+ SUBCASE (" Backend kind: TORCHSERVE" )
272+ {
273+ service_kind = cb::BackendKind::TORCHSERVE;
274+ json = R"( { "service_kind": "torchserve" })" ;
275+ }
276+
277+ SUBCASE (" Backend kind: TRITON_C_API" )
278+ {
279+ service_kind = cb::BackendKind::TRITON_C_API;
280+ json = R"( { "service_kind": "triton_c_api" })" ;
281+ }
282+
283+ SUBCASE (" Backend kind: OPENAI" )
284+ {
285+ service_kind = cb::BackendKind::OPENAI;
286+ json = R"( { "service_kind": "openai" })" ;
287+ }
288+
289+ exporter.AddServiceKind (service_kind);
290+ rapidjson::Document expected_document;
291+ expected_document.Parse (json.c_str ());
292+
293+ const rapidjson::Value& expected_kind{expected_document[" service_kind" ]};
294+ const rapidjson::Value& actual_kind{exporter.document_ [" service_kind" ]};
295+ CHECK (actual_kind == expected_kind);
296+ }
297+
298+ TEST_CASE (" profile_data_exporter: AddEndpoint" )
299+ {
300+ MockProfileDataExporter exporter{};
301+ exporter.ClearDocument ();
302+
303+ std::string endpoint{" " };
304+ std::string json{" " };
305+
306+ SUBCASE (" Endpoint: OpenAI Chat Completions" )
307+ {
308+ endpoint = " v1/chat/completions" ;
309+ json = R"( { "endpoint": "v1/chat/completions" })" ;
310+ }
311+
312+ SUBCASE (" Endpoint: OpenAI Completions" )
313+ {
314+ endpoint = " v1/completions" ;
315+ json = R"( { "endpoint": "v1/completions" })" ;
316+ }
317+
318+ exporter.AddEndpoint (endpoint);
319+ rapidjson::Document expected_document;
320+ expected_document.Parse (json.c_str ());
321+
322+ const rapidjson::Value& expected_endpoint{expected_document[" endpoint" ]};
323+ const rapidjson::Value& actual_endpoint{exporter.document_ [" endpoint" ]};
324+ CHECK (actual_endpoint == expected_endpoint);
325+ }
326+
247327}} // namespace triton::perfanalyzer
0 commit comments