@@ -18,7 +18,6 @@ import (
18
18
"fmt"
19
19
"strconv"
20
20
"testing"
21
- "time"
22
21
23
22
"github.com/containerd/containerd"
24
23
"github.com/containerd/containerd/namespaces"
@@ -53,23 +52,14 @@ func TestLaunchContainerWithRemoteSnapshotter_Isolated(t *testing.T) {
53
52
integtest .Prepare (t , integtest .WithDefaultNetwork ())
54
53
55
54
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 ))
62
56
require .NoError (t , err )
63
57
}
64
58
65
59
func TestLaunchMultipleContainersWithRemoteSnapshotter_Isolated (t * testing.T ) {
66
60
integtest .Prepare (t , integtest .WithDefaultNetwork ())
67
61
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 ())
73
63
74
64
numberOfVms := integtest .NumberOfVms
75
65
for vmID := 0 ; vmID < numberOfVms ; vmID ++ {
@@ -126,7 +116,7 @@ func launchContainerWithRemoteSnapshotterInVM(ctx context.Context, vmID string)
126
116
ContainerCount : 1 ,
127
117
})
128
118
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 )
130
120
}
131
121
defer fcClient .StopVM (ctx , & proto.StopVMRequest {VMID : vmID })
132
122
@@ -135,16 +125,16 @@ func launchContainerWithRemoteSnapshotterInVM(ctx context.Context, vmID string)
135
125
Metadata : fmt .Sprintf (dockerMetadataTemplate , "ghcr.io" , noAuth , noAuth ),
136
126
})
137
127
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 )
139
129
}
140
130
141
131
image , err := client .Pull (ctx , al2stargz ,
142
132
containerd .WithPullUnpack ,
143
133
containerd .WithPullSnapshotter (snapshotterName ),
144
- containerd .WithImageHandlerWrapper (source .AppendDefaultLabelsHandlerWrapper (al2stargz , 10 * 1024 * 1024 )),
134
+ containerd .WithImageHandlerWrapper (source .AppendDefaultLabelsHandlerWrapper (al2stargz , 10 * mib )),
145
135
)
146
136
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 )
148
138
}
149
139
defer client .ImageService ().Delete (ctx , image .Name ())
150
140
@@ -160,13 +150,13 @@ func launchContainerWithRemoteSnapshotterInVM(ctx context.Context, vmID string)
160
150
),
161
151
)
162
152
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 )
164
154
}
165
155
defer container .Delete (ctx , containerd .WithSnapshotCleanup )
166
156
167
157
_ , err = integtest .RunTask (ctx , container )
168
158
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 )
170
160
}
171
161
return nil
172
162
}
0 commit comments