Skip to content

refactor: migrate login_linux_test.go to nerdtest.Setup#4907

Open
ogulcanaydogan wants to merge 2 commits into
containerd:mainfrom
ogulcanaydogan:refactor/4613-login-linux-tigron-clean
Open

refactor: migrate login_linux_test.go to nerdtest.Setup#4907
ogulcanaydogan wants to merge 2 commits into
containerd:mainfrom
ogulcanaydogan:refactor/4613-login-linux-tigron-clean

Conversation

@ogulcanaydogan
Copy link
Copy Markdown
Contributor

Migrate login_linux_test.go to the nerdtest.Setup() / test.Case
pattern, consistent with the ongoing effort tracked in #4613.

Changes

  • Replace testutil.NewBase(t) with nerdtest.Setup() + test.Case
  • Lift registry and auth-server setup into Setup / Cleanup callbacks
  • Use helpers.Ensure / helpers.Anyhow for container-lifecycle calls
  • Use Tigron expect constants for exit codes (ExitCodeSuccess,
    ExitCodeGenericFail) rather than bare integer literals
  • Preserve all existing test logic: basic auth, token auth, TLS
    variants, insecure-registry flag, hostname variants

Testing

Existing TestLoginPersistence and TestLoginAgainstVariants cover the
full matrix. CI runners (rootful/rootless, canary/v1.7.30) validate the
migration.

Part of #4613.

@ogulcanaydogan
Copy link
Copy Markdown
Contributor Author

The latest push fixes the lint failures caught by CI:

  • Removed redundant testca import alias (revive: redundant-import-alias)
  • Removed 3 unnecessary bare blocks in test sections 1, 4, and 5 (gocritic: unnecessaryBlock)

The EL / almalinux-8 rootful failure is TestComposePsJSON timing out — a pre-existing flaky test unrelated to this PR. All login tests pass on that runner.

(&Client{configPath: configPath}).
Cmd(helpers, host).
Run(&test.Expected{ExitCode: 0})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can change the status codes to the constants as previous

Comment thread cmd/nerdctl/login/login_linux_test.go Outdated
username := utils.RandomStringBase64(30) + "∞"
password := utils.RandomStringBase64(30) + ":∞"

basicReg = nerdtest.RegistryWithBasicAuth(data, helpers, username, password, 0, false)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

probably put the constant 0 to named variable so it has a meaning full name here (what actually it its)

Replace testutil.NewBase-based test helpers with the Tigron test
framework (nerdtest.Setup). Key changes:

- Client.Run(base, host) replaced with Client.Cmd(helpers, host)
  returning test.TestableCommand; DOCKER_CONFIG set via Setenv.
- testregistry.NewRegistry / testca.New replaced with
  nerdtest.RegistryWithBasicAuth, nerdtest.RegistryWithTokenAuth, and
  lower-level registry.NewCesantaAuthServer + registry.NewDockerRegistry
  for the token-auth/no-TLS case (HTTP registry, matching original
  behaviour).
- TestLoginPersistence: two SubTests (basic, token) each owning their
  registry lifecycle via Setup/Cleanup.
- TestLoginAgainstVariants: dynamically generated SubTests from the
  existing test-case table; inner regHost and assertion loops run
  sequentially inside Setup (equivalent coverage without nested t.Run).
- testutil.DockerIncompatible replaced with require.Not(nerdtest.Docker).
- TestAgainstNoAuth remains commented out, unchanged.

Closes containerd#4613

Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
@ogulcanaydogan ogulcanaydogan force-pushed the refactor/4613-login-linux-tigron-clean branch from 0b0fc3d to efc8f73 Compare May 16, 2026 13:11
@ogulcanaydogan
Copy link
Copy Markdown
Contributor Author

Thanks for the review! Pushed fixes:

  • Replaced bare 0 port arguments with a local randomPort = 0 constant so the intent is explicit at call sites.
  • Replaced all ExitCode: 0 literals with expect.ExitCodeSuccess to match the constant used elsewhere (expect.ExitCodeGenericFail was already in use).

Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
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.

2 participants