MCPcopy
hub / github.com/containerd/containerd / TestContainerCloseIO

Function TestContainerCloseIO

integration/client/container_test.go:702–756  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

700}
701
702func TestContainerCloseIO(t *testing.T) {
703 t.Parallel()
704
705 client, err := newClient(t, address)
706 if err != nil {
707 t.Fatal(err)
708 }
709 defer client.Close()
710
711 var (
712 image Image
713 ctx, cancel = testContext(t)
714 id = t.Name()
715 )
716 defer cancel()
717
718 image, err = client.GetImage(ctx, testImage)
719 if err != nil {
720 t.Fatal(err)
721 }
722
723 container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), withCat()))
724 if err != nil {
725 t.Fatal(err)
726 }
727 defer container.Delete(ctx, WithSnapshotCleanup)
728
729 stdout := bytes.NewBuffer(nil)
730
731 r, w, err := os.Pipe()
732 if err != nil {
733 t.Fatal(err)
734 }
735
736 task, err := container.NewTask(ctx, cio.NewCreator(cio.WithStreams(r, stdout, io.Discard)))
737 if err != nil {
738 t.Fatal(err)
739 }
740 defer task.Delete(ctx)
741
742 statusC, err := task.Wait(ctx)
743 if err != nil {
744 t.Fatal(err)
745 }
746
747 if err := task.Start(ctx); err != nil {
748 t.Fatal(err)
749 }
750 w.Close()
751 if err := task.CloseIO(ctx, WithStdinCloser); err != nil {
752 t.Error(err)
753 }
754
755 <-statusC
756}
757
758func TestDeleteRunningContainer(t *testing.T) {
759 t.Parallel()

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
WithImageConfigFunction · 0.92
NewCreatorFunction · 0.92
WithStreamsFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithNewSpecFunction · 0.85
FatalMethod · 0.80
PipeMethod · 0.80
withCatFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…