| 269 | TEST(TestFlight, ServerCallContextIncomingHeaders) { |
| 270 | auto server = TestFlightServer::Make(); |
| 271 | ASSERT_OK_AND_ASSIGN(auto location, Location::ForGrpcTcp("localhost", 0)); |
| 272 | FlightServerOptions options(location); |
| 273 | ASSERT_OK(server->Init(options)); |
| 274 | |
| 275 | ASSERT_OK_AND_ASSIGN(auto client, FlightClient::Connect(server->location())); |
| 276 | Action action; |
| 277 | action.type = "list-incoming-headers"; |
| 278 | action.body = Buffer::FromString("test-header"); |
| 279 | FlightCallOptions call_options; |
| 280 | call_options.headers.emplace_back("test-header1", "value1"); |
| 281 | call_options.headers.emplace_back("test-header2", "value2"); |
| 282 | ASSERT_OK_AND_ASSIGN(auto stream, client->DoAction(call_options, action)); |
| 283 | ASSERT_OK_AND_ASSIGN(auto result, stream->Next()); |
| 284 | ASSERT_NE(result.get(), nullptr); |
| 285 | ASSERT_EQ(result->body->ToString(), "test-header1: value1"); |
| 286 | ASSERT_OK_AND_ASSIGN(result, stream->Next()); |
| 287 | ASSERT_NE(result.get(), nullptr); |
| 288 | ASSERT_EQ(result->body->ToString(), "test-header2: value2"); |
| 289 | ASSERT_OK_AND_ASSIGN(result, stream->Next()); |
| 290 | ASSERT_EQ(result.get(), nullptr); |
| 291 | } |
| 292 | |
| 293 | // ---------------------------------------------------------------------- |
| 294 | // Client tests |
| 295 | |
| 296 | class TestFlightClient : public ::testing::Test { |
| 297 | public: |
| 298 | void SetUp() { |
| 299 | server_ = TestFlightServer::Make(); |
| 300 | |
| 301 | ASSERT_OK_AND_ASSIGN(auto location, Location::ForGrpcTcp("localhost", 0)); |
| 302 | FlightServerOptions options(location); |
| 303 | ASSERT_OK(server_->Init(options)); |
| 304 | |
| 305 | ASSERT_OK(ConnectClient()); |
| 306 | } |
| 307 | |
| 308 | void TearDown() { |
| 309 | ASSERT_OK(client_->Close()); |
| 310 | ASSERT_OK(server_->Shutdown()); |
| 311 | } |
| 312 | |
| 313 | Status ConnectClient() { |
| 314 | ARROW_ASSIGN_OR_RAISE(auto location, |
| 315 | Location::ForGrpcTcp("localhost", server_->port())); |
| 316 | return FlightClient::Connect(location).Value(&client_); |
| 317 | } |
| 318 | |
| 319 | template <typename EndpointCheckFunc> |
| 320 | void CheckDoGet(const FlightDescriptor& descr, |
| 321 | const RecordBatchVector& expected_batches, |
| 322 | EndpointCheckFunc&& check_endpoints) { |
| 323 | auto expected_schema = expected_batches[0]->schema(); |
| 324 | |
| 325 | ASSERT_OK_AND_ASSIGN(auto info, client_->GetFlightInfo(descr)); |
| 326 | check_endpoints(info->endpoints()); |
| 327 | |
| 328 | ipc::DictionaryMemo dict_memo; |
no test coverage detected