| 824 | } |
| 825 | |
| 826 | void DoPutTest::TestSizeLimit() { |
| 827 | const int64_t size_limit = 4096; |
| 828 | ASSERT_OK_AND_ASSIGN(auto location, |
| 829 | Location::ForScheme(transport(), "127.0.0.1", server_->port())); |
| 830 | auto client_options = FlightClientOptions::Defaults(); |
| 831 | client_options.write_size_limit_bytes = size_limit; |
| 832 | ASSERT_OK_AND_ASSIGN(auto client, FlightClient::Connect(location, client_options)); |
| 833 | |
| 834 | auto descr = FlightDescriptor::Command("simple"); |
| 835 | // Batch is too large to fit in one message |
| 836 | auto schema = arrow::schema({field("f1", arrow::int64())}); |
| 837 | auto batch = arrow::ConstantArrayGenerator::Zeroes(768, schema); |
| 838 | auto batch1 = batch->Slice(0, 384); |
| 839 | auto batch2 = batch->Slice(384); |
| 840 | |
| 841 | ASSERT_OK_AND_ASSIGN(auto do_put_result, client->DoPut(descr, schema)); |
| 842 | std::unique_ptr<FlightStreamWriter> writer = std::move(do_put_result.writer); |
| 843 | std::unique_ptr<FlightMetadataReader> reader = std::move(do_put_result.reader); |
| 844 | |
| 845 | // Large batch will exceed the limit |
| 846 | const auto status = writer->WriteRecordBatch(*batch); |
| 847 | EXPECT_RAISES_WITH_MESSAGE_THAT(Invalid, ::testing::HasSubstr("exceeded soft limit"), |
| 848 | status); |
| 849 | auto detail = FlightWriteSizeStatusDetail::UnwrapStatus(status); |
| 850 | ASSERT_NE(nullptr, detail); |
| 851 | ASSERT_EQ(size_limit, detail->limit()); |
| 852 | ASSERT_GT(detail->actual(), size_limit); |
| 853 | |
| 854 | // But we can retry with smaller batches |
| 855 | ASSERT_OK(writer->WriteRecordBatch(*batch1)); |
| 856 | ASSERT_OK(writer->WriteWithMetadata(*batch2, Buffer::FromString("1"))); |
| 857 | |
| 858 | // Write a metadata-only message |
| 859 | ASSERT_OK(writer->WriteMetadata(Buffer::FromString(kExpectedMetadata))); |
| 860 | |
| 861 | ASSERT_OK(writer->DoneWriting()); |
| 862 | ASSERT_OK(writer->Close()); |
| 863 | CheckBatches(descr, {batch1, batch2}); |
| 864 | } |
| 865 | void DoPutTest::TestUndrained() { |
| 866 | // Ensure if the application doesn't drain all messages, that the |
| 867 | // server/transport does |
nothing calls this directly
no test coverage detected