Skip to content

Commit 2a091a2

Browse files
authored
update integration app (#126)
Also increase a timer to fix a flaky test
1 parent a5aeb48 commit 2a091a2

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

cmd/dbos/cli_test_app.go.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func ScheduledWorkflow(ctx dbos.DBOSContext, scheduledTime time.Time) (string, e
8686
func main() {
8787
// Create DBOS context
8888
var err error
89-
dbosCtx, err = dbos.NewDBOSContext(dbos.Config{
89+
dbosCtx, err = dbos.NewDBOSContext(context.Background(), dbos.Config{
9090
DatabaseURL: os.Getenv("DBOS_SYSTEM_DATABASE_URL"),
9191
AppName: "cli-test",
9292
AdminServer: true,

dbos/workflows_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,7 @@ var (
19741974
getEventStopIdempotencyEvent = NewEvent()
19751975
setSecondEventSignal = NewEvent()
19761976
setThirdEventSignal = NewEvent()
1977+
getEventWorkflowStartedSignal = NewEvent()
19771978
)
19781979

19791980
type setEventWorkflowInput struct {
@@ -1996,6 +1997,7 @@ type getEventWorkflowInput struct {
19961997
}
19971998

19981999
func getEventWorkflow(ctx DBOSContext, input getEventWorkflowInput) (string, error) {
2000+
getEventWorkflowStartedSignal.Set()
19992001
result, err := GetEvent[string](ctx, input.TargetWorkflowID, input.Key, 3*time.Second)
20002002
if err != nil {
20012003
return "", err
@@ -2203,6 +2205,8 @@ func TestSetGetEvent(t *testing.T) {
22032205
Key: "event", // Event key
22042206
})
22052207
require.NoError(t, err, "failed to start get first event workflow")
2208+
getEventWorkflowStartedSignal.Wait()
2209+
getEventWorkflowStartedSignal.Clear()
22062210

22072211
time.Sleep(500 * time.Millisecond)
22082212

@@ -2229,21 +2233,24 @@ func TestSetGetEvent(t *testing.T) {
22292233
Key: "event", // Event key
22302234
})
22312235
require.NoError(t, err, "failed to start get second event workflow")
2236+
getEventWorkflowStartedSignal.Wait()
2237+
getEventWorkflowStartedSignal.Clear()
22322238

22332239
// Verify we can get the second event
22342240
secondMessage, err := getSecondEventHandle.GetResult()
22352241
require.NoError(t, err, "failed to get result from second event workflow")
22362242
assert.Equal(t, "second-event-message", secondMessage, "expected second message to be 'second-event-message'")
22372243

2238-
// Signal the workflow to set the third event
2239-
setThirdEventSignal.Set()
2240-
22412244
// Start a workflow to get the third event
22422245
getThirdEventHandle, err := RunWorkflow(dbosCtx, getEventWorkflow, getEventWorkflowInput{
22432246
TargetWorkflowID: setWorkflowID, // Target workflow ID
22442247
Key: "anotherevent", // Event key
22452248
})
22462249
require.NoError(t, err, "failed to start get third event workflow")
2250+
getEventWorkflowStartedSignal.Wait() // So we know we're waiting on GetEvent
2251+
2252+
// Signal the workflow to set the third event and wait until it's done
2253+
setThirdEventSignal.Set()
22472254

22482255
// Verify we can get the third event
22492256
thirdMessage, err := getThirdEventHandle.GetResult()
@@ -2757,7 +2764,7 @@ func TestWorkflowTimeout(t *testing.T) {
27572764
})
27582765

27592766
t.Run("ManuallyCancelWorkflow", func(t *testing.T) {
2760-
cancelCtx, cancelFunc := WithTimeout(dbosCtx, 5*time.Second)
2767+
cancelCtx, cancelFunc := WithTimeout(dbosCtx, 5*time.Hour)
27612768
defer cancelFunc() // Ensure we clean up the context
27622769
handle, err := RunWorkflow(cancelCtx, waitForCancelWorkflow, "manual-cancel")
27632770
require.NoError(t, err, "failed to start manual cancel workflow")

0 commit comments

Comments
 (0)