(t *testing.T)
| 59 | var testUserNSImage = images.Get(images.VolumeOwnership) |
| 60 | |
| 61 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…