Skip to content

Commit 17ed325

Browse files
author
nKwiatkowski
committed
fix(test): backport flacky tests fixed on develop
1 parent 7dd7d45 commit 17ed325

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

core/src/test/java/io/kestra/core/schedulers/SchedulerScheduleOnDatesTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public class SchedulerScheduleOnDatesTest extends AbstractSchedulerTest {
5353

5454
private Flow createScheduleFlow(String zone, String triggerId) {
5555
var now = ZonedDateTime.now();
56-
var before = now.minusSeconds(1).truncatedTo(ChronoUnit.SECONDS);
57-
var after = now.plusSeconds(1).truncatedTo(ChronoUnit.SECONDS);
58-
var later = now.plusSeconds(2).truncatedTo(ChronoUnit.SECONDS);
56+
var before = now.minusSeconds(3).truncatedTo(ChronoUnit.SECONDS);
57+
var after = now.plusSeconds(3).truncatedTo(ChronoUnit.SECONDS);
58+
var later = now.plusSeconds(6).truncatedTo(ChronoUnit.SECONDS);
5959
ScheduleOnDates schedule = createScheduleOnDatesTrigger(zone, List.of(before, after, later), triggerId).build();
6060

6161
return createFlow(Collections.singletonList(schedule));
@@ -106,11 +106,11 @@ void scheduleOnDates() throws Exception {
106106
date.add((String) execution.getTrigger().getVariables().get("date"));
107107
executionId.add(execution.getId());
108108

109-
queueCount.countDown();
110109
if (execution.getState().getCurrent() == State.Type.CREATED) {
111110
executionQueue.emit(execution.withState(State.Type.SUCCESS));
112111
}
113112
assertThat(execution.getFlowId(), is(flow.getId()));
113+
queueCount.countDown();
114114
}));
115115

116116
scheduler.run();

jdbc/src/test/java/io/kestra/jdbc/runner/JdbcServiceLivenessCoordinatorTest.java

+6-12
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,11 @@ void shouldReEmitTriggerWhenWorkerIsDetectedAsNonResponding() throws Exception {
243243
worker.shutdown();
244244

245245
Worker newWorker = applicationContext.createBean(Worker.class, IdUtils.create(), 1, null);
246-
applicationContext.registerSingleton(newWorker);
247246
newWorker.run();
247+
assertThat(countDownLatch.await(30, TimeUnit.SECONDS), is(true));
248248

249-
boolean lastAwait = countDownLatch.await(10, TimeUnit.SECONDS);
250-
251-
newWorker.shutdown();
252249
receive.blockLast();
253-
assertThat(lastAwait, is(true));
250+
newWorker.shutdown();
254251
}
255252

256253
@Test
@@ -260,11 +257,11 @@ void shouldReEmitTriggerToTheSameWorkerGroup() throws Exception {
260257

261258
WorkerTrigger workerTrigger = workerTrigger(Duration.ofSeconds(5), "workerGroupKey");
262259

263-
// 2 trigger should happen because of the resubmit
260+
// 2 triggers should happen because of the resubmit
264261
CountDownLatch countDownLatch = new CountDownLatch(2);
265262
Flux<WorkerTriggerResult> receive = TestsUtils.receive(workerTriggerResultQueue, workerTriggerResult -> countDownLatch.countDown());
266263

267-
// we wait that the worker receive the trigger
264+
// we wait that the worker receives the trigger
268265
CountDownLatch triggerCountDownLatch = new CountDownLatch(1);
269266
Flux<Trigger> receiveTrigger = TestsUtils.receive(triggerQueue, either -> {
270267
if (either.getLeft().getWorkerId().equals(worker.getId())) {
@@ -277,14 +274,11 @@ void shouldReEmitTriggerToTheSameWorkerGroup() throws Exception {
277274
worker.shutdown();
278275

279276
Worker newWorker = applicationContext.createBean(Worker.class, IdUtils.create(), 1, "workerGroupKey");
280-
applicationContext.registerSingleton(newWorker);
281277
newWorker.run();
278+
assertThat(countDownLatch.await(30, TimeUnit.SECONDS), is(true));
282279

283-
boolean lastAwait = countDownLatch.await(10, TimeUnit.SECONDS);
284-
285-
newWorker.shutdown();
286280
receive.blockLast();
287-
assertThat(lastAwait, is(true));
281+
newWorker.shutdown();
288282
}
289283

290284
@MockBean(WorkerGroupService.class)

0 commit comments

Comments
 (0)