Skip to content

Commit a2d9d7b

Browse files
committed
Increase CallTest sleep durations to keep test from being flaky.
Decrease CallTest timeout from 1 minute to 1 second to speed up test execution.
1 parent 15d0055 commit a2d9d7b

1 file changed

Lines changed: 25 additions & 27 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 & 27 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,7 +182,7 @@ public void givenSetupThrowsQuotaException_throwsError() {
182182

183183
@Test
184184
public void givenSetupTimeout_throwsError() {
185-
Duration timeout = Duration.standardMinutes(1L);
185+
Duration timeout = Duration.standardSeconds(1L);
186186

187187
pipeline
188188
.apply(Create.of(new Request("")))
@@ -231,7 +231,7 @@ public void givenTeardownThrowsQuotaException_throwsError() {
231231

232232
@Test
233233
public void givenTeardownTimeout_throwsError() {
234-
Duration timeout = Duration.standardMinutes(1L);
234+
Duration timeout = Duration.standardSeconds(1L);
235235
pipeline
236236
.apply(Create.of(new Request("")))
237237
.apply(
@@ -271,7 +271,7 @@ public void givenValidCaller_emitValidResponse() {
271271
private static class ValidCaller implements Caller<Request, Response> {
272272

273273
@Override
274-
public Response call(Request request) throws UserCodeExecutionException {
274+
public Response call(Request request) {
275275
return new Response(request.id);
276276
}
277277
}
@@ -282,7 +282,7 @@ private static class UnSerializableCaller implements Caller<Request, Response> {
282282
private final UnSerializable nestedThing = new UnSerializable();
283283

284284
@Override
285-
public Response call(Request request) throws UserCodeExecutionException {
285+
public Response call(Request request) {
286286
return new Response(request.id);
287287
}
288288
}
@@ -291,10 +291,10 @@ private static class UnSerializableCallerWithSetupTeardown extends UnSerializabl
291291
implements SetupTeardown {
292292

293293
@Override
294-
public void setup() throws UserCodeExecutionException {}
294+
public void setup() {}
295295

296296
@Override
297-
public void teardown() throws UserCodeExecutionException {}
297+
public void teardown() {}
298298
}
299299

300300
private static class UnSerializable {}
@@ -358,11 +358,11 @@ private static class CallerExceedsTimeout implements Caller<Request, Response> {
358358
private final Duration timeout;
359359

360360
CallerExceedsTimeout(Duration timeout) {
361-
this.timeout = timeout.plus(Duration.standardSeconds(1L));
361+
this.timeout = timeout.plus(Duration.standardSeconds(10L));
362362
}
363363

364364
@Override
365-
public Response call(Request request) throws UserCodeExecutionException {
365+
public Response call(Request request) {
366366
sleep(timeout);
367367
return new Response(request.id);
368368
}
@@ -397,16 +397,16 @@ private static class SetupExceedsTimeout implements SetupTeardown {
397397
private final Duration timeout;
398398

399399
private SetupExceedsTimeout(Duration timeout) {
400-
this.timeout = timeout.plus(Duration.standardSeconds(1L));
400+
this.timeout = timeout.plus(Duration.standardSeconds(10L));
401401
}
402402

403403
@Override
404-
public void setup() throws UserCodeExecutionException {
404+
public void setup() {
405405
sleep(timeout);
406406
}
407407

408408
@Override
409-
public void teardown() throws UserCodeExecutionException {}
409+
public void teardown() {}
410410
}
411411

412412
private static class SetupThrowsUserCodeExecutionException implements SetupTeardown {
@@ -416,7 +416,7 @@ public void setup() throws UserCodeExecutionException {
416416
}
417417

418418
@Override
419-
public void teardown() throws UserCodeExecutionException {}
419+
public void teardown() {}
420420
}
421421

422422
private static class SetupThrowsUserCodeQuotaException implements SetupTeardown {
@@ -426,7 +426,7 @@ public void setup() throws UserCodeExecutionException {
426426
}
427427

428428
@Override
429-
public void teardown() throws UserCodeExecutionException {}
429+
public void teardown() {}
430430
}
431431

432432
private static class SetupThrowsUserCodeTimeoutException implements SetupTeardown {
@@ -436,28 +436,28 @@ public void setup() throws UserCodeExecutionException {
436436
}
437437

438438
@Override
439-
public void teardown() throws UserCodeExecutionException {}
439+
public void teardown() {}
440440
}
441441

442442
private static class TeardownExceedsTimeout implements SetupTeardown {
443443
private final Duration timeout;
444444

445445
private TeardownExceedsTimeout(Duration timeout) {
446-
this.timeout = timeout.plus(Duration.standardSeconds(1L));
446+
this.timeout = timeout.plus(Duration.standardSeconds(10L));
447447
}
448448

449449
@Override
450-
public void setup() throws UserCodeExecutionException {}
450+
public void setup() {}
451451

452452
@Override
453-
public void teardown() throws UserCodeExecutionException {
453+
public void teardown() {
454454
sleep(timeout);
455455
}
456456
}
457457

458458
private static class TeardownThrowsUserCodeExecutionException implements SetupTeardown {
459459
@Override
460-
public void setup() throws UserCodeExecutionException {}
460+
public void setup() {}
461461

462462
@Override
463463
public void teardown() throws UserCodeExecutionException {
@@ -467,7 +467,7 @@ public void teardown() throws UserCodeExecutionException {
467467

468468
private static class TeardownThrowsUserCodeQuotaException implements SetupTeardown {
469469
@Override
470-
public void setup() throws UserCodeExecutionException {}
470+
public void setup() {}
471471

472472
@Override
473473
public void teardown() throws UserCodeExecutionException {
@@ -477,7 +477,7 @@ public void teardown() throws UserCodeExecutionException {
477477

478478
private static class TeardownThrowsUserCodeTimeoutException implements SetupTeardown {
479479
@Override
480-
public void setup() throws UserCodeExecutionException {}
480+
public void setup() {}
481481

482482
@Override
483483
public void teardown() throws UserCodeExecutionException {
@@ -519,14 +519,12 @@ private static class DeterministicRequestCoder extends CustomCoder<@NonNull Requ
519519
private static final Coder<String> ID_CODER = StringUtf8Coder.of();
520520

521521
@Override
522-
public void encode(Request value, @NotNull OutputStream outStream)
523-
throws CoderException, IOException {
522+
public void encode(Request value, @NotNull OutputStream outStream) throws IOException {
524523
ID_CODER.encode(checkStateNotNull(value).id, outStream);
525524
}
526525

527526
@Override
528-
public @NonNull Request decode(@NotNull InputStream inStream)
529-
throws CoderException, IOException {
527+
public @NonNull Request decode(@NotNull InputStream inStream) throws IOException {
530528
String id = ID_CODER.decode(inStream);
531529
return new Request(id);
532530
}
@@ -542,7 +540,7 @@ private static class DeterministicResponseCoder extends CustomCoder<Response> {
542540

543541
@Override
544542
public void encode(@Nullable Response value, @NotNull OutputStream outStream)
545-
throws CoderException, IOException {
543+
throws IOException {
546544
if (value == null) {
547545
ID_CODER.encode(null, outStream);
548546
return;
@@ -551,7 +549,7 @@ public void encode(@Nullable Response value, @NotNull OutputStream outStream)
551549
}
552550

553551
@Override
554-
public Response decode(@NotNull InputStream inStream) throws CoderException, IOException {
552+
public Response decode(@NotNull InputStream inStream) throws IOException {
555553
try {
556554
String id = ID_CODER.decode(inStream);
557555
return new Response(id);

0 commit comments

Comments
 (0)