16 #ifndef TENSORFLOW_SERVING_MODEL_SERVERS_TEST_UTIL_SERVER_CORE_TEST_UTIL_H_
17 #define TENSORFLOW_SERVING_MODEL_SERVERS_TEST_UTIL_SERVER_CORE_TEST_UTIL_H_
22 #include <gtest/gtest.h>
23 #include "tensorflow_serving/core/servable_id.h"
24 #include "tensorflow_serving/model_servers/server_core.h"
26 namespace tensorflow {
41 constexpr
char kTestModelName[] =
"test_model";
42 constexpr
int kTestModelVersion = 123;
43 constexpr
int kTestModelLargerVersion = 124;
44 constexpr
int kTestModelBogusVersion = 777;
45 constexpr std::array<int64_t, 2> kAspiredVersions = {kTestModelVersion,
46 kTestModelLargerVersion};
48 constexpr
char kFakePlatform[] =
"fake_servable";
53 class ServerCoreTest :
public ::testing::TestWithParam<std::tuple<int, bool>> {
58 SAVED_MODEL_BACKWARD_COMPATIBILITY,
65 static string GetNameOfTestType(
int test_type) {
66 switch (
static_cast<TestType
>(test_type)) {
67 case SAVED_MODEL_BACKWARD_COMPATIBILITY:
68 return "SAVED_MODEL_BACKWARD_COMPATIBILITY";
81 ModelServerConfig GetTestModelServerConfigForFakePlatform();
85 ModelServerConfig GetTestModelServerConfigForTensorflowPlatform();
89 void SwitchToHalfPlusTwoWith2Versions(ModelServerConfig* config);
93 Status CreateServerCore(
const ModelServerConfig& config,
95 std::unique_ptr<ServerCore>* server_core);
99 Status CreateServerCore(
const ModelServerConfig& config,
100 std::unique_ptr<ServerCore>* server_core) {
101 return CreateServerCore(config, GetDefaultOptions(), server_core);
106 TestType GetTestType() {
107 return static_cast<TestType
>(std::get<0>(GetParam()));
112 bool PrefixPathsWithURIScheme() {
return std::get<1>(GetParam()); }
115 string GetNameForTestCase() {
116 return GetNameOfTestType(GetTestType()) +
"_" +
117 (PrefixPathsWithURIScheme() ?
"URI" :
"Path");
122 Status CreateServerCore(
const ModelServerConfig& config,
124 std::unique_ptr<ServerCore>* server_core);
127 Status CreateServerCore(
const ModelServerConfig& config,
128 std::unique_ptr<ServerCore>* server_core);
137 (*config_->mutable_version_labels())[label] = version;
142 ModelConfig* config_;
147 config->mutable_model_config_list()->mutable_config(0));
Options for configuring a ServerCore object.