Skip to content

Commit a1b30bf

Browse files
author
Noah Meyerhans
committed
TestMicroVMExecution test cleanup
Clean up context usage Make sure the firecracker process is terminated Signed-off-by: Noah Meyerhans <[email protected]>
1 parent cca7243 commit a1b30bf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

machine_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,17 +323,20 @@ func TestMicroVMExecution(t *testing.T) {
323323
t.Run("TestAttachSecondaryDrive", func(t *testing.T) { testAttachSecondaryDrive(ctx, t, m) })
324324
t.Run("TestAttachVsock", func(t *testing.T) { testAttachVsock(ctx, t, m) })
325325
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) })
328328

329329
// Let the VMM start and stabilize...
330330
timer := time.NewTimer(5 * time.Second)
331331
select {
332332
case <-timer.C:
333-
t.Run("TestShutdown", func(t *testing.T) { testShutdown(vmmCtx, t, m) })
333+
t.Run("TestShutdown", func(t *testing.T) { testShutdown(ctx, t, m) })
334334
case <-exitchannel:
335335
// if we've already exited, there's no use waiting for the timer
336336
}
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()
337340
m.Wait(vmmCtx)
338341
}
339342

0 commit comments

Comments
 (0)