Skip to content

Commit e34d88b

Browse files
authored
fix recent test failures (#352)
1 parent b13bd3e commit e34d88b

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

transact/src/test/java/dev/dbos/transact/client/PgSqlClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void clientEnqueueTimeout() throws Exception {
114114

115115
@Test
116116
public void clientEnqueueDeadline() throws Exception {
117-
var wfid1 = enqueueWorkflow("sleep", null, null, Instant.now().plusMillis(1000), 10000);
117+
var wfid1 = enqueueWorkflow("sleep", null, null, Instant.now().plusMillis(5000), 60000);
118118
var handle1 = dbos.retrieveWorkflow(wfid1);
119119
assertThrows(
120120
DBOSAwaitedWorkflowCancelledException.class,

transact/src/test/java/dev/dbos/transact/execution/DBOSExecutorTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ private ExecutingService register(DBOS dbos) {
5050
return service;
5151
}
5252

53+
private static void awaitStepCount(DBOS dbos, String wfid, int expected, int timeoutMs)
54+
throws Exception {
55+
long deadline = System.currentTimeMillis() + timeoutMs;
56+
while (System.currentTimeMillis() < deadline) {
57+
if (dbos.listWorkflowSteps(wfid).size() == expected) return;
58+
Thread.sleep(50);
59+
}
60+
assertEquals(expected, dbos.listWorkflowSteps(wfid).size());
61+
}
62+
5363
@Test
5464
@EnabledForJreRange(min = JRE.JAVA_21)
5565
public void virtualThreadPoolJava21() throws Exception {
@@ -201,8 +211,7 @@ public void executeWithStep() throws Exception {
201211

202212
DBUtils.setWorkflowState(dataSource, wfid, WorkflowState.PENDING.name());
203213
DBUtils.deleteAllStepOutputs(dataSource, wfid);
204-
steps = dbos.listWorkflowSteps(wfid);
205-
assertEquals(0, steps.size());
214+
awaitStepCount(dbos, wfid, 0, 2000);
206215

207216
WorkflowHandle<String, ?> handle = dbosExecutor.executeWorkflowById(wfid, true, false);
208217

@@ -212,8 +221,7 @@ public void executeWithStep() throws Exception {
212221

213222
wfs = dbos.listWorkflows(null);
214223
assertEquals(WorkflowState.SUCCESS, wfs.get(0).status());
215-
steps = dbos.listWorkflowSteps(wfid);
216-
assertEquals(2, steps.size());
224+
awaitStepCount(dbos, wfid, 2, 2000);
217225
}
218226
}
219227

@@ -246,8 +254,7 @@ public void ReExecuteWithStepTwoOnly() throws Exception {
246254

247255
DBUtils.setWorkflowState(dataSource, wfid, WorkflowState.PENDING.name());
248256
DBUtils.deleteStepOutput(dataSource, wfid, 1);
249-
steps = dbos.listWorkflowSteps(wfid);
250-
assertEquals(1, steps.size());
257+
awaitStepCount(dbos, wfid, 1, 2000);
251258

252259
WorkflowHandle<String, ?> handle = dbosExecutor.executeWorkflowById(wfid, true, false);
253260

@@ -260,8 +267,7 @@ public void ReExecuteWithStepTwoOnly() throws Exception {
260267

261268
wfs = dbos.listWorkflows(null);
262269
assertEquals(WorkflowState.SUCCESS, wfs.get(0).status());
263-
steps = dbos.listWorkflowSteps(wfid);
264-
assertEquals(2, steps.size());
270+
awaitStepCount(dbos, wfid, 2, 2000);
265271
}
266272
}
267273

transact/src/test/java/dev/dbos/transact/scheduled/WorkflowScheduleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public void scheduleRunsAfterPolling() throws Exception {
498498
// Wait for all 3 counts to be released, which indicates the workflow ran at least 3 times
499499
// (scheduler should run it every second).
500500
assertTrue(
501-
impl.latch.await(5, TimeUnit.SECONDS),
502-
"Expected latch to count down to zero within 5 seconds");
501+
impl.latch.await(15, TimeUnit.SECONDS),
502+
"Expected latch to count down to zero within 15 seconds");
503503
}
504504
}

0 commit comments

Comments
 (0)