@@ -173,24 +173,22 @@ func getStartContainerTestData() (*runtime.ContainerConfig, *runtime.PodSandboxC
173173
174174func TestGeneralContainerSpec (t * testing.T ) {
175175 testID := "test-id"
176- testPodID := "test-pod-id"
177176 testPid := uint32 (1234 )
178177 config , sandboxConfig , imageConfig , specCheck := getStartContainerTestData ()
179178 c := newTestCRIContainerdService ()
180- spec , err := c .generateContainerSpec (testID , testPodID , testPid , config , sandboxConfig , imageConfig , nil )
179+ spec , err := c .generateContainerSpec (testID , testPid , config , sandboxConfig , imageConfig , nil )
181180 assert .NoError (t , err )
182181 specCheck (t , testID , testPid , spec )
183182}
184183
185184func TestContainerSpecTty (t * testing.T ) {
186185 testID := "test-id"
187- testPodID := "test-pod-id"
188186 testPid := uint32 (1234 )
189187 config , sandboxConfig , imageConfig , specCheck := getStartContainerTestData ()
190188 c := newTestCRIContainerdService ()
191189 for _ , tty := range []bool {true , false } {
192190 config .Tty = tty
193- spec , err := c .generateContainerSpec (testID , testPodID , testPid , config , sandboxConfig , imageConfig , nil )
191+ spec , err := c .generateContainerSpec (testID , testPid , config , sandboxConfig , imageConfig , nil )
194192 assert .NoError (t , err )
195193 specCheck (t , testID , testPid , spec )
196194 assert .Equal (t , tty , spec .Process .Terminal )
@@ -199,13 +197,12 @@ func TestContainerSpecTty(t *testing.T) {
199197
200198func TestContainerSpecReadonlyRootfs (t * testing.T ) {
201199 testID := "test-id"
202- testPodID := "test-pod-id"
203200 testPid := uint32 (1234 )
204201 config , sandboxConfig , imageConfig , specCheck := getStartContainerTestData ()
205202 c := newTestCRIContainerdService ()
206203 for _ , readonly := range []bool {true , false } {
207204 config .Linux .SecurityContext .ReadonlyRootfs = readonly
208- spec , err := c .generateContainerSpec (testID , testPodID , testPid , config , sandboxConfig , imageConfig , nil )
205+ spec , err := c .generateContainerSpec (testID , testPid , config , sandboxConfig , imageConfig , nil )
209206 assert .NoError (t , err )
210207 specCheck (t , testID , testPid , spec )
211208 assert .Equal (t , readonly , spec .Root .Readonly )
@@ -214,7 +211,6 @@ func TestContainerSpecReadonlyRootfs(t *testing.T) {
214211
215212func TestContainerSpecWithExtraMounts (t * testing.T ) {
216213 testID := "test-id"
217- testPodID := "test-pod-id"
218214 testPid := uint32 (1234 )
219215 config , sandboxConfig , imageConfig , specCheck := getStartContainerTestData ()
220216 c := newTestCRIContainerdService ()
@@ -229,7 +225,7 @@ func TestContainerSpecWithExtraMounts(t *testing.T) {
229225 HostPath : "test-host-path-extra" ,
230226 Readonly : true ,
231227 }
232- spec , err := c .generateContainerSpec (testID , testPodID , testPid , config , sandboxConfig , imageConfig , []* runtime.Mount {extraMount })
228+ spec , err := c .generateContainerSpec (testID , testPid , config , sandboxConfig , imageConfig , []* runtime.Mount {extraMount })
233229 assert .NoError (t , err )
234230 specCheck (t , testID , testPid , spec )
235231 var mounts []runtimespec.Mount
@@ -313,23 +309,37 @@ func TestGenerateContainerMounts(t *testing.T) {
313309 securityContext * runtime.LinuxContainerSecurityContext
314310 expectedMounts []* runtime.Mount
315311 }{
316- "should setup ro /etc/hosts mount when rootfs is read-only" : {
312+ "should setup ro mount when rootfs is read-only" : {
317313 securityContext : & runtime.LinuxContainerSecurityContext {
318314 ReadonlyRootfs : true ,
319315 },
320- expectedMounts : []* runtime.Mount {{
321- ContainerPath : "/etc/hosts" ,
322- HostPath : testSandboxRootDir + "/hosts" ,
323- Readonly : true ,
324- }},
316+ expectedMounts : []* runtime.Mount {
317+ {
318+ ContainerPath : "/etc/hosts" ,
319+ HostPath : testSandboxRootDir + "/hosts" ,
320+ Readonly : true ,
321+ },
322+ {
323+ ContainerPath : resolvConfPath ,
324+ HostPath : testSandboxRootDir + "/resolv.conf" ,
325+ Readonly : true ,
326+ },
327+ },
325328 },
326- "should setup rw /etc/hosts mount when rootfs is read-write" : {
329+ "should setup rw mount when rootfs is read-write" : {
327330 securityContext : & runtime.LinuxContainerSecurityContext {},
328- expectedMounts : []* runtime.Mount {{
329- ContainerPath : "/etc/hosts" ,
330- HostPath : testSandboxRootDir + "/hosts" ,
331- Readonly : false ,
332- }},
331+ expectedMounts : []* runtime.Mount {
332+ {
333+ ContainerPath : "/etc/hosts" ,
334+ HostPath : testSandboxRootDir + "/hosts" ,
335+ Readonly : false ,
336+ },
337+ {
338+ ContainerPath : resolvConfPath ,
339+ HostPath : getResolvPath (testSandboxRootDir ),
340+ Readonly : false ,
341+ },
342+ },
333343 },
334344 } {
335345 config := & runtime.ContainerConfig {
0 commit comments