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 c0701da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ func (a *Agent) Status() *models.Status {
&a.graph.StartedAt,
&a.graph.FinishedAt,
)
if status.Status == scheduler.SchedulerStatus_None {
status.Status = scheduler.SchedulerStatus_Running
}
status.RequestId = a.requestId
status.Log = a.logFilename
if node := a.scheduler.HandlerNode(constants.OnExit); node != nil {
Expand Down
15 changes: 9 additions & 6 deletions internal/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ func TestMain(m *testing.M) {
}

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

status, err := testDAG(t, dag)
require.NoError(t, err)
_, dag := testDAGAsync(t, testConfig("agent_run.yaml"))
time.Sleep(100 * time.Millisecond)
status, _ := controller.New(dag.Config).GetLastStatus()
require.Equal(t, status.Status, scheduler.SchedulerStatus_Running)

assert.Equal(t, scheduler.SchedulerStatus_Success, status.Status)
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 c0701da

Please sign in to comment.