@@ -583,35 +583,69 @@ func TestLongUnixSocketPath_Isolated(t *testing.T) {
583
583
// default location we store state results in a path like
584
584
// "/run/firecracker-containerd/default/<vmID>" (with len 112).
585
585
const maxUnixSockLen = 108
586
- vmID := strings .Repeat ("x" , 76 )
586
+ vmID := strings .Repeat ("x" , 72 )
587
587
588
588
ctx := namespaces .WithNamespace (context .Background (), "default" )
589
589
590
590
pluginClient , err := ttrpcutil .NewClient (containerdSockPath + ".ttrpc" )
591
591
require .NoError (t , err , "failed to create ttrpc client" )
592
592
593
- fcClient := fccontrol .NewFirecrackerClient (pluginClient .Client ())
594
- _ , err = fcClient .CreateVM (ctx , & proto.CreateVMRequest {
595
- VMID : vmID ,
596
- NetworkInterfaces : []* proto.FirecrackerNetworkInterface {},
597
- })
598
- 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
+ }
599
618
600
- // double-check that the sockets are at the expected path and that their absolute
601
- // length exceeds 108 bytes
602
- shimDir , err := vm .ShimDir (cfg .ShimBaseDir , "default" , vmID )
603
- 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
+ }
604
638
605
- _ , err = os .Stat (shimDir .FirecrackerSockPath ())
606
- require .NoError (t , err , "failed to stat firecracker socket path" )
607
- if len (shimDir .FirecrackerSockPath ()) <= maxUnixSockLen {
608
- assert .Failf (t , "firecracker sock absolute path %q is not greater than max unix socket path length" , shimDir .FirecrackerSockPath ())
609
- }
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
+ }
610
645
611
- _ , err = os .Stat (shimDir .FirecrackerVSockPath ())
612
- require .NoError (t , err , "failed to stat firecracker vsock path" )
613
- if len (shimDir .FirecrackerVSockPath ()) <= maxUnixSockLen {
614
- 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
+ })
615
649
}
616
650
}
617
651
0 commit comments