Skip to content

Conversation

@apostasie
Copy link
Contributor

@apostasie apostasie commented Jun 9, 2024

The fundamental motivation for this is to fix #3044

Furthermore, before embarking on revamping login code to fix everything in #3072 we do need a clean working ready-to-go test tooling and environment (specifically fix #3071).

This PR does revamp testregistry, testca and adds a couple of files.

In a shell:

  • testca now allows additional names
  • portlock allows for "locking" a port (or finding a free one), that is not racy and safe to use with parallel across distinct invocations. This allows tests to not have to specify an explicit port anymore (if they don't want a specific one), which in turn allow for parralelization without risks of conflicts
  • testregistry and login_linux_test have been largely rewritten and fix:
    • guarantee that cleanups are always done
    • add support for Basic Authentication
    • prevent cross registry pollution by using distinct credentials per registry
    • prevent credential pollution between tests by privatizing .docker/config.json
    • reduce duplication in testregistry
    • better host toml coverage for variants (w/o ports)
    • Auth server can now serve on http or https
    • parallelize as much as feasible
    • adding a larger variety of tests

Pending green CI, I would suggest we merge this ASAP so that further test cleanup can happen (and more parallelization) and actual work can begin on cleaning-up login

@apostasie apostasie force-pushed the dev-3044 branch 4 times, most recently from 117ac97 to 11c8504 Compare June 9, 2024 05:19
// skip if nydusify is not installed
// skip if nydusify and nydusd are not installed
testutil.RequireExecutable(t, "nydusify")
testutil.RequireExecutable(t, "nydusd")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding missing requirement

defer registry.Cleanup()
registry := testregistry.NewWithNoAuth(base, 0, false)
remoteImage := fmt.Sprintf("%s:%d/nydusd-image:test", "localhost", registry.Port)
t.Cleanup(func() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleanup is better to use than defer

@apostasie apostasie force-pushed the dev-3044 branch 2 times, most recently from 0c22fba to 7c80d34 Compare June 11, 2024 05:55
@apostasie
Copy link
Contributor Author

CI is green

@AkihiroSuda and team PTAL at your convenience.

@apostasie
Copy link
Contributor Author

Apologies for the re-push.
Did mistakenly commit files from another PR.

@apostasie
Copy link
Contributor Author

@AkihiroSuda if this looks fine to you folks, I would love to see this merged in as I have more CI and tests changes that would benefit from it.

I believe the windows failure is a fluke, so, if you can poke it that would be lovely.

@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Jun 14, 2024
@AkihiroSuda AkihiroSuda requested review from Zheaoli and fahedouch June 14, 2024 11:37

reg := testregistry.NewPlainHTTP(base, 5000)
defer reg.Cleanup()
reg := testregistry.NewWithNoAuth(base, 0, false)
Copy link
Member

Choose a reason for hiding this comment

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

Why renamed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Methods have been simplified / renamed:

  • there is no longer separate helpers for http vs. https (you pass a tls bool instead) - so, the previous name (NewPlainHTTP, that does not specific what type of auth it is using)
  • all helpers names now follow the same pattern:
    • NewWithTokenAuth
    • NewWithBasicAuth
    • NewWithNoAuth

Let me know if you don't like it and I can revert this one if you wish.

t.Logf("localhost IP=%q", localhostIP)
testImageRefPrefix := fmt.Sprintf("%s:%d/",
localhostIP, reg.ListenPort)
localhostIP, reg.Port)
Copy link
Member

Choose a reason for hiding this comment

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

Why renamed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"ListenIP" makes sense (0.0.0.0) - as in "the address the registry process is binding to" - and also does "IP" (the exposed ip you can access it with).
"ListenPort" feels the wrong way - since this is NOT the port the registry process is actually listening on (still 5000), but instead the port you can access it with.

It seems better to me that way.

Either way, this is minor. I can reverse it if you dont like it.

Thanks @AkihiroSuda

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 743609f into containerd:main Jun 16, 2024
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.

Tests manipulating credentials are not properly isolated from one another TestLoginWithPlainHttp appears to be broken

2 participants