20
20
#include < gtest/gtest.h>
21
21
22
22
#include " test_utils.hpp"
23
- #include " ../filesystem.hpp"
24
- #include " ../status.hpp"
25
23
#include " ../capi_frontend/server_settings.hpp"
26
24
#include " ../graph_export/graph_export.hpp"
25
+ #include " ../filesystem.hpp"
26
+ #include " ../status.hpp"
27
+ #include " ../version.hpp"
27
28
28
29
const std::string expectedOneSettingPluginGraphContents = R"(
29
30
input_stream: "HTTP_REQUEST_PAYLOAD:input"
@@ -313,8 +314,77 @@ class GraphCreationTest : public TestWithTempDir {
313
314
void TearDown () {
314
315
TestWithTempDir::TearDown ();
315
316
}
317
+
318
+ // Removes # OpenVINO Model Server REPLACE_PROJECT_VERSION comment added for debug purpose in graph export at the begging of graph.pbtxt
319
+ // This string differs per build and setup
320
+ std::string removeVersionString (std::string input) {
321
+ return input.erase (0 , input.find (" \n " ) + 1 );
322
+ }
323
+
324
+ std::string getVersionString () {
325
+ std::stringstream expected;
326
+ expected << " # File created with: " << PROJECT_NAME << " " << PROJECT_VERSION << std::endl;
327
+ return expected.str ();
328
+ }
316
329
};
317
330
331
+ TEST_F (GraphCreationTest, positiveDefaultWithVersionString) {
332
+ ovms::HFSettingsImpl hfSettings;
333
+ std::string graphPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " graph.pbtxt" ;
334
+ std::unique_ptr<ovms::GraphExport> graphExporter = std::make_unique<ovms::GraphExport>();
335
+ auto status = graphExporter->createServableConfig (this ->directoryPath , hfSettings);
336
+ ASSERT_EQ (status, ovms::StatusCode::OK);
337
+
338
+ std::string graphContents = GetFileContents (graphPath);
339
+ std::string expected = getVersionString () + expectedDefaultGraphContents;
340
+ ASSERT_EQ (expected, graphContents) << graphContents;
341
+ }
342
+
343
+ TEST_F (GraphCreationTest, positiveReranktWithVersionString) {
344
+ ovms::HFSettingsImpl hfSettings;
345
+ hfSettings.task = ovms::RERANK_GRAPH;
346
+ ovms::RerankGraphSettingsImpl rerankGraphSettings;
347
+ hfSettings.graphSettings = std::move (rerankGraphSettings);
348
+ std::string graphPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " graph.pbtxt" ;
349
+ std::unique_ptr<ovms::GraphExport> graphExporter = std::make_unique<ovms::GraphExport>();
350
+ auto status = graphExporter->createServableConfig (this ->directoryPath , hfSettings);
351
+ ASSERT_EQ (status, ovms::StatusCode::OK);
352
+
353
+ std::string graphContents = GetFileContents (graphPath);
354
+ std::string expected = getVersionString () + expectedRerankGraphContentsDefault;
355
+ ASSERT_EQ (expected, graphContents) << graphContents;
356
+ }
357
+
358
+ TEST_F (GraphCreationTest, positiveEmbeddingsWithVersionString) {
359
+ ovms::HFSettingsImpl hfSettings;
360
+ hfSettings.task = ovms::EMBEDDINGS_GRAPH;
361
+ ovms::EmbeddingsGraphSettingsImpl embeddingsGraphSettings;
362
+ hfSettings.graphSettings = std::move (embeddingsGraphSettings);
363
+ std::string graphPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " graph.pbtxt" ;
364
+ std::unique_ptr<ovms::GraphExport> graphExporter = std::make_unique<ovms::GraphExport>();
365
+ auto status = graphExporter->createServableConfig (this ->directoryPath , hfSettings);
366
+ ASSERT_EQ (status, ovms::StatusCode::OK);
367
+
368
+ std::string graphContents = GetFileContents (graphPath);
369
+ std::string expected = getVersionString () + expectedEmbeddingsGraphContentsDefault;
370
+ ASSERT_EQ (expected, graphContents) << graphContents;
371
+ }
372
+
373
+ TEST_F (GraphCreationTest, positiveImageGenWithVersionString) {
374
+ ovms::HFSettingsImpl hfSettings;
375
+ hfSettings.task = ovms::IMAGE_GENERATION_GRAPH;
376
+ ovms::ImageGenerationGraphSettingsImpl imageGenerationGraphSettings;
377
+ hfSettings.graphSettings = std::move (imageGenerationGraphSettings);
378
+ std::string graphPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " graph.pbtxt" ;
379
+ std::unique_ptr<ovms::GraphExport> graphExporter = std::make_unique<ovms::GraphExport>();
380
+ auto status = graphExporter->createServableConfig (this ->directoryPath , hfSettings);
381
+ ASSERT_EQ (status, ovms::StatusCode::OK);
382
+
383
+ std::string graphContents = GetFileContents (graphPath);
384
+ std::string expected = getVersionString () + expectedImageGenerationGraphContentsDefault;
385
+ ASSERT_EQ (expected, graphContents) << graphContents;
386
+ }
387
+
318
388
TEST_F (GraphCreationTest, positiveDefault) {
319
389
ovms::HFSettingsImpl hfSettings;
320
390
std::string graphPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " graph.pbtxt" ;
@@ -323,7 +393,7 @@ TEST_F(GraphCreationTest, positiveDefault) {
323
393
ASSERT_EQ (status, ovms::StatusCode::OK);
324
394
325
395
std::string graphContents = GetFileContents (graphPath);
326
- ASSERT_EQ (expectedDefaultGraphContents, graphContents) << graphContents;
396
+ ASSERT_EQ (expectedDefaultGraphContents, removeVersionString ( graphContents) ) << graphContents;
327
397
}
328
398
329
399
TEST_F (GraphCreationTest, rerankPositiveNonDefault) {
@@ -338,13 +408,12 @@ TEST_F(GraphCreationTest, rerankPositiveNonDefault) {
338
408
hfSettings.graphSettings = std::move (rerankGraphSettings);
339
409
340
410
std::string graphPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " graph.pbtxt" ;
341
- std::string subconfigPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " subconfig.json" ;
342
411
std::unique_ptr<ovms::GraphExport> graphExporter = std::make_unique<ovms::GraphExport>();
343
412
auto status = graphExporter->createServableConfig (this ->directoryPath , hfSettings);
344
413
ASSERT_EQ (status, ovms::StatusCode::OK);
345
414
346
415
std::string graphContents = GetFileContents (graphPath);
347
- ASSERT_EQ (expectedRerankGraphContentsNonDefault, graphContents) << graphContents;
416
+ ASSERT_EQ (expectedRerankGraphContentsNonDefault, removeVersionString ( graphContents) ) << graphContents;
348
417
}
349
418
350
419
TEST_F (GraphCreationTest, rerankPositiveDefault) {
@@ -354,13 +423,12 @@ TEST_F(GraphCreationTest, rerankPositiveDefault) {
354
423
hfSettings.graphSettings = std::move (rerankGraphSettings);
355
424
356
425
std::string graphPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " graph.pbtxt" ;
357
- std::string subconfigPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " subconfig.json" ;
358
426
std::unique_ptr<ovms::GraphExport> graphExporter = std::make_unique<ovms::GraphExport>();
359
427
auto status = graphExporter->createServableConfig (this ->directoryPath , hfSettings);
360
428
ASSERT_EQ (status, ovms::StatusCode::OK);
361
429
362
430
std::string graphContents = GetFileContents (graphPath);
363
- ASSERT_EQ (expectedRerankGraphContentsDefault, graphContents) << graphContents;
431
+ ASSERT_EQ (expectedRerankGraphContentsDefault, removeVersionString ( graphContents) ) << graphContents;
364
432
}
365
433
366
434
TEST_F (GraphCreationTest, rerankCreatedPbtxtInvalid) {
@@ -372,7 +440,6 @@ TEST_F(GraphCreationTest, rerankCreatedPbtxtInvalid) {
372
440
rerankGraphSettings.numStreams = 2 ;
373
441
hfSettings.graphSettings = std::move (rerankGraphSettings);
374
442
std::string graphPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " graph.pbtxt" ;
375
- std::string subconfigPath = ovms::FileSystem::appendSlash (this ->directoryPath ) + " subconfig.json" ;
376
443
std::unique_ptr<ovms::GraphExport> graphExporter = std::make_unique<ovms::GraphExport>();
377
444
auto status = graphExporter->createServableConfig (this ->directoryPath , hfSettings);
378
445
#if (MEDIAPIPE_DISABLE == 0)
@@ -399,7 +466,7 @@ TEST_F(GraphCreationTest, embeddingsPositiveNonDefault) {
399
466
ASSERT_EQ (status, ovms::StatusCode::OK);
400
467
401
468
std::string graphContents = GetFileContents (graphPath);
402
- ASSERT_EQ (expectedEmbeddingsGraphContents, graphContents) << graphContents;
469
+ ASSERT_EQ (expectedEmbeddingsGraphContents, removeVersionString ( graphContents) ) << graphContents;
403
470
}
404
471
405
472
TEST_F (GraphCreationTest, embeddingsPositiveDefault) {
@@ -413,7 +480,7 @@ TEST_F(GraphCreationTest, embeddingsPositiveDefault) {
413
480
ASSERT_EQ (status, ovms::StatusCode::OK);
414
481
415
482
std::string graphContents = GetFileContents (graphPath);
416
- ASSERT_EQ (expectedEmbeddingsGraphContentsDefault, graphContents) << graphContents;
483
+ ASSERT_EQ (expectedEmbeddingsGraphContentsDefault, removeVersionString ( graphContents) ) << graphContents;
417
484
}
418
485
419
486
TEST_F (GraphCreationTest, embeddingsCreatedPbtxtInvalid) {
@@ -450,7 +517,7 @@ TEST_F(GraphCreationTest, positivePluginConfigAll) {
450
517
ASSERT_EQ (status, ovms::StatusCode::OK);
451
518
452
519
std::string graphContents = GetFileContents (graphPath);
453
- ASSERT_EQ (expectedFullPluginGraphContents, graphContents) << graphContents;
520
+ ASSERT_EQ (expectedFullPluginGraphContents, removeVersionString ( graphContents) ) << graphContents;
454
521
}
455
522
456
523
TEST_F (GraphCreationTest, positiveWithParsersAndToolGuidedGeneration) {
@@ -468,7 +535,7 @@ TEST_F(GraphCreationTest, positiveWithParsersAndToolGuidedGeneration) {
468
535
ASSERT_EQ (status, ovms::StatusCode::OK);
469
536
470
537
std::string graphContents = GetFileContents (graphPath);
471
- ASSERT_EQ (expectedGraphContentsWithResponseParser, graphContents) << graphContents;
538
+ ASSERT_EQ (expectedGraphContentsWithResponseParser, removeVersionString ( graphContents) ) << graphContents;
472
539
}
473
540
474
541
TEST_F (GraphCreationTest, positivePluginConfigOne) {
@@ -483,7 +550,7 @@ TEST_F(GraphCreationTest, positivePluginConfigOne) {
483
550
ASSERT_EQ (status, ovms::StatusCode::OK);
484
551
485
552
std::string graphContents = GetFileContents (graphPath);
486
- ASSERT_EQ (expectedOneSettingPluginGraphContents, graphContents) << graphContents;
553
+ ASSERT_EQ (expectedOneSettingPluginGraphContents, removeVersionString ( graphContents) ) << graphContents;
487
554
}
488
555
489
556
TEST_F (GraphCreationTest, negativeCreateFileWrongDirectoryPaths) {
@@ -551,7 +618,7 @@ TEST_F(GraphCreationTest, imageGenerationPositiveDefault) {
551
618
ASSERT_EQ (status, ovms::StatusCode::OK);
552
619
553
620
std::string graphContents = GetFileContents (graphPath);
554
- ASSERT_EQ (expectedImageGenerationGraphContentsDefault, graphContents) << graphContents;
621
+ ASSERT_EQ (expectedImageGenerationGraphContentsDefault, removeVersionString ( graphContents) ) << graphContents;
555
622
}
556
623
557
624
TEST_F (GraphCreationTest, imageGenerationPositiveFull) {
@@ -572,5 +639,5 @@ TEST_F(GraphCreationTest, imageGenerationPositiveFull) {
572
639
ASSERT_EQ (status, ovms::StatusCode::OK);
573
640
574
641
std::string graphContents = GetFileContents (graphPath);
575
- ASSERT_EQ (expectedImageGenerationGraphContents, graphContents) << graphContents;
642
+ ASSERT_EQ (expectedImageGenerationGraphContents, removeVersionString ( graphContents) ) << graphContents;
576
643
}
0 commit comments