@@ -18,7 +18,6 @@ import (
1818 "fmt"
1919 "strconv"
2020 "testing"
21- "time"
2221
2322 "github.com/containerd/containerd"
2423 "github.com/containerd/containerd/namespaces"
@@ -53,23 +52,14 @@ func TestLaunchContainerWithRemoteSnapshotter_Isolated(t *testing.T) {
5352 integtest .Prepare (t , integtest .WithDefaultNetwork ())
5453
5554 vmID := 0
56-
57- testTimeout := 300 * time .Second
58- ctx , cancel := context .WithTimeout (context .Background (), testTimeout )
59- defer cancel ()
60-
61- err := launchContainerWithRemoteSnapshotterInVM (ctx , strconv .Itoa (vmID ))
55+ err := launchContainerWithRemoteSnapshotterInVM (context .Background (), strconv .Itoa (vmID ))
6256 require .NoError (t , err )
6357}
6458
6559func TestLaunchMultipleContainersWithRemoteSnapshotter_Isolated (t * testing.T ) {
6660 integtest .Prepare (t , integtest .WithDefaultNetwork ())
6761
68- testTimeout := 600 * time .Second
69- ctx , cancel := context .WithTimeout (context .Background (), testTimeout )
70- defer cancel ()
71-
72- eg , ctx := errgroup .WithContext (ctx )
62+ eg , ctx := errgroup .WithContext (context .Background ())
7363
7464 numberOfVms := integtest .NumberOfVms
7565 for vmID := 0 ; vmID < numberOfVms ; vmID ++ {
@@ -126,7 +116,7 @@ func launchContainerWithRemoteSnapshotterInVM(ctx context.Context, vmID string)
126116 ContainerCount : 1 ,
127117 })
128118 if err != nil {
129- return fmt .Errorf ("Failed to create microVM [%s] [%v] " , vmID , err )
119+ return fmt .Errorf ("Failed to create VM [%s]: %w " , vmID , err )
130120 }
131121 defer fcClient .StopVM (ctx , & proto.StopVMRequest {VMID : vmID })
132122
@@ -135,16 +125,16 @@ func launchContainerWithRemoteSnapshotterInVM(ctx context.Context, vmID string)
135125 Metadata : fmt .Sprintf (dockerMetadataTemplate , "ghcr.io" , noAuth , noAuth ),
136126 })
137127 if err != nil {
138- return fmt .Errorf ("Failed to configure VM metadata for registry resolution [%v] " , err )
128+ return fmt .Errorf ("Failed to configure VM metadata for registry resolution: %w " , err )
139129 }
140130
141131 image , err := client .Pull (ctx , al2stargz ,
142132 containerd .WithPullUnpack ,
143133 containerd .WithPullSnapshotter (snapshotterName ),
144- containerd .WithImageHandlerWrapper (source .AppendDefaultLabelsHandlerWrapper (al2stargz , 10 * 1024 * 1024 )),
134+ containerd .WithImageHandlerWrapper (source .AppendDefaultLabelsHandlerWrapper (al2stargz , 10 * mib )),
145135 )
146136 if err != nil {
147- return fmt .Errorf ("Failed to pull image for VM: %s [%v] " , vmID , err )
137+ return fmt .Errorf ("Failed to pull image for VM[%s]: %w " , vmID , err )
148138 }
149139 defer client .ImageService ().Delete (ctx , image .Name ())
150140
@@ -160,13 +150,13 @@ func launchContainerWithRemoteSnapshotterInVM(ctx context.Context, vmID string)
160150 ),
161151 )
162152 if err != nil {
163- return fmt .Errorf ("Failed to create container in VM: %s, [%v] " , vmID , err )
153+ return fmt .Errorf ("Failed to create container in VM[%s]: %w " , vmID , err )
164154 }
165155 defer container .Delete (ctx , containerd .WithSnapshotCleanup )
166156
167157 _ , err = integtest .RunTask (ctx , container )
168158 if err != nil {
169- return fmt .Errorf ("Failed to run task in VM: %s [%v] " , vmID , err )
159+ return fmt .Errorf ("Failed to run task in VM[%s]: %w " , vmID , err )
170160 }
171161 return nil
172162}
0 commit comments