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

Function TestTaskUpdate

integration/client/container_linux_test.go:61–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59var testUserNSImage = images.Get(images.VolumeOwnership)
60
61func TestTaskUpdate(t *testing.T) {
62 t.Parallel()
63
64 client, err := newClient(t, address)
65 if err != nil {
66 t.Fatal(err)
67 }
68 defer client.Close()
69
70 var (
71 ctx, cancel = testContext(t)
72 id = t.Name()
73 )
74 defer cancel()
75
76 image, err := client.GetImage(ctx, testImage)
77 if err != nil {
78 t.Fatal(err)
79 }
80 limit := int64(32 * 1024 * 1024)
81 memory := func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error {
82 s.Linux.Resources.Memory = &specs.LinuxMemory{
83 Limit: &limit,
84 }
85 return nil
86 }
87 container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image),
88 WithNewSpec(oci.WithImageConfig(image), withProcessArgs("sleep", "30"), memory))
89 if err != nil {
90 t.Fatal(err)
91 }
92 defer container.Delete(ctx, WithSnapshotCleanup)
93
94 task, err := container.NewTask(ctx, empty())
95 if err != nil {
96 t.Fatal(err)
97 }
98 defer task.Delete(ctx)
99
100 statusC, err := task.Wait(ctx)
101 if err != nil {
102 t.Fatal(err)
103 }
104
105 var (
106 cgroup cgroup1.Cgroup
107 cgroup2 *cgroupsv2.Manager
108 )
109 // check that the task has a limit of 32mb
110 if cgroups.Mode() == cgroups.Unified {
111 groupPath, err := cgroupsv2.PidGroupPath(int(task.Pid()))
112 if err != nil {
113 t.Fatal(err)
114 }
115 cgroup2, err = cgroupsv2.Load(groupPath)
116 if err != nil {
117 t.Fatal(err)
118 }

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
UpdateMethod · 0.95
WithImageConfigFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithNewSpecFunction · 0.85
emptyFunction · 0.85
FatalMethod · 0.80
LoadMethod · 0.80
withProcessArgsFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…