Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 560406006
  • Loading branch information
tensorflower-gardener authored and tensorflow-copybara committed Aug 27, 2023
1 parent 07f9ba5 commit ba44e06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions tensorflow_serving/model_servers/test_util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ cc_library(
"//visibility:public",
],
deps = [
"//tensorflow_serving/apis:logging_cc_proto",
"//tensorflow_serving/apis:model_cc_proto",
"//tensorflow_serving/config:model_server_config_cc_proto",
"//tensorflow_serving/config:platform_config_cc_proto",
Expand Down
19 changes: 15 additions & 4 deletions tensorflow_serving/model_servers/test_util/mock_server_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.

#include <memory>
#include <string>
#include <utility>

#include "base/logging.h"
#include "google/protobuf/any.pb.h"
Expand Down Expand Up @@ -56,7 +57,9 @@ class MockServerCore : public ServerCore {
return platform_config_map;
}

static Options GetOptions(const PlatformConfigMap& platform_config_map) {
static Options GetOptions(
const PlatformConfigMap& platform_config_map,
std::unique_ptr<ServerRequestLogger> server_request_logger) {
Options options;
options.platform_config_map = platform_config_map;
options.servable_state_monitor_creator =
Expand All @@ -71,13 +74,21 @@ class MockServerCore : public ServerCore {
UniquePtrWithDeps<AspiredVersionsManager>* manager) -> Status {
return Status();
};
TF_CHECK_OK(
ServerRequestLogger::Create(nullptr, &options.server_request_logger));
if (server_request_logger != nullptr) {
options.server_request_logger = std::move(server_request_logger);
} else {
TF_CHECK_OK(
ServerRequestLogger::Create(nullptr, &options.server_request_logger));
}
return options;
}

explicit MockServerCore(const PlatformConfigMap& platform_config_map)
: ServerCore(GetOptions(platform_config_map)) {}
: MockServerCore(platform_config_map, nullptr) {}
MockServerCore(const PlatformConfigMap& platform_config_map,
std::unique_ptr<ServerRequestLogger> server_request_logger)
: ServerCore(GetOptions(platform_config_map,
std::move(server_request_logger))) {}

MOCK_METHOD(ServableStateMonitor*, servable_state_monitor, (),
(const, override));
Expand Down

0 comments on commit ba44e06

Please sign in to comment.