MCPcopy
hub / github.com/moby/moby / TestEventsExecDie

Function TestEventsExecDie

integration/system/event_test.go:21–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestEventsExecDie(t *testing.T) {
22 skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME. Suspect may need to wait until container is running before exec")
23 ctx := setupTest(t)
24 apiClient := testEnv.APIClient()
25
26 cID := container.Run(ctx, t, apiClient)
27
28 res, err := apiClient.ExecCreate(ctx, cID, client.ExecCreateOptions{
29 Cmd: []string{"echo", "hello"},
30 })
31 assert.NilError(t, err)
32
33 result := apiClient.Events(ctx, client.EventsListOptions{
34 Filters: make(client.Filters).Add("container", cID).Add("event", string(events.ActionExecDie)),
35 })
36 msg := result.Messages
37 errs := result.Err
38
39 _, err = apiClient.ExecStart(ctx, res.ID, client.ExecStartOptions{
40 Detach: true,
41 TTY: false,
42 })
43 assert.NilError(t, err)
44
45 select {
46 case m := <-msg:
47 assert.Equal(t, m.Type, events.ContainerEventType)
48 assert.Equal(t, m.Actor.ID, cID)
49 assert.Equal(t, m.Action, events.ActionExecDie)
50 assert.Equal(t, m.Actor.Attributes["execID"], res.ID)
51 assert.Equal(t, m.Actor.Attributes["exitCode"], "0")
52 case err = <-errs:
53 assert.NilError(t, err)
54 case <-time.After(time.Second * 3):
55 t.Fatal("timeout hit")
56 }
57}
58
59// TestEventsNonBlocking verifies that the API responds immediately (not blocking),
60// if there are no events.

Callers

nothing calls this directly

Calls 8

RunFunction · 0.92
APIClientMethod · 0.80
EqualMethod · 0.80
setupTestFunction · 0.70
ExecCreateMethod · 0.65
EventsMethod · 0.65
AddMethod · 0.65
ExecStartMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…