MCPcopy
hub / github.com/containerd/containerd / TestContainerUserID

Function TestContainerUserID

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

Source from the content-addressed store, hash-verified

840}
841
842func TestContainerUserID(t *testing.T) {
843 t.Parallel()
844
845 client, err := newClient(t, address)
846 if err != nil {
847 t.Fatal(err)
848 }
849 defer client.Close()
850
851 var (
852 image Image
853 ctx, cancel = testContext(t)
854 id = t.Name()
855 )
856 defer cancel()
857
858 image, err = client.GetImage(ctx, testImage)
859 if err != nil {
860 t.Fatal(err)
861 }
862 direct, err := newDirectIO(ctx, false)
863 if err != nil {
864 t.Fatal(err)
865 }
866 defer direct.Delete()
867 var (
868 wg sync.WaitGroup
869 buf = bytes.NewBuffer(nil)
870 )
871 wg.Go(func() {
872 io.Copy(buf, direct.Stdout)
873 })
874
875 // sys user in the busybox image has a uid and gid of 3.
876 container, err := client.NewContainer(ctx, id,
877 WithNewSnapshot(id, image),
878 WithNewSpec(oci.WithImageConfig(image), oci.WithUserID(3), oci.WithProcessArgs("sh", "-c", "echo $(id -u):$(id -g)")),
879 )
880 if err != nil {
881 t.Fatal(err)
882 }
883 defer container.Delete(ctx, WithSnapshotCleanup)
884
885 task, err := container.NewTask(ctx, direct.IOCreate)
886 if err != nil {
887 t.Fatal(err)
888 }
889 defer task.Delete(ctx)
890
891 statusC, err := task.Wait(ctx)
892 if err != nil {
893 t.Fatal(err)
894 }
895
896 if err := task.Start(ctx); err != nil {
897 t.Fatal(err)
898 }
899 <-statusC

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
WithImageConfigFunction · 0.92
WithUserIDFunction · 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…