@@ -16,6 +16,7 @@ import (
16
16
17
17
"github.com/coder/coder/v2/cli/clitest"
18
18
"github.com/coder/coder/v2/coderd/httpapi"
19
+ "github.com/coder/coder/v2/coderd/util/ptr"
19
20
"github.com/coder/coder/v2/codersdk"
20
21
"github.com/coder/coder/v2/testutil"
21
22
)
@@ -63,8 +64,8 @@ func Test_TaskStatus(t *testing.T) {
63
64
},
64
65
{
65
66
args : []string {"exists" },
66
- expectOutput :`STATE CHANGED STATUS STATE MESSAGE
67
- 0s ago running working Thinking furiously...` ,
67
+ expectOutput :`STATE CHANGED STATUSHEALTHY STATE MESSAGE
68
+ 0s ago runningtrue working Thinking furiously...` ,
68
69
hf :func (ctx context.Context ,now time.Time )func (w http.ResponseWriter ,r * http.Request ) {
69
70
return func (w http.ResponseWriter ,r * http.Request ) {
70
71
switch r .URL .Path {
@@ -83,6 +84,10 @@ func Test_TaskStatus(t *testing.T) {
83
84
Timestamp :now ,
84
85
Message :"Thinking furiously..." ,
85
86
},
87
+ WorkspaceAgentHealth :& codersdk.WorkspaceAgentHealth {
88
+ Healthy :true ,
89
+ },
90
+ WorkspaceAgentLifecycle :ptr .Ref (codersdk .WorkspaceAgentLifecycleReady ),
86
91
})
87
92
default :
88
93
t .Errorf ("unexpected path: %s" ,r .URL .Path )
@@ -93,12 +98,10 @@ func Test_TaskStatus(t *testing.T) {
93
98
{
94
99
args : []string {"exists" ,"--watch" },
95
100
expectOutput :`
96
- STATE CHANGED STATUS STATE MESSAGE
97
- 4s ago running
98
- 3s ago running working Reticulating splines...
99
- 2s ago running completed Splines reticulated successfully!
100
- 2s ago stopping completed Splines reticulated successfully!
101
- 2s ago stopped completed Splines reticulated successfully!` ,
101
+ STATE CHANGED STATUS HEALTHY STATE MESSAGE
102
+ 4s ago running true
103
+ 3s ago running true working Reticulating splines...
104
+ 2s ago running true complete Splines reticulated successfully!` ,
102
105
hf :func (ctx context.Context ,now time.Time )func (http.ResponseWriter ,* http.Request ) {
103
106
var calls atomic.Int64
104
107
return func (w http.ResponseWriter ,r * http.Request ) {
@@ -116,20 +119,32 @@ STATE CHANGED STATUS STATE MESSAGE
116
119
Status :codersdk .WorkspaceStatusPending ,
117
120
CreatedAt :now .Add (- 5 * time .Second ),
118
121
UpdatedAt :now .Add (- 5 * time .Second ),
122
+ WorkspaceAgentHealth :& codersdk.WorkspaceAgentHealth {
123
+ Healthy :true ,
124
+ },
125
+ WorkspaceAgentLifecycle :ptr .Ref (codersdk .WorkspaceAgentLifecycleReady ),
119
126
})
120
127
case 1 :
121
128
httpapi .Write (ctx ,w ,http .StatusOK , codersdk.Task {
122
129
ID :uuid .MustParse ("11111111-1111-1111-1111-111111111111" ),
123
130
Status :codersdk .WorkspaceStatusRunning ,
124
131
CreatedAt :now .Add (- 5 * time .Second ),
125
- UpdatedAt :now .Add (- 4 * time .Second ),
132
+ WorkspaceAgentHealth :& codersdk.WorkspaceAgentHealth {
133
+ Healthy :true ,
134
+ },
135
+ WorkspaceAgentLifecycle :ptr .Ref (codersdk .WorkspaceAgentLifecycleReady ),
136
+ UpdatedAt :now .Add (- 4 * time .Second ),
126
137
})
127
138
case 2 :
128
139
httpapi .Write (ctx ,w ,http .StatusOK , codersdk.Task {
129
140
ID :uuid .MustParse ("11111111-1111-1111-1111-111111111111" ),
130
141
Status :codersdk .WorkspaceStatusRunning ,
131
142
CreatedAt :now .Add (- 5 * time .Second ),
132
143
UpdatedAt :now .Add (- 4 * time .Second ),
144
+ WorkspaceAgentHealth :& codersdk.WorkspaceAgentHealth {
145
+ Healthy :true ,
146
+ },
147
+ WorkspaceAgentLifecycle :ptr .Ref (codersdk .WorkspaceAgentLifecycleReady ),
133
148
CurrentState :& codersdk.TaskStateEntry {
134
149
State :codersdk .TaskStateWorking ,
135
150
Timestamp :now .Add (- 3 * time .Second ),
@@ -142,6 +157,10 @@ STATE CHANGED STATUS STATE MESSAGE
142
157
Status :codersdk .WorkspaceStatusRunning ,
143
158
CreatedAt :now .Add (- 5 * time .Second ),
144
159
UpdatedAt :now .Add (- 4 * time .Second ),
160
+ WorkspaceAgentHealth :& codersdk.WorkspaceAgentHealth {
161
+ Healthy :true ,
162
+ },
163
+ WorkspaceAgentLifecycle :ptr .Ref (codersdk .WorkspaceAgentLifecycleReady ),
145
164
CurrentState :& codersdk.TaskStateEntry {
146
165
State :codersdk .TaskStateComplete ,
147
166
Timestamp :now .Add (- 2 * time .Second ),