MCPcopy
hub / github.com/containerd/containerd / TestContainerKill

Function TestContainerKill

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

Source from the content-addressed store, hash-verified

811}
812
813func TestContainerKill(t *testing.T) {
814 t.Parallel()
815
816 client, err := newClient(t, address)
817 if err != nil {
818 t.Fatal(err)
819 }
820 defer client.Close()
821
822 var (
823 image Image
824 ctx, cancel = testContext(t)
825 id = t.Name()
826 )
827 defer cancel()
828
829 image, err = client.GetImage(ctx, testImage)
830 if err != nil {
831 t.Fatal(err)
832 }
833
834 container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), longCommand))
835 if err != nil {
836 t.Fatal(err)
837 }
838 defer container.Delete(ctx)
839
840 task, err := container.NewTask(ctx, empty())
841 if err != nil {
842 t.Fatal(err)
843 }
844 defer task.Delete(ctx)
845
846 statusC, err := task.Wait(ctx)
847 if err != nil {
848 t.Fatal(err)
849 }
850
851 if err := task.Start(ctx); err != nil {
852 t.Fatal(err)
853 }
854 if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
855 t.Fatal(err)
856 }
857 <-statusC
858
859 err = task.Kill(ctx, syscall.SIGTERM)
860 if err == nil {
861 t.Fatal("second call to kill should return an error")
862 }
863 if !errdefs.IsNotFound(err) {
864 t.Errorf("expected error %q but received %q", errdefs.ErrNotFound, err)
865 }
866}
867
868func TestKillContainerDeletedByRunc(t *testing.T) {
869 t.Parallel()

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
WithImageConfigFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithNewSpecFunction · 0.85
emptyFunction · 0.85
FatalMethod · 0.80
CloseMethod · 0.65
NameMethod · 0.65
GetImageMethod · 0.65
NewContainerMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…