@@ -140,7 +140,7 @@ func TestJailerMicroVMExecution(t *testing.T) {
140
140
jailerFullRootPath := filepath .Join (jailerTestPath , "firecracker" , id )
141
141
os .MkdirAll (jailerTestPath , 0777 )
142
142
143
- socketPath := filepath .Join (jailerTestPath , "firecracker" , "api .socket" )
143
+ socketPath := filepath .Join (jailerTestPath , "firecracker" , "TestJailerMicroVMExecution .socket" )
144
144
logFifo := filepath .Join (testDataPath , "firecracker.log" )
145
145
metricsFifo := filepath .Join (testDataPath , "firecracker-metrics" )
146
146
defer func () {
@@ -257,7 +257,7 @@ func TestMicroVMExecution(t *testing.T) {
257
257
var nCpus int64 = 2
258
258
cpuTemplate := models .CPUTemplate (models .CPUTemplateT2 )
259
259
var memSz int64 = 256
260
- socketPath := filepath .Join (testDataPath , "firecracker .sock" )
260
+ socketPath := filepath .Join (testDataPath , "TestMicroVMExecution .sock" )
261
261
logFifo := filepath .Join (testDataPath , "firecracker.log" )
262
262
metricsFifo := filepath .Join (testDataPath , "firecracker-metrics" )
263
263
defer func () {
@@ -323,22 +323,25 @@ func TestMicroVMExecution(t *testing.T) {
323
323
t .Run ("TestAttachSecondaryDrive" , func (t * testing.T ) { testAttachSecondaryDrive (ctx , t , m ) })
324
324
t .Run ("TestAttachVsock" , func (t * testing.T ) { testAttachVsock (ctx , t , m ) })
325
325
t .Run ("SetMetadata" , func (t * testing.T ) { testSetMetadata (ctx , t , m ) })
326
- t .Run ("TestUpdateGuestDrive" , func (t * testing.T ) { testUpdateGuestDrive (vmmCtx , t , m ) })
327
- t .Run ("TestStartInstance" , func (t * testing.T ) { testStartInstance (vmmCtx , t , m ) })
326
+ t .Run ("TestUpdateGuestDrive" , func (t * testing.T ) { testUpdateGuestDrive (ctx , t , m ) })
327
+ t .Run ("TestStartInstance" , func (t * testing.T ) { testStartInstance (ctx , t , m ) })
328
328
329
329
// Let the VMM start and stabilize...
330
330
timer := time .NewTimer (5 * time .Second )
331
331
select {
332
332
case <- timer .C :
333
- t .Run ("TestStopVMM " , func (t * testing.T ) { testStopVMM (ctx , t , m ) })
333
+ t .Run ("TestShutdown " , func (t * testing.T ) { testShutdown (ctx , t , m ) })
334
334
case <- exitchannel :
335
335
// if we've already exited, there's no use waiting for the timer
336
336
}
337
+ // unconditionally stop the VM here. TestShutdown may have triggered a shutdown, but if it
338
+ // didn't for some reason, we still need to terminate it:
339
+ m .StopVMM ()
337
340
m .Wait (vmmCtx )
338
341
}
339
342
340
343
func TestStartVMM (t * testing.T ) {
341
- socketPath := filepath .Join ("testdata" , "fc-start-vmm-test .sock" )
344
+ socketPath := filepath .Join ("testdata" , "TestStartVMM .sock" )
342
345
defer os .Remove (socketPath )
343
346
cfg := Config {
344
347
SocketPath : socketPath ,
@@ -370,11 +373,10 @@ func TestStartVMM(t *testing.T) {
370
373
t .Errorf ("startVMM returned %s" , m .Wait (ctx ))
371
374
}
372
375
}
373
-
374
376
}
375
377
376
378
func TestStartVMMOnce (t * testing.T ) {
377
- socketPath := filepath .Join ("testdata" , "fc-start-vmm-test .sock" )
379
+ socketPath := filepath .Join ("testdata" , "TestStartVMMOnce .sock" )
378
380
defer os .Remove (socketPath )
379
381
380
382
cfg := Config {
@@ -410,6 +412,7 @@ func TestStartVMMOnce(t *testing.T) {
410
412
case <- timeout .Done ():
411
413
if timeout .Err () == context .DeadlineExceeded {
412
414
t .Log ("firecracker ran for 250ms" )
415
+ t .Run ("TestStopVMM" , func (t * testing.T ) { testStopVMM (ctx , t , m ) })
413
416
} else {
414
417
t .Errorf ("startVMM returned %s" , m .Wait (ctx ))
415
418
}
@@ -565,6 +568,13 @@ func testStopVMM(ctx context.Context, t *testing.T, m *Machine) {
565
568
}
566
569
}
567
570
571
+ func testShutdown (ctx context.Context , t * testing.T , m * Machine ) {
572
+ err := m .Shutdown (ctx )
573
+ if err != nil {
574
+ t .Errorf ("machine.Shutdown() failed: %s" , err )
575
+ }
576
+ }
577
+
568
578
func TestWaitForSocket (t * testing.T ) {
569
579
okClient := fctesting.MockClient {}
570
580
errClient := fctesting.MockClient {
0 commit comments