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

Function testContainerUser

integration/client/container_linux_test.go:599–661  ·  view source on GitHub ↗
(t *testing.T, userstr, expectedOutput string)

Source from the content-addressed store, hash-verified

597}
598
599func testContainerUser(t *testing.T, userstr, expectedOutput string) {
600 client, err := newClient(t, address)
601 if err != nil {
602 t.Fatal(err)
603 }
604 defer client.Close()
605
606 var (
607 image Image
608 ctx, cancel = testContext(t)
609 id = strings.Replace(t.Name(), "/", "_", -1)
610 )
611 defer cancel()
612
613 image, err = client.GetImage(ctx, testImage)
614 if err != nil {
615 t.Fatal(err)
616 }
617 direct, err := newDirectIO(ctx, false)
618 if err != nil {
619 t.Fatal(err)
620 }
621 defer direct.Delete()
622 var (
623 wg sync.WaitGroup
624 buf = bytes.NewBuffer(nil)
625 )
626 wg.Go(func() {
627 io.Copy(buf, direct.Stdout)
628 })
629
630 container, err := client.NewContainer(ctx, id,
631 WithNewSnapshot(id, image),
632 WithNewSpec(oci.WithImageConfig(image), oci.WithUser(userstr), oci.WithProcessArgs("sh", "-c", "echo $(id -u):$(id -g)")),
633 )
634 if err != nil {
635 t.Fatal(err)
636 }
637 defer container.Delete(ctx, WithSnapshotCleanup)
638
639 task, err := container.NewTask(ctx, direct.IOCreate)
640 if err != nil {
641 t.Fatal(err)
642 }
643 defer task.Delete(ctx)
644
645 statusC, err := task.Wait(ctx)
646 if err != nil {
647 t.Fatal(err)
648 }
649
650 if err := task.Start(ctx); err != nil {
651 t.Fatal(err)
652 }
653 <-statusC
654
655 wg.Wait()
656

Callers 1

TestContainerUserFunction · 0.85

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
WithImageConfigFunction · 0.92
WithUserFunction · 0.92
WithProcessArgsFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithNewSpecFunction · 0.85
FatalMethod · 0.80
CopyMethod · 0.80
newDirectIOFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…