Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions cli/command/container/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ func TestRunAttachTermination(t *testing.T) {
_ = p.Close()
}()

var conn net.Conn
killCh := make(chan struct{})
attachCh := make(chan struct{})
fakeCLI := test.NewFakeCli(&fakeClient{
Expand All @@ -156,13 +155,14 @@ func TestRunAttachTermination(t *testing.T) {
ID: "id",
}, nil
},
containerKillFunc: func(ctx context.Context, containerID, signal string) error {
killCh <- struct{}{}
containerKillFunc: func(ctx context.Context, containerID, sig string) error {
if sig == "TERM" {
close(killCh)
}
return nil
},
containerAttachFunc: func(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error) {
server, client := net.Pipe()
conn = server
t.Cleanup(func() {
_ = server.Close()
})
Expand All @@ -172,7 +172,7 @@ func TestRunAttachTermination(t *testing.T) {
waitFunc: func(_ string) (<-chan container.WaitResponse, <-chan error) {
responseChan := make(chan container.WaitResponse, 1)
errChan := make(chan error)

<-killCh
responseChan <- container.WaitResponse{
StatusCode: 130,
}
Expand Down Expand Up @@ -201,9 +201,7 @@ func TestRunAttachTermination(t *testing.T) {
case <-attachCh:
}

assert.NilError(t, syscall.Kill(syscall.Getpid(), syscall.SIGINT))
// end stream from "container" so that we'll detach
conn.Close()
Copy link
Collaborator

@vvoland vvoland Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason for removing conn.Close? @Benehiko

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still being flaky? From my testing closing the connection here didn't add anything.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: #5957

It's needed for the cmdErrC to actually receive the event. Removing it depended on the bug that was introduced.

I'm wondering if the flakiness was actually caused by the bug fixed by the mentioned PR 🤔

assert.NilError(t, syscall.Kill(syscall.Getpid(), syscall.SIGTERM))

select {
case <-killCh:
Expand Down
Loading