Test some connection basics using XrtGrpcEagerClient directly.
| 64 | |
| 65 | // Test some connection basics using XrtGrpcEagerClient directly. |
| 66 | TEST_F(XrtClientTest, XrtGrpcEagerClientWorks) { |
| 67 | ChannelCreationFunction channel_func = |
| 68 | ConvertToChannelCreationFunction(NewHostPortGrpcChannel); |
| 69 | TF_ASSERT_OK_AND_ASSIGN(std::shared_ptr<GrpcChannelCache> channel_cache, |
| 70 | GetGrpcChannelCache(cluster_def_, channel_func)); |
| 71 | XrtGrpcEagerClientCache client_cache(channel_cache); |
| 72 | |
| 73 | TF_ASSERT_OK_AND_ASSIGN( |
| 74 | XrtGrpcEagerClient * client, |
| 75 | client_cache.GetClient("/job:localhost/task:0/replica:0")); |
| 76 | |
| 77 | // Create and destroy a context to verify we can make RPCs. |
| 78 | eager::CreateContextRequest request; |
| 79 | uint64 context_id = random::New64(); |
| 80 | ServerDef* server_def = request.mutable_server_def(); |
| 81 | *server_def->mutable_cluster() = cluster_def_; |
| 82 | server_def->set_job_name("localhost"); |
| 83 | server_def->set_protocol("grpc"); |
| 84 | request.set_keep_alive_secs(60); |
| 85 | request.set_context_id(context_id); |
| 86 | |
| 87 | eager::CreateContextResponse create_response; |
| 88 | TF_ASSERT_OK(client->SyncCall(&XrtGrpcEagerClient::CreateContextAsync, |
| 89 | &request, &create_response)); |
| 90 | |
| 91 | eager::CloseContextRequest close_request; |
| 92 | close_request.set_context_id(context_id); |
| 93 | |
| 94 | eager::CloseContextResponse close_response; |
| 95 | TF_ASSERT_OK(client->SyncCall(&XrtGrpcEagerClient::CloseContextAsync, |
| 96 | &close_request, &close_response)); |
| 97 | } |
| 98 | |
| 99 | // Tests that we can connect to a server using the higher-level XrtTfClient API, |
| 100 | // transfer tensors to the device, run an Add operator, and retrieve the result. |
no test coverage detected