@@ -470,9 +470,12 @@ func testMultipleExecs(
470470 close (execStdouts )
471471
472472 if jailerConfig != nil {
473+ dir , err := vm .ShimDir (shimBaseDir (), "default" , vmIDStr )
474+ require .NoError (t , err )
475+
473476 jailer := & runcJailer {
474477 Config : runcJailerConfig {
475- OCIBundlePath : filepath . Join ( shimBaseDir (), vmIDStr ),
478+ OCIBundlePath : dir . RootPath ( ),
476479 },
477480 vmID : vmIDStr ,
478481 }
@@ -580,35 +583,69 @@ func TestLongUnixSocketPath_Isolated(t *testing.T) {
580583 // default location we store state results in a path like
581584 // "/run/firecracker-containerd/default/<vmID>" (with len 112).
582585 const maxUnixSockLen = 108
583- vmID := strings .Repeat ("x" , 76 )
586+ vmID := strings .Repeat ("x" , 72 )
584587
585588 ctx := namespaces .WithNamespace (context .Background (), "default" )
586589
587590 pluginClient , err := ttrpcutil .NewClient (containerdSockPath + ".ttrpc" )
588591 require .NoError (t , err , "failed to create ttrpc client" )
589592
590- fcClient := fccontrol .NewFirecrackerClient (pluginClient .Client ())
591- _ , err = fcClient .CreateVM (ctx , & proto.CreateVMRequest {
592- VMID : vmID ,
593- NetworkInterfaces : []* proto.FirecrackerNetworkInterface {},
594- })
595- require .NoError (t , err , "failed to create VM" )
593+ subtests := []struct {
594+ name string
595+ request proto.CreateVMRequest
596+ }{
597+ {
598+ name : "Without Jailer" ,
599+ request : proto.CreateVMRequest {
600+ VMID : vmID + "noop" ,
601+ NetworkInterfaces : []* proto.FirecrackerNetworkInterface {},
602+ },
603+ },
604+ {
605+ name : "With Jailer" ,
606+ request : proto.CreateVMRequest {
607+ // We somehow cannot use the same VM ID here.
608+ // https://github.com/firecracker-microvm/firecracker-containerd/issues/409
609+ VMID : vmID + "jail" ,
610+ NetworkInterfaces : []* proto.FirecrackerNetworkInterface {},
611+ JailerConfig : & proto.JailerConfig {
612+ UID : 30000 ,
613+ GID : 30000 ,
614+ },
615+ },
616+ },
617+ }
596618
597- // double-check that the sockets are at the expected path and that their absolute
598- // length exceeds 108 bytes
599- shimDir , err := vm .ShimDir (cfg .ShimBaseDir , "default" , vmID )
600- require .NoError (t , err , "failed to get shim dir" )
619+ fcClient := fccontrol .NewFirecrackerClient (pluginClient .Client ())
620+ for _ , subtest := range subtests {
621+ request := subtest .request
622+ vmID := request .VMID
623+ t .Run (subtest .name , func (t * testing.T ) {
624+ _ , err = fcClient .CreateVM (ctx , & request )
625+ require .NoError (t , err , "failed to create VM" )
626+
627+ // double-check that the sockets are at the expected path and that their absolute
628+ // length exceeds 108 bytes
629+ shimDir , err := vm .ShimDir (cfg .ShimBaseDir , "default" , vmID )
630+ require .NoError (t , err , "failed to get shim dir" )
631+
632+ if request .JailerConfig == nil {
633+ _ , err = os .Stat (shimDir .FirecrackerSockPath ())
634+ require .NoError (t , err , "failed to stat firecracker socket path" )
635+ if len (shimDir .FirecrackerSockPath ()) <= maxUnixSockLen {
636+ assert .Failf (t , "firecracker sock absolute path %q is not greater than max unix socket path length" , shimDir .FirecrackerSockPath ())
637+ }
601638
602- _ , err = os .Stat (shimDir .FirecrackerSockPath ())
603- require .NoError (t , err , "failed to stat firecracker socket path" )
604- if len (shimDir .FirecrackerSockPath ()) <= maxUnixSockLen {
605- assert .Failf (t , "firecracker sock absolute path %q is not greater than max unix socket path length" , shimDir .FirecrackerSockPath ())
606- }
639+ _ , err = os .Stat (shimDir .FirecrackerVSockPath ())
640+ require .NoError (t , err , "failed to stat firecracker vsock path" )
641+ if len (shimDir .FirecrackerVSockPath ()) <= maxUnixSockLen {
642+ assert .Failf (t , "firecracker vsock absolute path %q is not greater than max unix socket path length" , shimDir .FirecrackerVSockPath ())
643+ }
644+ }
607645
608- _ , err = os .Stat (shimDir .FirecrackerVSockPath ())
609- require .NoError (t , err , "failed to stat firecracker vsock path" )
610- if len (shimDir .FirecrackerVSockPath ()) <= maxUnixSockLen {
611- assert .Failf (t , "firecracker vsock absolute path %q is not greater than max unix socket path length" , shimDir .FirecrackerVSockPath ())
646+ _ , err = fcClient .StopVM (ctx , & proto.StopVMRequest {VMID : vmID })
647+ require .NoError (t , err )
648+ })
612649 }
613650}
614651
0 commit comments