Skip to content

Commit 88e342d

Browse files
authored
Fix flaky flight tests (#115)
1 parent b9c2ae8 commit 88e342d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

test/Apache.Arrow.Flight.Tests/FlightTests.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,12 @@ public async Task EnsureCallRaisesDeadlineExceeded()
478478
RpcException exception = null;
479479

480480
var asyncServerStreamingCallFlights = _flightClient.ListFlights(null, null, deadline);
481-
Assert.Equal(StatusCode.DeadlineExceeded, asyncServerStreamingCallFlights.GetStatus().StatusCode);
481+
exception = await Assert.ThrowsAsync<RpcException>(async () => await asyncServerStreamingCallFlights.ResponseStream.ToListAsync());
482+
Assert.Equal(StatusCode.DeadlineExceeded, exception.StatusCode);
482483

483484
var asyncServerStreamingCallActions = _flightClient.ListActions(null, deadline);
484-
Assert.Equal(StatusCode.DeadlineExceeded, asyncServerStreamingCallFlights.GetStatus().StatusCode);
485+
exception = await Assert.ThrowsAsync<RpcException>(async () => await asyncServerStreamingCallActions.ResponseStream.ToListAsync());
486+
Assert.Equal(StatusCode.DeadlineExceeded, exception.StatusCode);
485487

486488
GivenStoreBatches(flightDescriptor, new RecordBatchWithMetadata(batch));
487489
exception = await Assert.ThrowsAsync<RpcException>(async () => await _flightClient.GetInfo(flightDescriptor, null, deadline));
@@ -490,7 +492,8 @@ public async Task EnsureCallRaisesDeadlineExceeded()
490492
var flightInfo = await _flightClient.GetInfo(flightDescriptor);
491493
var endpoint = flightInfo.Endpoints.FirstOrDefault();
492494
var getStream = _flightClient.GetStream(endpoint.Ticket, null, deadline);
493-
Assert.Equal(StatusCode.DeadlineExceeded, getStream.GetStatus().StatusCode);
495+
exception = await Assert.ThrowsAsync<RpcException>(async () => await getStream.ResponseStream.ToListAsync());
496+
Assert.Equal(StatusCode.DeadlineExceeded, exception.StatusCode);
494497

495498
var duplexStreamingCall = _flightClient.DoExchange(flightDescriptor, null, deadline);
496499
exception = await Assert.ThrowsAsync<RpcException>(async () => await duplexStreamingCall.RequestStream.WriteAsync(batch));
@@ -514,16 +517,17 @@ public async Task EnsureCallRaisesRequestCancelled()
514517
cts.CancelAfter(1);
515518

516519
var batch = CreateTestBatch(0, 100);
517-
var metadata = new Metadata();
518520
var flightDescriptor = FlightDescriptor.CreatePathDescriptor("raise_cancelled");
519521
await Task.Delay(5);
520522
RpcException exception = null;
521523

522524
var asyncServerStreamingCallFlights = _flightClient.ListFlights(null, null, null, cts.Token);
523-
Assert.Equal(StatusCode.Cancelled, asyncServerStreamingCallFlights.GetStatus().StatusCode);
525+
exception = await Assert.ThrowsAsync<RpcException>(async () => await asyncServerStreamingCallFlights.ResponseStream.ToListAsync());
526+
Assert.Equal(StatusCode.Cancelled, exception.StatusCode);
524527

525528
var asyncServerStreamingCallActions = _flightClient.ListActions(null, null, cts.Token);
526-
Assert.Equal(StatusCode.Cancelled, asyncServerStreamingCallFlights.GetStatus().StatusCode);
529+
exception = await Assert.ThrowsAsync<RpcException>(async () => await asyncServerStreamingCallActions.ResponseStream.ToListAsync());
530+
Assert.Equal(StatusCode.Cancelled, exception.StatusCode);
527531

528532
GivenStoreBatches(flightDescriptor, new RecordBatchWithMetadata(batch));
529533
exception = await Assert.ThrowsAsync<RpcException>(async () => await _flightClient.GetInfo(flightDescriptor, null, null, cts.Token));
@@ -532,7 +536,8 @@ public async Task EnsureCallRaisesRequestCancelled()
532536
var flightInfo = await _flightClient.GetInfo(flightDescriptor);
533537
var endpoint = flightInfo.Endpoints.FirstOrDefault();
534538
var getStream = _flightClient.GetStream(endpoint.Ticket, null, null, cts.Token);
535-
Assert.Equal(StatusCode.Cancelled, getStream.GetStatus().StatusCode);
539+
exception = await Assert.ThrowsAsync<RpcException>(async () => await getStream.ResponseStream.ToListAsync());
540+
Assert.Equal(StatusCode.Cancelled, exception.StatusCode);
536541

537542
var duplexStreamingCall = _flightClient.DoExchange(flightDescriptor, null, null, cts.Token);
538543
exception = await Assert.ThrowsAsync<RpcException>(async () => await duplexStreamingCall.RequestStream.WriteAsync(batch));

0 commit comments

Comments
 (0)