Skip to content

Commit fac24a1

Browse files
authored
Merge pull request #99 from cschleiden/schedule-ids
Set schedule event ids to 0 for workflow started events
2 parents e3f875a + 64c86de commit fac24a1

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

backend/test/e2e.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,28 @@ func EndToEndBackendTest(t *testing.T, setup func() TestBackend, teardown func(b
3636
require.Equal(t, "hello world", output)
3737
},
3838
},
39+
{
40+
name: "SimpleWorkflow_ExpectedHistory",
41+
f: func(t *testing.T, ctx context.Context, c client.Client, w worker.Worker, b TestBackend) {
42+
wf := func(ctx workflow.Context, msg string) (string, error) {
43+
return msg + " world", nil
44+
}
45+
register(t, ctx, w, []interface{}{wf}, nil)
46+
47+
instance := runWorkflow(t, ctx, c, wf, "hello")
48+
49+
require.NoError(t, c.WaitForWorkflowInstance(ctx, instance, time.Second*10))
50+
51+
events, err := b.GetWorkflowInstanceHistory(ctx, instance, nil)
52+
require.NoError(t, err)
53+
54+
require.Equal(t, history.EventType_WorkflowTaskStarted, events[0].Type)
55+
require.Equal(t, history.EventType_WorkflowExecutionStarted, events[1].Type)
56+
require.Equal(t, int64(0), events[1].ScheduleEventID)
57+
require.Equal(t, history.EventType_WorkflowExecutionFinished, events[2].Type)
58+
require.Equal(t, int64(0), events[2].ScheduleEventID)
59+
},
60+
},
3961
{
4062
name: "UnregisteredWorkflow_Errors",
4163
f: func(t *testing.T, ctx context.Context, c client.Client, w worker.Worker, b TestBackend) {

internal/workflow/executor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ func (e *executor) processCommands(ctx context.Context, t *task.Workflow) (bool,
489489
Name: a.Name,
490490
Inputs: a.Inputs,
491491
},
492-
history.ScheduleEventID(c.ID),
492+
history.ScheduleEventID(0),
493493
),
494494
})
495495

@@ -564,7 +564,7 @@ func (e *executor) processCommands(ctx context.Context, t *task.Workflow) (bool,
564564
Result: a.Result,
565565
Error: a.Error,
566566
},
567-
history.ScheduleEventID(c.ID),
567+
history.ScheduleEventID(0),
568568
))
569569

570570
if instance.SubWorkflow() {

0 commit comments

Comments
 (0)