@@ -200,8 +200,11 @@ func TestWorkspace(t *testing.T) {
200
200
201
201
workspace , err := client .Workspace (ctx , workspace .ID )
202
202
require .NoError (t , err )
203
+
203
204
agent := workspace .LatestBuild .Resources [0 ].Agents [0 ]
204
205
206
+ assert .True (t , workspace .Health .Healthy )
207
+ assert .Len (t , workspace .Health .FailingAgents , 0 )
205
208
assert .True (t , agent .Health .Healthy )
206
209
assert .Empty (t , agent .Health .Reason )
207
210
})
@@ -239,7 +242,6 @@ func TestWorkspace(t *testing.T) {
239
242
var err error
240
243
testutil .Eventually (ctx , t , func (ctx context.Context ) bool {
241
244
workspace , err = client .Workspace (ctx , workspace .ID )
242
- t .Logf ("%#v" , workspace )
243
245
return assert .NoError (t , err ) && ! workspace .Health .Healthy
244
246
}, testutil .IntervalMedium )
245
247
@@ -250,6 +252,58 @@ func TestWorkspace(t *testing.T) {
250
252
assert .False (t , agent .Health .Healthy )
251
253
assert .NotEmpty (t , agent .Health .Reason )
252
254
})
255
+
256
+ t .Run ("Mixed health" , func (t * testing.T ) {
257
+ t .Parallel ()
258
+ client := coderdtest .New (t , & coderdtest.Options {IncludeProvisionerDaemon : true })
259
+ user := coderdtest .CreateFirstUser (t , client )
260
+ version := coderdtest .CreateTemplateVersion (t , client , user .OrganizationID , & echo.Responses {
261
+ Parse : echo .ParseComplete ,
262
+ ProvisionApply : []* proto.Provision_Response {{
263
+ Type : & proto.Provision_Response_Complete {
264
+ Complete : & proto.Provision_Complete {
265
+ Resources : []* proto.Resource {{
266
+ Name : "some" ,
267
+ Type : "example" ,
268
+ Agents : []* proto.Agent {{
269
+ Id : uuid .NewString (),
270
+ Name : "a1" ,
271
+ Auth : & proto.Agent_Token {},
272
+ }, {
273
+ Id : uuid .NewString (),
274
+ Name : "a2" ,
275
+ Auth : & proto.Agent_Token {},
276
+ ConnectionTimeoutSeconds : 1 ,
277
+ }},
278
+ }},
279
+ },
280
+ },
281
+ }},
282
+ })
283
+ coderdtest .AwaitTemplateVersionJob (t , client , version .ID )
284
+ template := coderdtest .CreateTemplate (t , client , user .OrganizationID , version .ID )
285
+ workspace := coderdtest .CreateWorkspace (t , client , user .OrganizationID , template .ID )
286
+ coderdtest .AwaitWorkspaceBuildJob (t , client , workspace .LatestBuild .ID )
287
+
288
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
289
+ defer cancel ()
290
+
291
+ var err error
292
+ testutil .Eventually (ctx , t , func (ctx context.Context ) bool {
293
+ workspace , err = client .Workspace (ctx , workspace .ID )
294
+ return assert .NoError (t , err ) && ! workspace .Health .Healthy
295
+ }, testutil .IntervalMedium )
296
+
297
+ assert .False (t , workspace .Health .Healthy )
298
+ assert .Len (t , workspace .Health .FailingAgents , 1 )
299
+
300
+ agent1 := workspace .LatestBuild .Resources [0 ].Agents [0 ]
301
+ assert .True (t , agent1 .Health .Healthy )
302
+ assert .Empty (t , agent1 .Health .Reason )
303
+ agent2 := workspace .LatestBuild .Resources [0 ].Agents [1 ]
304
+ assert .False (t , agent2 .Health .Healthy )
305
+ assert .NotEmpty (t , agent2 .Health .Reason )
306
+ })
253
307
})
254
308
}
255
309
0 commit comments