MCPcopy Index your code
hub / github.com/containerd/containerd / TestNriLinuxMemsetAdjustmentUpdate

Function TestNriLinuxMemsetAdjustmentUpdate

integration/nri_test.go:466–531  ·  view source on GitHub ↗

Test creation-time linux memset update of existing containers by NRI plugins.

(t *testing.T)

Source from the content-addressed store, hash-verified

464
465// Test creation-time linux memset update of existing containers by NRI plugins.
466func TestNriLinuxMemsetAdjustmentUpdate(t *testing.T) {
467 skipNriTestIfNecessary(t,
468 map[string]bool{
469 "not enough online memory nodes for test": len(getAvailableMemset(t)) < 2,
470 },
471 )
472
473 t.Log("Test that NRI plugins can update linux memsets of existing containers.")
474
475 var (
476 out = t.TempDir()
477 tc = &nriTest{
478 t: t,
479 plugins: []*mockPlugin{{}},
480 }
481 ctr0 string
482 updateMemset = func(p *mockPlugin, pod *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) {
483 var (
484 adjust *api.ContainerAdjustment
485 update []*api.ContainerUpdate
486 )
487 if ctr.Name == "ctr0" {
488 ctr0 = ctr.Id
489 adjust = &api.ContainerAdjustment{}
490 adjust.AddMount(&api.Mount{
491 Destination: "/out",
492 Source: out,
493 Type: "bind",
494 Options: []string{"bind"},
495 })
496 adjust.SetLinuxCPUSetMems(availableMemset[0])
497 } else {
498 update = []*api.ContainerUpdate{{}}
499 update[0].SetContainerId(ctr0)
500 update[0].SetLinuxCPUSetMems(availableMemset[1])
501 }
502 return adjust, update, nil
503 }
504 )
505
506 tc.plugins[0].createContainer = updateMemset
507 tc.setup()
508
509 podID := tc.runPod("pod0")
510 tc.startContainer(podID, "ctr0",
511 WithCommand("/bin/sh", "-c",
512 `prev=""
513 while true; do
514 mems="$(grep Mems_allowed_list: /proc/self/status)"
515 [ "$mems" != "$prev" ] && echo "$mems" > /out/result
516 mems="$prev"
517 sleep 0.2
518 done`),
519 )
520 tc.startContainer(podID, "ctr1",
521 WithCommand("/bin/sh", "-c", "sleep 3600"),
522 )
523

Callers

nothing calls this directly

Calls 8

skipNriTestIfNecessaryFunction · 0.85
getAvailableMemsetFunction · 0.85
WithCommandFunction · 0.85
waitForFileAndReadFunction · 0.85
LogMethod · 0.80
setupMethod · 0.80
runPodMethod · 0.80
startContainerMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…