Skip to content

Commit b4e17ba

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 or 10 seconds to speed up test execution.
1 parent 15d0055 commit b4e17ba

1 file changed

Lines changed: 28 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: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ public void givenCallerThrowsQuotaException_emitsIntoFailurePCollection() {
123123

124124
@Test
125125
public void givenCallerTimeout_emitsFailurePCollection() {
126-
Duration timeout = Duration.standardMinutes(1L);
126+
// This timeout applies both to processing and setup/teardown. Too low of values causes the
127+
// timeout to be triggered
128+
// on setup/teardown methods unexpectedly.
129+
Duration timeout = Duration.standardSeconds(10L);
127130
Result<Response> result =
128131
pipeline
129132
.apply(Create.of(new Request("a")))
@@ -182,8 +185,7 @@ public void givenSetupThrowsQuotaException_throwsError() {
182185

183186
@Test
184187
public void givenSetupTimeout_throwsError() {
185-
Duration timeout = Duration.standardMinutes(1L);
186-
188+
Duration timeout = Duration.standardSeconds(1L);
187189
pipeline
188190
.apply(Create.of(new Request("")))
189191
.apply(
@@ -231,7 +233,7 @@ public void givenTeardownThrowsQuotaException_throwsError() {
231233

232234
@Test
233235
public void givenTeardownTimeout_throwsError() {
234-
Duration timeout = Duration.standardMinutes(1L);
236+
Duration timeout = Duration.standardSeconds(1L);
235237
pipeline
236238
.apply(Create.of(new Request("")))
237239
.apply(
@@ -271,7 +273,7 @@ public void givenValidCaller_emitValidResponse() {
271273
private static class ValidCaller implements Caller<Request, Response> {
272274

273275
@Override
274-
public Response call(Request request) throws UserCodeExecutionException {
276+
public Response call(Request request) {
275277
return new Response(request.id);
276278
}
277279
}
@@ -282,7 +284,7 @@ private static class UnSerializableCaller implements Caller<Request, Response> {
282284
private final UnSerializable nestedThing = new UnSerializable();
283285

284286
@Override
285-
public Response call(Request request) throws UserCodeExecutionException {
287+
public Response call(Request request) {
286288
return new Response(request.id);
287289
}
288290
}
@@ -291,10 +293,10 @@ private static class UnSerializableCallerWithSetupTeardown extends UnSerializabl
291293
implements SetupTeardown {
292294

293295
@Override
294-
public void setup() throws UserCodeExecutionException {}
296+
public void setup() {}
295297

296298
@Override
297-
public void teardown() throws UserCodeExecutionException {}
299+
public void teardown() {}
298300
}
299301

300302
private static class UnSerializable {}
@@ -358,11 +360,11 @@ private static class CallerExceedsTimeout implements Caller<Request, Response> {
358360
private final Duration timeout;
359361

360362
CallerExceedsTimeout(Duration timeout) {
361-
this.timeout = timeout.plus(Duration.standardSeconds(1L));
363+
this.timeout = timeout.plus(Duration.standardSeconds(10L));
362364
}
363365

364366
@Override
365-
public Response call(Request request) throws UserCodeExecutionException {
367+
public Response call(Request request) {
366368
sleep(timeout);
367369
return new Response(request.id);
368370
}
@@ -397,16 +399,16 @@ private static class SetupExceedsTimeout implements SetupTeardown {
397399
private final Duration timeout;
398400

399401
private SetupExceedsTimeout(Duration timeout) {
400-
this.timeout = timeout.plus(Duration.standardSeconds(1L));
402+
this.timeout = timeout.plus(Duration.standardSeconds(10L));
401403
}
402404

403405
@Override
404-
public void setup() throws UserCodeExecutionException {
406+
public void setup() {
405407
sleep(timeout);
406408
}
407409

408410
@Override
409-
public void teardown() throws UserCodeExecutionException {}
411+
public void teardown() {}
410412
}
411413

412414
private static class SetupThrowsUserCodeExecutionException implements SetupTeardown {
@@ -416,7 +418,7 @@ public void setup() throws UserCodeExecutionException {
416418
}
417419

418420
@Override
419-
public void teardown() throws UserCodeExecutionException {}
421+
public void teardown() {}
420422
}
421423

422424
private static class SetupThrowsUserCodeQuotaException implements SetupTeardown {
@@ -426,7 +428,7 @@ public void setup() throws UserCodeExecutionException {
426428
}
427429

428430
@Override
429-
public void teardown() throws UserCodeExecutionException {}
431+
public void teardown() {}
430432
}
431433

432434
private static class SetupThrowsUserCodeTimeoutException implements SetupTeardown {
@@ -436,28 +438,28 @@ public void setup() throws UserCodeExecutionException {
436438
}
437439

438440
@Override
439-
public void teardown() throws UserCodeExecutionException {}
441+
public void teardown() {}
440442
}
441443

442444
private static class TeardownExceedsTimeout implements SetupTeardown {
443445
private final Duration timeout;
444446

445447
private TeardownExceedsTimeout(Duration timeout) {
446-
this.timeout = timeout.plus(Duration.standardSeconds(1L));
448+
this.timeout = timeout.plus(Duration.standardSeconds(10L));
447449
}
448450

449451
@Override
450-
public void setup() throws UserCodeExecutionException {}
452+
public void setup() {}
451453

452454
@Override
453-
public void teardown() throws UserCodeExecutionException {
455+
public void teardown() {
454456
sleep(timeout);
455457
}
456458
}
457459

458460
private static class TeardownThrowsUserCodeExecutionException implements SetupTeardown {
459461
@Override
460-
public void setup() throws UserCodeExecutionException {}
462+
public void setup() {}
461463

462464
@Override
463465
public void teardown() throws UserCodeExecutionException {
@@ -467,7 +469,7 @@ public void teardown() throws UserCodeExecutionException {
467469

468470
private static class TeardownThrowsUserCodeQuotaException implements SetupTeardown {
469471
@Override
470-
public void setup() throws UserCodeExecutionException {}
472+
public void setup() {}
471473

472474
@Override
473475
public void teardown() throws UserCodeExecutionException {
@@ -477,7 +479,7 @@ public void teardown() throws UserCodeExecutionException {
477479

478480
private static class TeardownThrowsUserCodeTimeoutException implements SetupTeardown {
479481
@Override
480-
public void setup() throws UserCodeExecutionException {}
482+
public void setup() {}
481483

482484
@Override
483485
public void teardown() throws UserCodeExecutionException {
@@ -519,14 +521,12 @@ private static class DeterministicRequestCoder extends CustomCoder<@NonNull Requ
519521
private static final Coder<String> ID_CODER = StringUtf8Coder.of();
520522

521523
@Override
522-
public void encode(Request value, @NotNull OutputStream outStream)
523-
throws CoderException, IOException {
524+
public void encode(Request value, @NotNull OutputStream outStream) throws IOException {
524525
ID_CODER.encode(checkStateNotNull(value).id, outStream);
525526
}
526527

527528
@Override
528-
public @NonNull Request decode(@NotNull InputStream inStream)
529-
throws CoderException, IOException {
529+
public @NonNull Request decode(@NotNull InputStream inStream) throws IOException {
530530
String id = ID_CODER.decode(inStream);
531531
return new Request(id);
532532
}
@@ -542,7 +542,7 @@ private static class DeterministicResponseCoder extends CustomCoder<Response> {
542542

543543
@Override
544544
public void encode(@Nullable Response value, @NotNull OutputStream outStream)
545-
throws CoderException, IOException {
545+
throws IOException {
546546
if (value == null) {
547547
ID_CODER.encode(null, outStream);
548548
return;
@@ -551,7 +551,7 @@ public void encode(@Nullable Response value, @NotNull OutputStream outStream)
551551
}
552552

553553
@Override
554-
public Response decode(@NotNull InputStream inStream) throws CoderException, IOException {
554+
public Response decode(@NotNull InputStream inStream) throws IOException {
555555
try {
556556
String id = ID_CODER.decode(inStream);
557557
return new Response(id);

0 commit comments

Comments
 (0)