@@ -344,6 +344,45 @@ public void testExecuteStreamingPartitionedUpdateUnexpectedEOS() {
344
344
Mockito .eq (executeRequestWithResumeToken ), anyMap (), any (Duration .class ));
345
345
}
346
346
347
+ @ Test
348
+ public void testExecuteStreamingPartitionedUpdateRSTstream () {
349
+ ResultSetStats stats = ResultSetStats .newBuilder ().setRowCountLowerBound (1000L ).build ();
350
+ PartialResultSet p1 = PartialResultSet .newBuilder ().setResumeToken (resumeToken ).build ();
351
+ PartialResultSet p2 = PartialResultSet .newBuilder ().setStats (stats ).build ();
352
+ ServerStream <PartialResultSet > stream1 = mock (ServerStream .class );
353
+ Iterator <PartialResultSet > iterator = mock (Iterator .class );
354
+ when (iterator .hasNext ()).thenReturn (true , true , false );
355
+ when (iterator .next ())
356
+ .thenReturn (p1 )
357
+ .thenThrow (
358
+ new InternalException (
359
+ "INTERNAL: stream terminated by RST_STREAM." ,
360
+ null ,
361
+ GrpcStatusCode .of (Code .INTERNAL ),
362
+ true ));
363
+ when (stream1 .iterator ()).thenReturn (iterator );
364
+ ServerStream <PartialResultSet > stream2 = mock (ServerStream .class );
365
+ when (stream2 .iterator ()).thenReturn (ImmutableList .of (p1 , p2 ).iterator ());
366
+ when (rpc .executeStreamingPartitionedDml (
367
+ Mockito .eq (executeRequestWithoutResumeToken ), anyMap (), any (Duration .class )))
368
+ .thenReturn (stream1 );
369
+ when (rpc .executeStreamingPartitionedDml (
370
+ Mockito .eq (executeRequestWithResumeToken ), anyMap (), any (Duration .class )))
371
+ .thenReturn (stream2 );
372
+
373
+ PartitionedDmlTransaction tx = new PartitionedDmlTransaction (session , rpc , ticker );
374
+ long count = tx .executeStreamingPartitionedUpdate (Statement .of (sql ), Duration .ofMinutes (10 ));
375
+
376
+ assertThat (count ).isEqualTo (1000L );
377
+ verify (rpc ).beginTransaction (any (BeginTransactionRequest .class ), anyMap ());
378
+ verify (rpc )
379
+ .executeStreamingPartitionedDml (
380
+ Mockito .eq (executeRequestWithoutResumeToken ), anyMap (), any (Duration .class ));
381
+ verify (rpc )
382
+ .executeStreamingPartitionedDml (
383
+ Mockito .eq (executeRequestWithResumeToken ), anyMap (), any (Duration .class ));
384
+ }
385
+
347
386
@ Test
348
387
public void testExecuteStreamingPartitionedUpdateGenericInternalException () {
349
388
PartialResultSet p1 = PartialResultSet .newBuilder ().setResumeToken (resumeToken ).build ();
0 commit comments