Skip to content

test: refactor container_stop_linux.go to use Tigron#4863

Open
opjt wants to merge 1 commit intocontainerd:mainfrom
opjt:issues_4613_container_stop_linux_test
Open

test: refactor container_stop_linux.go to use Tigron#4863
opjt wants to merge 1 commit intocontainerd:mainfrom
opjt:issues_4613_container_stop_linux_test

Conversation

@opjt
Copy link
Copy Markdown
Contributor

@opjt opjt commented Apr 22, 2026

Comment thread cmd/nerdctl/container/container_stop_linux_test.go Outdated
Comment thread cmd/nerdctl/container/container_stop_linux_test.go Outdated
Comment thread cmd/nerdctl/container/container_stop_linux_test.go Outdated
Comment thread cmd/nerdctl/container/container_stop_linux_test.go Outdated
Comment thread cmd/nerdctl/container/container_stop_linux_test.go Outdated
Comment thread cmd/nerdctl/container/container_stop_linux_test.go Outdated
@opjt opjt force-pushed the issues_4613_container_stop_linux_test branch from 9519677 to 358c028 Compare April 26, 2026 06:54
@opjt opjt requested a review from haytok April 26, 2026 07:00
@opjt
Copy link
Copy Markdown
Contributor Author

opjt commented Apr 27, 2026

@haytok thanks for your review! Could you take another look?

Comment thread cmd/nerdctl/container/container_stop_linux_test.go Outdated
Comment thread cmd/nerdctl/container/container_stop_linux_test.go Outdated
Comment on lines -197 to -200
elapsed := time.Since(start)
testCase.Setup = func(data test.Data, helpers test.Helpers) {
// Start a container that sleeps forever
helpers.Ensure("run", "-d", "--name", data.Identifier(), testutil.CommonImage, "sleep", nerdtest.Infinity)
}

// The container should get the SIGKILL before the 10s default timeout
assert.Assert(t, elapsed < 10*time.Second, "Container did not respect --timeout flag")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did you delete this test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

replaced cmd.WithTimeout(10 * time.Second)

Comment on lines -179 to -182
elapsed := time.Since(start)
testCase.Expected = test.Expects(expect.ExitCodeSuccess, nil, nil)

// The container should be stopped almost immediately, well before the 5-second timeout
assert.Assert(t, elapsed < 5*time.Second, "Container wasn't stopped immediately with SIGKILL")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did you delete this test?

Copy link
Copy Markdown
Contributor Author

@opjt opjt Apr 29, 2026

Choose a reason for hiding this comment

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

The elapsed time assertion was replaced with cmd.WithTimeout(5s), which is more direct — if the stop command doesn't complete within 5 seconds, the test fails immediately

return nil
}

assert.NilError(t, check(5))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Has this been deleted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will add it back..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added it back in testCase.Setup

Comment on lines +96 to +97
helpers.Fail("exec", data.Labels().Get("containerName"), "ps")
assert.Assert(t, httpCheck(data, 1) != nil, "expected HTTP to fail after stop")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't this be split into a separate subtest?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think keeping them in the same subtest is fine as a verification that stop was successful.

Signed-off-by: Park jungtae <jtpark1957@gmail.com>
@opjt opjt force-pushed the issues_4613_container_stop_linux_test branch from 358c028 to c55d91b Compare May 2, 2026 00:59
@opjt opjt requested a review from haytok May 2, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants