TensorFlow Serving C++ API Documentation
manager_test_util.h
1 /* Copyright 2016 Google Inc. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7  http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_SERVING_CORE_TEST_UTIL_MANAGER_TEST_UTIL_H_
17 #define TENSORFLOW_SERVING_CORE_TEST_UTIL_MANAGER_TEST_UTIL_H_
18 
19 #include "tensorflow_serving/core/aspired_versions_manager.h"
20 #include "tensorflow_serving/core/caching_manager.h"
21 
22 namespace tensorflow {
23 namespace serving {
24 namespace test_util {
25 
26 // A test utility that provides access to private AspiredVersionsManager
27 // members.
29  public:
31 
32  // Invokes FlushServables() on the manager.
33  void FlushServables();
34 
35  // Invokes HandlePendingAspiredVersionsRequests() on the manager.
36  void HandlePendingAspiredVersionsRequests();
37 
38  // Invokes InvokePolicyAndExecuteAction() on the manager.
39  void InvokePolicyAndExecuteAction();
40 
41  void SetNumLoadThreads(uint32 num_load_threads);
42 
43  uint32 num_load_threads() const;
44 
45  void SetCustomSortActions(
46  AspiredVersionsManager::CustomSortActionsFn custom_sort_actions);
47 
48  private:
49  AspiredVersionsManager* const manager_;
50 
51  TF_DISALLOW_COPY_AND_ASSIGN(AspiredVersionsManagerTestAccess);
52 };
53 
54 // A test utility that provides access to private BasicManager members.
56  public:
57  explicit BasicManagerTestAccess(BasicManager* manager);
58 
59  void SetNumLoadThreads(uint32 num_load_threads);
60 
61  uint32 num_load_threads() const;
62 
63  private:
64  BasicManager* const manager_;
65 
66  TF_DISALLOW_COPY_AND_ASSIGN(BasicManagerTestAccess);
67 };
68 
69 // A test utility that provides access to private CachingManager members.
71  public:
72  explicit CachingManagerTestAccess(CachingManager* manager);
73 
74  // Returns the size of the load-mutex map that stores the mutex reference per
75  // servable-id requested for load.
76  int64_t GetLoadMutexMapSize() const;
77 
78  private:
79  CachingManager* const manager_;
80 
81  TF_DISALLOW_COPY_AND_ASSIGN(CachingManagerTestAccess);
82 };
83 
84 } // namespace test_util
85 } // namespace serving
86 } // namespace tensorflow
87 
88 #endif // TENSORFLOW_SERVING_CORE_TEST_UTIL_MANAGER_TEST_UTIL_H_