refactor: migrate container_create_linux_test.go to nerdtest.Setup#4900
refactor: migrate container_create_linux_test.go to nerdtest.Setup#4900ogulcanaydogan wants to merge 4 commits into
Conversation
Migrate TestCreateWithLabel, TestCreateWithMACAddress, TestCreateWithTty, and TestCreateFromOCIArchive from testutil.NewBase to the Tigron-based nerdtest.Setup pattern. Also fix TestUsernsMappingCreateCmd which called nerdtest.Setup() without using its return value; now uses the returned *test.Case directly. Helper function removeUsernsConfig updated to accept tig.T instead of *testing.T to align with the rest of the Tigron-based test infrastructure. Part of containerd#4613. Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
|
TestCreateWithTty seems failing |
With -t, the container's output goes through a pseudoTTY. Attaching via "start -a" does not reliably forward PTY output through Tigron's subprocess pipe, causing the stty check to fail on certain containerd versions (e.g. v1.7.30). Match the original test's approach: start the container without -a, then read its output via "nerdctl logs" which goes through the log driver and is always available after the container exits. Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
|
Thanks for flagging. The issue: with |
| } | ||
| testCase.Expected = func(data test.Data, helpers test.Helpers) *test.Expected { | ||
| return &test.Expected{ | ||
| ExitCode: 0, |
There was a problem hiding this comment.
Use constants defined in the tigron framework for the exit codes. Change them in other test cases as well
Replace hardcoded exit code literals (0, 1) in Tigron test.Expected structs with the named constants from the expect package: ExitCodeSuccess, ExitCodeGenericFail. Existing ExitCodeNoCheck usages were already correct. Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
|
Thanks for the review. Replaced all hardcoded exit code literals in Tigron Expected structs with the named constants from the expect package (ExitCodeSuccess, ExitCodeGenericFail). The existing ExitCodeNoCheck usages were already correct. |
Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
Summary
Continues the Tigron migration work tracked in #4613. Migrates the remaining
testutil.NewBase-based tests incmd/nerdctl/container/container_create_linux_test.go:TestCreateWithLabel: migrated; label assertions now usehelpers.Capture("inspect", "--format", ...)in theOutputcallbackTestCreateWithMACAddress: migrated; parentSetupcreates networks and fetches the host default MAC, per-subtestSetupgenerates a unique MAC,Outputcallbacks runstart -ato verify MAC propagationTestCreateWithTty: migrated; split into two subtests usingstart -aas theCommand, stderr checked viaErrorsfor the no-TTY caseTestCreateFromOCIArchive: migrated; build context created indata.Temp(), OCI archive built and container created inSetup,start --attachreturned as theCommandTestUsernsMappingCreateCmd: fixed a pre-existing inconsistency wherenerdtest.Setup()was called for its side-effect only and the returned*test.Casediscarded; now uses the returned case directly.removeUsernsConfigupdated to accepttig.Tinstead of*testing.T.TestIssue2993was already fully migrated and is left unchanged.Test plan
go build ./cmd/nerdctl/container/passes (no compile errors)go test -run ^$ ./cmd/nerdctl/container/compiles cleanlyRelated: #4613