Skip to content

Commit

Permalink
fix: write running status not none on the first step
Browse files Browse the repository at this point in the history
  • Loading branch information
yottahmd committed May 20, 2022
1 parent 07fe01c commit 58c6511
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ func (a *Agent) run() error {
}
}()

go func() {
time.Sleep(time.Millisecond * 100)
a.dbWriter.Write(a.Status())
}()

lastErr := a.scheduler.Schedule(a.graph, done)
status := a.Status()

Expand Down
16 changes: 11 additions & 5 deletions internal/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ func TestMain(m *testing.M) {
}

func TestRunDAG(t *testing.T) {
dag, err := controller.FromConfig(testConfig("agent_run.yaml"))
require.NoError(t, err)
_, dag := testDAGAsync(t, testConfig("agent_run.yaml"))

status, err := testDAG(t, dag)
require.NoError(t, err)
time.Sleep(100 * time.Millisecond)

assert.Equal(t, scheduler.SchedulerStatus_Success, status.Status)
status, _ := controller.New(dag.Config).GetLastStatus()
require.Equal(t, status.Status, scheduler.SchedulerStatus_Running)
require.Equal(t, status.Nodes[0].Status, scheduler.NodeStatus_Running)

require.Eventually(t, func() bool {
status, err := controller.New(dag.Config).GetLastStatus()
require.NoError(t, err)
return status.Status == scheduler.SchedulerStatus_Success
}, time.Second*2, time.Millisecond*100)
}

func TestCheckRunning(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/agent_run.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "test"
steps:
- name: "1"
command: "true"
command: "sleep 1"

0 comments on commit 58c6511

Please sign in to comment.