(t *testing.T)
| 587 | } |
| 588 | |
| 589 | func TestContainerPids(t *testing.T) { |
| 590 | t.Parallel() |
| 591 | |
| 592 | client, err := newClient(t, address) |
| 593 | if err != nil { |
| 594 | t.Fatal(err) |
| 595 | } |
| 596 | defer client.Close() |
| 597 | |
| 598 | var ( |
| 599 | image Image |
| 600 | ctx, cancel = testContext(t) |
| 601 | id = t.Name() |
| 602 | ) |
| 603 | defer cancel() |
| 604 | |
| 605 | image, err = client.GetImage(ctx, testImage) |
| 606 | if err != nil { |
| 607 | t.Fatal(err) |
| 608 | } |
| 609 | |
| 610 | container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), longCommand)) |
| 611 | if err != nil { |
| 612 | t.Fatal(err) |
| 613 | } |
| 614 | defer container.Delete(ctx, WithSnapshotCleanup) |
| 615 | |
| 616 | task, err := container.NewTask(ctx, empty()) |
| 617 | if err != nil { |
| 618 | t.Fatal(err) |
| 619 | } |
| 620 | defer task.Delete(ctx) |
| 621 | |
| 622 | statusC, err := task.Wait(ctx) |
| 623 | if err != nil { |
| 624 | t.Fatal(err) |
| 625 | } |
| 626 | |
| 627 | if err := task.Start(ctx); err != nil { |
| 628 | t.Fatal(err) |
| 629 | } |
| 630 | |
| 631 | taskPid := task.Pid() |
| 632 | if taskPid < 1 { |
| 633 | t.Errorf("invalid task pid %d", taskPid) |
| 634 | } |
| 635 | |
| 636 | tryUntil := time.Now().Add(time.Second) |
| 637 | checkPids := func() bool { |
| 638 | processes, err := task.Pids(ctx) |
| 639 | if err != nil { |
| 640 | t.Fatal(err) |
| 641 | } |
| 642 | |
| 643 | l := len(processes) |
| 644 | // The point of this test is to see that we successfully can get all of |
| 645 | // the pids running in the container and they match the number expected, |
| 646 | // but for Windows this concept is a bit different. Windows containers |
nothing calls this directly
no test coverage detected
searching dependent graphs…