Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Tensorflow Serving Server Core Test

From Leeroopedia
Knowledge Sources
Domains Testing, Model Server Management
Last Updated 2026-02-13 00:00 GMT

Overview

Test suite validating the ServerCore component, the central orchestrator responsible for model lifecycle management, configuration reloading, multi-platform support, and request routing.

Description

This test file exercises the ServerCore class using a parameterized test fixture (ServerCoreTest) provided by test_util::ServerCoreTest. A secondary fixture RelativePathsServerCoreTest validates path handling. Tests cover the full breadth of ServerCore functionality: pre-load hooks, model availability after creation, configuration reloading (adding, removing, and changing models), error model handling, illegal reconfigurations, duplicate model names, unknown platforms, multi-platform setups, request logging, version label assignment, and storage path prefix options.

Usage

Run these tests to validate that ServerCore correctly manages model lifecycles, enforces configuration constraints, supports multi-platform serving, and handles version labeling and path resolution policies.

Code Reference

Source Location

  • Repository: Tensorflow_Serving
  • File: tensorflow_serving/model_servers/server_core_test.cc
  • Lines: 1-999

Test Fixture

// Uses parameterized fixture from test utilities
using test_util::ServerCoreTest;

TEST_P(ServerCoreTest, CreateWaitsTillModelsAvailable) {
  std::unique_ptr<ServerCore> server_core;
  TF_ASSERT_OK(CreateServerCore(
      GetTestModelServerConfigForFakePlatform(), &server_core));
  const std::vector<ServableId> available_servables =
      server_core->ListAvailableServableIds();
  ASSERT_EQ(available_servables.size(), 1);
  // ...
}

Build Target

bazel test //tensorflow_serving/model_servers:server_core_test

Test Coverage

Key Test Cases

Test Name Category Description
PreLoadHook Hooks Verifies pre-load hook is called with correct ServableId before loading
CreateWaitsTillModelsAvailable Initialization Ensures ServerCore::Create blocks until all models are available
ReloadConfigWaitsTillModelsAvailable Configuration Validates ReloadConfig blocks until newly configured models are available
ReloadConfigUnloadsModels Configuration Confirms models are unloaded when removed from config
ReloadConfigHandlesLoadingAPreviouslyUnloadedModel Configuration Tests re-adding a previously unloaded model
ReloadConfigChangeModelBasePath Configuration Validates changing a model's base path via config reload
AbsolutePathSucceeds Path Handling Verifies absolute model paths are accepted
RelativePathFails Path Handling Verifies relative model paths are rejected by default
RelativePathWithOptionsSucceeds Path Handling Tests that relative paths succeed when option is enabled
ErroringModel Error Handling Tests behavior when a model fails to load
IllegalReconfigurationToCustomConfig Validation Prevents switching from model_config_list to custom config
IllegalReconfigurationFromCustomConfig Validation Prevents switching from custom config to model_config_list
DuplicateModelNameInConfig Validation Rejects configurations with duplicate model names
UnknownModelPlatform Validation Rejects configurations with unrecognized model platforms
MultiplePlatforms Multi-Platform Tests loading models from multiple serving platforms simultaneously
MultiplePlatformsWithConfigChange Multi-Platform Tests platform behavior across configuration changes
IllegalToChangeModelPlatform Validation Prevents changing a model's platform after initial load
RequestLoggingOff Logging Verifies no logging occurs when logging is not configured
RequestLoggingOn Logging Validates request logging is active when configured
ModelSpecMultipleVersionsAvailable Version Management Tests model spec resolution when multiple versions are loaded
AssignLabelToUnavailableVersion Version Labels Tests label assignment to unavailable versions (default: rejected)
AssignLabelToUnavailableVersionAllowed Version Labels Tests label assignment to unavailable versions when allowed
VersionLabelsNotAllowed Version Labels Validates version labels are rejected when not enabled
StoragePathPrefixOption Configuration Tests the storage path prefix option for model base paths

Usage Examples

Test Pattern

TEST_P(ServerCoreTest, CreateWaitsTillModelsAvailable) {
  std::unique_ptr<ServerCore> server_core;
  TF_ASSERT_OK(CreateServerCore(
      GetTestModelServerConfigForFakePlatform(), &server_core));

  const std::vector<ServableId> available_servables =
      server_core->ListAvailableServableIds();
  ASSERT_EQ(available_servables.size(), 1);
  const ServableId expected_id = {test_util::kTestModelName,
                                  test_util::kTestModelVersion};
  EXPECT_EQ(available_servables.at(0), expected_id);

  ModelSpec model_spec;
  model_spec.set_name(test_util::kTestModelName);
  model_spec.mutable_version()->set_value(test_util::kTestModelVersion);
  ServableHandle<string> servable_handle;
  TF_ASSERT_OK(
      server_core->GetServableHandle<string>(model_spec, &servable_handle));
  EXPECT_EQ(servable_handle.id(), expected_id);
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment