Skip to content

Commit 0601a46

Browse files
authored
use new Launch/Shutdown package methods in tests (#159)
1 parent 769b55e commit 0601a46

File tree

9 files changed

+59
-59
lines changed

9 files changed

+59
-59
lines changed

chaos_tests/chaos_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func setupDBOS(t *testing.T) dbos.DBOSContext {
188188
// Register cleanup to run after test completes
189189
t.Cleanup(func() {
190190
if dbosCtx != nil {
191-
dbosCtx.Shutdown(30 * time.Second)
191+
dbos.Shutdown(dbosCtx, 30*time.Second)
192192
}
193193
})
194194

@@ -246,7 +246,7 @@ func TestChaosWorkflow(t *testing.T) {
246246
// Register scheduled workflow to run every second for chaos testing
247247
dbos.RegisterWorkflow(dbosCtx, scheduledWorkflow, dbos.WithSchedule("* * * * * *"), dbos.WithWorkflowName("ScheduledChaosTest"))
248248

249-
err := dbosCtx.Launch()
249+
err := dbos.Launch(dbosCtx)
250250
require.NoError(t, err)
251251

252252
// Run multiple workflows
@@ -309,7 +309,7 @@ func TestChaosRecv(t *testing.T) {
309309
// Register the workflow
310310
dbos.RegisterWorkflow(dbosCtx, recvWorkflow)
311311

312-
err := dbosCtx.Launch()
312+
err := dbos.Launch(dbosCtx)
313313
require.NoError(t, err)
314314

315315
// Run multiple workflows with send/recv
@@ -364,7 +364,7 @@ func TestChaosEvents(t *testing.T) {
364364
// Register the workflow
365365
dbos.RegisterWorkflow(dbosCtx, eventWorkflow)
366366

367-
err := dbosCtx.Launch()
367+
err := dbos.Launch(dbosCtx)
368368
require.NoError(t, err)
369369

370370
// Run multiple workflows with events
@@ -455,7 +455,7 @@ func TestChaosQueues(t *testing.T) {
455455
dbos.RegisterWorkflow(dbosCtx, stepTwo)
456456
dbos.RegisterWorkflow(dbosCtx, workflow)
457457

458-
err := dbosCtx.Launch()
458+
err := dbos.Launch(dbosCtx)
459459
require.NoError(t, err)
460460

461461
// Run multiple workflows

dbos/admin_server_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ func TestAdminServer(t *testing.T) {
3232
})
3333
require.NoError(t, err)
3434

35-
err = ctx.Launch()
35+
err = Launch(ctx)
3636
require.NoError(t, err)
3737
// Ensure cleanup
3838
defer func() {
3939
if ctx != nil {
40-
ctx.Shutdown(1 * time.Minute)
40+
Shutdown(ctx, 1*time.Minute)
4141
}
4242
}()
4343

@@ -65,13 +65,13 @@ func TestAdminServer(t *testing.T) {
6565
})
6666
require.NoError(t, err)
6767

68-
err = ctx.Launch()
68+
err = Launch(ctx)
6969
require.NoError(t, err)
7070

7171
// Ensure cleanup
7272
defer func() {
7373
if ctx != nil {
74-
ctx.Shutdown(1 * time.Minute)
74+
Shutdown(ctx, 1*time.Minute)
7575
}
7676
}()
7777

@@ -253,13 +253,13 @@ func TestAdminServer(t *testing.T) {
253253
}
254254
RegisterWorkflow(ctx, structWorkflow)
255255

256-
err = ctx.Launch()
256+
err = Launch(ctx)
257257
require.NoError(t, err)
258258

259259
// Ensure cleanup
260260
defer func() {
261261
if ctx != nil {
262-
ctx.Shutdown(1 * time.Minute)
262+
Shutdown(ctx, 1*time.Minute)
263263
}
264264
}()
265265

@@ -381,13 +381,13 @@ func TestAdminServer(t *testing.T) {
381381
}
382382
RegisterWorkflow(ctx, testWorkflow)
383383

384-
err = ctx.Launch()
384+
err = Launch(ctx)
385385
require.NoError(t, err)
386386

387387
// Ensure cleanup
388388
defer func() {
389389
if ctx != nil {
390-
ctx.Shutdown(1 * time.Minute)
390+
Shutdown(ctx, 1*time.Minute)
391391
}
392392
}()
393393

@@ -569,14 +569,14 @@ func TestAdminServer(t *testing.T) {
569569
}
570570
RegisterWorkflow(ctx, regularWorkflow)
571571

572-
err = ctx.Launch()
572+
err = Launch(ctx)
573573
require.NoError(t, err)
574574

575575
// Ensure cleanup
576576
defer func() {
577577
close(blockingChan) // Unblock any blocked workflows
578578
if ctx != nil {
579-
ctx.Shutdown(1 * time.Minute)
579+
Shutdown(ctx, 1*time.Minute)
580580
}
581581
}()
582582

@@ -745,15 +745,15 @@ func TestAdminServer(t *testing.T) {
745745
return fmt.Sprintf("executed at %v", scheduledTime), nil
746746
}, WithSchedule("* * * * * *")) // Every second
747747

748-
err = ctx.Launch()
748+
err = Launch(ctx)
749749
require.NoError(t, err)
750750

751751
client := &http.Client{Timeout: 5 * time.Second}
752752

753753
// Ensure cleanup
754754
defer func() {
755755
if ctx != nil {
756-
ctx.Shutdown(1 * time.Minute)
756+
Shutdown(ctx, 1*time.Minute)
757757
}
758758
if client.Transport != nil {
759759
client.Transport.(*http.Transport).CloseIdleConnections()

dbos/client_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestEnqueue(t *testing.T) {
6060
RegisterWorkflow(serverCtx, priorityWorkflow, WithWorkflowName("PriorityWorkflow"))
6161

6262
// Launch the server context to start processing tasks
63-
err := serverCtx.Launch()
63+
err := Launch(serverCtx)
6464
require.NoError(t, err)
6565

6666
// Setup client - this will enqueue tasks
@@ -319,7 +319,7 @@ func TestCancelResume(t *testing.T) {
319319
RegisterWorkflow(serverCtx, timeoutBlockingWorkflow, WithWorkflowName("TimeoutBlockingWorkflow"))
320320

321321
// Launch the server context to start processing tasks
322-
err := serverCtx.Launch()
322+
err := Launch(serverCtx)
323323
require.NoError(t, err)
324324

325325
// Setup client - this will enqueue tasks
@@ -570,7 +570,7 @@ func TestForkWorkflow(t *testing.T) {
570570
RegisterWorkflow(serverCtx, parentWorkflow, WithWorkflowName("ParentWorkflow"))
571571

572572
// Launch the server context to start processing tasks
573-
err := serverCtx.Launch()
573+
err := Launch(serverCtx)
574574
require.NoError(t, err)
575575

576576
// Setup client
@@ -706,7 +706,7 @@ func TestListWorkflows(t *testing.T) {
706706
// Register cleanup for server context
707707
t.Cleanup(func() {
708708
if serverCtx != nil {
709-
serverCtx.Shutdown(30 * time.Second)
709+
Shutdown(serverCtx, 30*time.Second)
710710
}
711711
})
712712

@@ -728,7 +728,7 @@ func TestListWorkflows(t *testing.T) {
728728
RegisterWorkflow(serverCtx, simpleWorkflow, WithWorkflowName("SimpleWorkflow"))
729729

730730
// Launch server
731-
err = serverCtx.Launch()
731+
err = Launch(serverCtx)
732732
require.NoError(t, err)
733733

734734
// Setup client with same custom schema

dbos/dbos_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestConfig(t *testing.T) {
3333
require.NoError(t, err)
3434
defer func() {
3535
if ctx != nil {
36-
ctx.Shutdown(1 * time.Minute)
36+
Shutdown(ctx, 1*time.Minute)
3737
}
3838
}() // Clean up executor
3939

@@ -100,7 +100,7 @@ func TestConfig(t *testing.T) {
100100
require.NoError(t, err)
101101
defer func() {
102102
if ctx != nil {
103-
ctx.Shutdown(1 * time.Minute)
103+
Shutdown(ctx, 1*time.Minute)
104104
}
105105
}()
106106

@@ -121,7 +121,7 @@ func TestConfig(t *testing.T) {
121121
require.NoError(t, err)
122122
defer func() {
123123
if ctx != nil {
124-
ctx.Shutdown(1 * time.Minute)
124+
Shutdown(ctx, 1*time.Minute)
125125
}
126126
}()
127127

@@ -143,7 +143,7 @@ func TestConfig(t *testing.T) {
143143
require.NoError(t, err)
144144
defer func() {
145145
if ctx != nil {
146-
ctx.Shutdown(1 * time.Minute)
146+
Shutdown(ctx, 1*time.Minute)
147147
}
148148
}()
149149

@@ -168,7 +168,7 @@ func TestConfig(t *testing.T) {
168168
require.NoError(t, err)
169169
defer func() {
170170
if ctx != nil {
171-
ctx.Shutdown(1 * time.Minute)
171+
Shutdown(ctx, 1*time.Minute)
172172
}
173173
}()
174174

@@ -190,7 +190,7 @@ func TestConfig(t *testing.T) {
190190
require.NoError(t, err)
191191
defer func() {
192192
if ctx != nil {
193-
ctx.Shutdown(1 * time.Minute)
193+
Shutdown(ctx, 1*time.Minute)
194194
}
195195
}()
196196

@@ -262,7 +262,7 @@ func TestConfig(t *testing.T) {
262262
assert.Equal(t, int64(1), version, "migration version should be 1 (after initial migration)")
263263

264264
// Test manual shutdown and recreate
265-
ctx.Shutdown(1 * time.Minute)
265+
Shutdown(ctx, 1*time.Minute)
266266

267267
// Recreate context - should have no error since DB is already migrated
268268
ctx2, err := NewDBOSContext(context.Background(), Config{
@@ -272,7 +272,7 @@ func TestConfig(t *testing.T) {
272272
require.NoError(t, err)
273273
defer func() {
274274
if ctx2 != nil {
275-
ctx2.Shutdown(1 * time.Minute)
275+
Shutdown(ctx2, 1*time.Minute)
276276
}
277277
}()
278278

@@ -301,7 +301,7 @@ func TestCustomSystemDBSchema(t *testing.T) {
301301
require.NoError(t, err)
302302
defer func() {
303303
if ctx != nil {
304-
ctx.Shutdown(1 * time.Minute)
304+
Shutdown(ctx, 1*time.Minute)
305305
}
306306
}()
307307

@@ -425,7 +425,7 @@ func TestCustomSystemDBSchema(t *testing.T) {
425425
RegisterWorkflow(ctx, recvSetEventWorkflow)
426426

427427
// Launch the DBOS context
428-
ctx.Launch()
428+
Launch(ctx)
429429

430430
// Test RunWorkflow - start both workflows that will communicate with each other
431431
workflowAID := uuid.NewString()
@@ -548,7 +548,7 @@ func TestCustomPool(t *testing.T) {
548548
require.NotNil(t, customdbosContext)
549549

550550
dbosCtx, ok := customdbosContext.(*dbosContext)
551-
defer dbosCtx.Shutdown(10 * time.Second)
551+
defer Shutdown(dbosCtx, 10*time.Second)
552552
require.True(t, ok)
553553

554554
sysDB, ok := dbosCtx.systemDB.(*sysDB)
@@ -570,9 +570,9 @@ func TestCustomPool(t *testing.T) {
570570
RegisterWorkflow(customdbosContext, recvSetEventWorkflowCustom)
571571

572572
// Launch the DBOS context
573-
err = customdbosContext.Launch()
573+
err = Launch(customdbosContext)
574574
require.NoError(t, err)
575-
defer dbosCtx.Shutdown(1 * time.Minute)
575+
defer Shutdown(dbosCtx, 1*time.Minute)
576576

577577
// Test RunWorkflow - start both workflows that will communicate with each other
578578
workflowAID := uuid.NewString()
@@ -643,9 +643,9 @@ func TestCustomPool(t *testing.T) {
643643
RegisterWorkflow(dbosCtx, wf)
644644

645645
// Launch the DBOS context
646-
err = dbosCtx.Launch()
646+
err = Launch(dbosCtx)
647647
require.NoError(t, err)
648-
defer dbosCtx.Shutdown(1 * time.Minute)
648+
defer Shutdown(dbosCtx, 1*time.Minute)
649649

650650
// Run a workflow
651651
_, err = RunWorkflow(dbosCtx, wf, "test-input")

dbos/logger_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ func TestLogger(t *testing.T) {
2626
AppName: "test-app",
2727
}) // Create executor with default logger
2828
require.NoError(t, err)
29-
err = dbosCtx.Launch()
29+
err = Launch(dbosCtx)
3030
require.NoError(t, err)
3131
t.Cleanup(func() {
3232
if dbosCtx != nil {
33-
dbosCtx.Shutdown(10 * time.Second)
33+
Shutdown(dbosCtx, 10*time.Second)
3434
}
3535
})
3636

@@ -59,11 +59,11 @@ func TestLogger(t *testing.T) {
5959
Logger: slogLogger,
6060
})
6161
require.NoError(t, err)
62-
err = dbosCtx.Launch()
62+
err = Launch(dbosCtx)
6363
require.NoError(t, err)
6464
t.Cleanup(func() {
6565
if dbosCtx != nil {
66-
dbosCtx.Shutdown(10 * time.Second)
66+
Shutdown(dbosCtx, 10*time.Second)
6767
}
6868
})
6969

0 commit comments

Comments
 (0)