Skip to content

Commit 7c65ca2

Browse files
committed
Increase CallTest sleep durations to keep test from being flaky due to timeout not being observed.
Decrease configured timeouts from 1 minute to 1 second to speed up test execution.
1 parent 8ba0474 commit 7c65ca2

1 file changed

Lines changed: 25 additions & 28 deletions

File tree

  • sdks/java/io/rrio/src/test/java/org/apache/beam/io/requestresponse

sdks/java/io/rrio/src/test/java/org/apache/beam/io/requestresponse/CallTest.java

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void givenCallerThrowsQuotaException_emitsIntoFailurePCollection() {
123123

124124
@Test
125125
public void givenCallerTimeout_emitsFailurePCollection() {
126-
Duration timeout = Duration.standardMinutes(1L);
126+
Duration timeout = Duration.standardSeconds(1L);
127127
Result<Response> result =
128128
pipeline
129129
.apply(Create.of(new Request("a")))
@@ -182,8 +182,7 @@ public void givenSetupThrowsQuotaException_throwsError() {
182182

183183
@Test
184184
public void givenSetupTimeout_throwsError() {
185-
Duration timeout = Duration.standardMinutes(1L);
186-
185+
Duration timeout = Duration.standardSeconds(1L);
187186
pipeline
188187
.apply(Create.of(new Request("")))
189188
.apply(
@@ -231,7 +230,7 @@ public void givenTeardownThrowsQuotaException_throwsError() {
231230

232231
@Test
233232
public void givenTeardownTimeout_throwsError() {
234-
Duration timeout = Duration.standardMinutes(1L);
233+
Duration timeout = Duration.standardSeconds(1L);
235234
pipeline
236235
.apply(Create.of(new Request("")))
237236
.apply(
@@ -271,7 +270,7 @@ public void givenValidCaller_emitValidResponse() {
271270
private static class ValidCaller implements Caller<Request, Response> {
272271

273272
@Override
274-
public Response call(Request request) throws UserCodeExecutionException {
273+
public Response call(Request request) {
275274
return new Response(request.id);
276275
}
277276
}
@@ -282,7 +281,7 @@ private static class UnSerializableCaller implements Caller<Request, Response> {
282281
private final UnSerializable nestedThing = new UnSerializable();
283282

284283
@Override
285-
public Response call(Request request) throws UserCodeExecutionException {
284+
public Response call(Request request) {
286285
return new Response(request.id);
287286
}
288287
}
@@ -291,10 +290,10 @@ private static class UnSerializableCallerWithSetupTeardown extends UnSerializabl
291290
implements SetupTeardown {
292291

293292
@Override
294-
public void setup() throws UserCodeExecutionException {}
293+
public void setup() {}
295294

296295
@Override
297-
public void teardown() throws UserCodeExecutionException {}
296+
public void teardown() {}
298297
}
299298

300299
private static class UnSerializable {}
@@ -358,11 +357,11 @@ private static class CallerExceedsTimeout implements Caller<Request, Response> {
358357
private final Duration timeout;
359358

360359
CallerExceedsTimeout(Duration timeout) {
361-
this.timeout = timeout.plus(Duration.standardSeconds(1L));
360+
this.timeout = timeout.plus(Duration.standardSeconds(10L));
362361
}
363362

364363
@Override
365-
public Response call(Request request) throws UserCodeExecutionException {
364+
public Response call(Request request) {
366365
sleep(timeout);
367366
return new Response(request.id);
368367
}
@@ -397,16 +396,16 @@ private static class SetupExceedsTimeout implements SetupTeardown {
397396
private final Duration timeout;
398397

399398
private SetupExceedsTimeout(Duration timeout) {
400-
this.timeout = timeout.plus(Duration.standardSeconds(1L));
399+
this.timeout = timeout.plus(Duration.standardSeconds(10L));
401400
}
402401

403402
@Override
404-
public void setup() throws UserCodeExecutionException {
403+
public void setup() {
405404
sleep(timeout);
406405
}
407406

408407
@Override
409-
public void teardown() throws UserCodeExecutionException {}
408+
public void teardown() {}
410409
}
411410

412411
private static class SetupThrowsUserCodeExecutionException implements SetupTeardown {
@@ -416,7 +415,7 @@ public void setup() throws UserCodeExecutionException {
416415
}
417416

418417
@Override
419-
public void teardown() throws UserCodeExecutionException {}
418+
public void teardown() {}
420419
}
421420

422421
private static class SetupThrowsUserCodeQuotaException implements SetupTeardown {
@@ -426,7 +425,7 @@ public void setup() throws UserCodeExecutionException {
426425
}
427426

428427
@Override
429-
public void teardown() throws UserCodeExecutionException {}
428+
public void teardown() {}
430429
}
431430

432431
private static class SetupThrowsUserCodeTimeoutException implements SetupTeardown {
@@ -436,28 +435,28 @@ public void setup() throws UserCodeExecutionException {
436435
}
437436

438437
@Override
439-
public void teardown() throws UserCodeExecutionException {}
438+
public void teardown() {}
440439
}
441440

442441
private static class TeardownExceedsTimeout implements SetupTeardown {
443442
private final Duration timeout;
444443

445444
private TeardownExceedsTimeout(Duration timeout) {
446-
this.timeout = timeout.plus(Duration.standardSeconds(1L));
445+
this.timeout = timeout.plus(Duration.standardSeconds(10L));
447446
}
448447

449448
@Override
450-
public void setup() throws UserCodeExecutionException {}
449+
public void setup() {}
451450

452451
@Override
453-
public void teardown() throws UserCodeExecutionException {
452+
public void teardown() {
454453
sleep(timeout);
455454
}
456455
}
457456

458457
private static class TeardownThrowsUserCodeExecutionException implements SetupTeardown {
459458
@Override
460-
public void setup() throws UserCodeExecutionException {}
459+
public void setup() {}
461460

462461
@Override
463462
public void teardown() throws UserCodeExecutionException {
@@ -467,7 +466,7 @@ public void teardown() throws UserCodeExecutionException {
467466

468467
private static class TeardownThrowsUserCodeQuotaException implements SetupTeardown {
469468
@Override
470-
public void setup() throws UserCodeExecutionException {}
469+
public void setup() {}
471470

472471
@Override
473472
public void teardown() throws UserCodeExecutionException {
@@ -477,7 +476,7 @@ public void teardown() throws UserCodeExecutionException {
477476

478477
private static class TeardownThrowsUserCodeTimeoutException implements SetupTeardown {
479478
@Override
480-
public void setup() throws UserCodeExecutionException {}
479+
public void setup() {}
481480

482481
@Override
483482
public void teardown() throws UserCodeExecutionException {
@@ -519,14 +518,12 @@ private static class DeterministicRequestCoder extends CustomCoder<@NonNull Requ
519518
private static final Coder<String> ID_CODER = StringUtf8Coder.of();
520519

521520
@Override
522-
public void encode(Request value, @NotNull OutputStream outStream)
523-
throws CoderException, IOException {
521+
public void encode(Request value, @NotNull OutputStream outStream) throws IOException {
524522
ID_CODER.encode(checkStateNotNull(value).id, outStream);
525523
}
526524

527525
@Override
528-
public @NonNull Request decode(@NotNull InputStream inStream)
529-
throws CoderException, IOException {
526+
public @NonNull Request decode(@NotNull InputStream inStream) throws IOException {
530527
String id = ID_CODER.decode(inStream);
531528
return new Request(id);
532529
}
@@ -542,7 +539,7 @@ private static class DeterministicResponseCoder extends CustomCoder<Response> {
542539

543540
@Override
544541
public void encode(@Nullable Response value, @NotNull OutputStream outStream)
545-
throws CoderException, IOException {
542+
throws IOException {
546543
if (value == null) {
547544
ID_CODER.encode(null, outStream);
548545
return;
@@ -551,7 +548,7 @@ public void encode(@Nullable Response value, @NotNull OutputStream outStream)
551548
}
552549

553550
@Override
554-
public Response decode(@NotNull InputStream inStream) throws CoderException, IOException {
551+
public Response decode(@NotNull InputStream inStream) throws IOException {
555552
try {
556553
String id = ID_CODER.decode(inStream);
557554
return new Response(id);

0 commit comments

Comments
 (0)