1# Copyright 2017 The TensorFlow Authors. 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"""Tests for tf.GrpcServer.""" 16 17from __future__ import absolute_import 18from __future__ import division 19from __future__ import print_function 20 21from tensorflow.python.client import session 22from tensorflow.python.framework import constant_op 23from tensorflow.python.framework import ops 24from tensorflow.python.platform import test 25from tensorflow.python.training import server_lib 26 27 28class SparseJobTest(test.TestCase): 29 30 # TODO(b/34465411): Starting multiple servers with different configurations 31 # in the same test is flaky. Move this test case back into 32 # "server_lib_test.py" when this is no longer the case. 33 def testSparseJob(self): 34 server = server_lib.Server({"local": {37: "localhost:0"}}) 35 with ops.device("/job:local/task:37"): 36 a = constant_op.constant(1.0) 37 38 with session.Session(server.target) as sess: 39 self.assertEqual(1.0, sess.run(a)) 40 41 42if __name__ == "__main__": 43 test.main() 44