Test linux device injection by NRI plugins.
(t *testing.T)
| 257 | |
| 258 | // Test linux device injection by NRI plugins. |
| 259 | func TestNriLinuxDeviceInjection(t *testing.T) { |
| 260 | skipNriTestIfNecessary(t) |
| 261 | |
| 262 | t.Log("Test that NRI plugins can inject linux devices into containers.") |
| 263 | |
| 264 | var ( |
| 265 | out = t.TempDir() |
| 266 | tc = &nriTest{ |
| 267 | t: t, |
| 268 | plugins: []*mockPlugin{{}}, |
| 269 | } |
| 270 | injectDev = func(p *mockPlugin, pod *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { |
| 271 | adjust := &api.ContainerAdjustment{} |
| 272 | adjust.AddMount(&api.Mount{ |
| 273 | Destination: "/out", |
| 274 | Source: out, |
| 275 | Type: "bind", |
| 276 | Options: []string{"bind"}, |
| 277 | }) |
| 278 | adjust.AddDevice(&api.LinuxDevice{ |
| 279 | Path: "/dev/pie", |
| 280 | Type: "c", |
| 281 | Major: 31, |
| 282 | Minor: 41, |
| 283 | Uid: api.UInt32(uint32(11)), |
| 284 | Gid: api.UInt32(uint32(22)), |
| 285 | FileMode: api.FileMode(uint32(0664)), |
| 286 | }) |
| 287 | return adjust, nil, nil |
| 288 | } |
| 289 | ) |
| 290 | |
| 291 | tc.plugins[0].createContainer = injectDev |
| 292 | tc.setup() |
| 293 | |
| 294 | podID := tc.runPod("pod0") |
| 295 | tc.startContainer(podID, "ctr0", |
| 296 | WithCommand("/bin/sh", "-c", "stat -c %F-%a-%u:%g-%t:%T /dev/pie > /out/result; sleep 3600"), |
| 297 | ) |
| 298 | |
| 299 | chk, err := waitForFileAndRead(filepath.Join(out, "result"), time.Second) |
| 300 | require.NoError(t, err, "read result") |
| 301 | require.Equal(t, "character special file-664-11:22-1f:29\n", string(chk), "check result") |
| 302 | } |
| 303 | |
| 304 | // Test linux cpuset adjustment by NRI plugins. |
| 305 | func TestNriLinuxCpusetAdjustment(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…