@@ -2250,17 +2250,12 @@ func TestCreateVM_Isolated(t *testing.T) {
22502250 require .NoError (t , err , "unable to create client to containerd service at %s, is containerd running?" , integtest .ContainerdSockPath )
22512251 defer client .Close ()
22522252
2253- ctx := namespaces .WithNamespace (context .Background (), "default" )
2254-
2255- fcClient , err := integtest .NewFCControlClient (integtest .ContainerdSockPath )
2256- require .NoError (t , err , "failed to create ttrpc client" )
2257-
22582253 kernelArgs := integtest .DefaultRuntimeConfig .KernelArgs
22592254
22602255 type subtest struct {
22612256 name string
22622257 request proto.CreateVMRequest
2263- validate func (* testing.T , error )
2258+ validate func (* testing.T , context. Context , error )
22642259 validateUsesFindProcess bool
22652260 stopVM bool
22662261 }
@@ -2269,7 +2264,7 @@ func TestCreateVM_Isolated(t *testing.T) {
22692264 {
22702265 name : "Happy Case" ,
22712266 request : proto.CreateVMRequest {},
2272- validate : func (t * testing.T , err error ) {
2267+ validate : func (t * testing.T , ctx context. Context , err error ) {
22732268 require .NoError (t , err )
22742269 },
22752270 stopVM : true ,
@@ -2283,7 +2278,7 @@ func TestCreateVM_Isolated(t *testing.T) {
22832278 HostPath : "/var/lib/firecracker-containerd/runtime/rootfs-debug.img" ,
22842279 },
22852280 },
2286- validate : func (t * testing.T , err error ) {
2281+ validate : func (t * testing.T , ctx context. Context , err error ) {
22872282 require .NotNil (t , err , "expected an error but did not receive any" )
22882283 time .Sleep (5 * time .Second )
22892284 firecrackerProcesses , err := findProcess (ctx , findFirecracker )
@@ -2300,11 +2295,12 @@ func TestCreateVM_Isolated(t *testing.T) {
23002295 RootDrive : & proto.FirecrackerRootDrive {
23012296 HostPath : "/var/lib/firecracker-containerd/runtime/rootfs-debug.img" ,
23022297 },
2298+ TimeoutSeconds : 5 ,
23032299 },
2304- validate : func (t * testing.T , err error ) {
2300+ validate : func (t * testing.T , ctx context. Context , err error ) {
23052301 require .Error (t , err )
23062302 assert .Equal (t , codes .DeadlineExceeded , status .Code (err ))
2307- assert .Contains (t , err .Error (), "didn't start within 20s " )
2303+ assert .Contains (t , err .Error (), "didn't start within 5s " )
23082304 },
23092305 stopVM : true ,
23102306 },
@@ -2317,7 +2313,7 @@ func TestCreateVM_Isolated(t *testing.T) {
23172313 },
23182314 TimeoutSeconds : 60 ,
23192315 },
2320- validate : func (t * testing.T , err error ) {
2316+ validate : func (t * testing.T , ctx context. Context , err error ) {
23212317 require .NoError (t , err )
23222318 },
23232319 stopVM : true ,
@@ -2331,6 +2327,15 @@ func TestCreateVM_Isolated(t *testing.T) {
23312327 if ! s .validateUsesFindProcess {
23322328 t .Parallel ()
23332329 }
2330+
2331+ ctx , cancel := context .WithTimeout (context .Background (), 60 * time .Second )
2332+ defer cancel ()
2333+ ctx = namespaces .WithNamespace (ctx , "default" )
2334+
2335+ fcClient , err := integtest .NewFCControlClient (integtest .ContainerdSockPath )
2336+ require .NoError (t , err , "failed to create ttrpc client" )
2337+ defer fcClient .Close ()
2338+
23342339 vmID := testNameToVMID (t .Name ())
23352340
23362341 tempDir := t .TempDir ()
@@ -2349,7 +2354,7 @@ func TestCreateVM_Isolated(t *testing.T) {
23492354 requireNonEmptyFifo (t , metricsFile )
23502355
23512356 // Some test cases are expected to have an error, some are not.
2352- s .validate (t , createVMErr )
2357+ s .validate (t , ctx , createVMErr )
23532358
23542359 if createVMErr == nil && s .stopVM {
23552360 // Ensure the response fields are populated correctly
@@ -2360,6 +2365,8 @@ func TestCreateVM_Isolated(t *testing.T) {
23602365 TimeoutSeconds : 30 ,
23612366 })
23622367 require .Equal (t , status .Code (err ), codes .OK )
2368+
2369+ time .Sleep (500 * time .Millisecond )
23632370 }
23642371 }
23652372
@@ -2627,7 +2634,9 @@ func TestBrokenPipe_Isolated(t *testing.T) {
26272634 require .NoError (t , err , "unable to create client to containerd service at %s, is containerd running?" , integtest .ContainerdSockPath )
26282635 defer client .Close ()
26292636
2630- ctx := namespaces .WithNamespace (context .Background (), "default" )
2637+ ctx , cancel := context .WithTimeout (context .Background (), 60 * time .Second )
2638+ defer cancel ()
2639+ ctx = namespaces .WithNamespace (ctx , "default" )
26312640
26322641 image , err := alpineImage (ctx , client , defaultSnapshotterName )
26332642 require .NoError (t , err , "failed to get alpine image" )
@@ -2641,6 +2650,7 @@ func TestBrokenPipe_Isolated(t *testing.T) {
26412650 containerd .WithNewSpec (oci .WithProcessArgs ("/usr/bin/yes" )),
26422651 )
26432652 require .NoError (t , err )
2653+ defer c .Delete (ctx , containerd .WithSnapshotCleanup )
26442654
26452655 var stdout1 errorBuffer
26462656 var stderr1 errorBuffer
0 commit comments