-
Notifications
You must be signed in to change notification settings - Fork 863
integration tests: learn to start a dummy registry #3894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tests/helpers.bash
Outdated
| # Sets REGISTRY_PID, REGISTRY_PORT (to append to "localhost:"), and | ||
| # REGISTRY_DIR (where the CA cert can be found) on success. | ||
| function start_registry() { | ||
| local REGISTRY_IMAGE=docker.io/library/registry:2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may call this a fair number of times during the tests and I wonder if we'll hit the rate limits. Would it make sense to have our own registry image tucked away on quay.io somewhere? Do they have one for Podman already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not against that, but I have no idea if we have a plan in place to keep any of those up to date. The start_registry function uses _prefetch, so it should be pulled, at most, once in a given CI job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using quay.io/libpod/registry:2.6. I recall that an update to the one on Docker Hub once broke gating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using 2.7 now. 2.6 and 2.7 are not multi-arch, and 2.8 isn't in that repository. How/when do they get updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they're under the loving care of @edsantiago
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.8 copy in progress; it'll take a long time (30m?) due to my slow network.
$ skopeo copy --all docker://docker.io/registry:2.8 docker://quay.io/libpod/registry:2.8There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edsantiago, feel free to ping me next time. Still enjoying fast French fibre :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done:
$ buildah manifest inspect quay.io/libpod/registry:2.8 | jq '.manifests[].platform.architecture'
"amd64"
"arm"
"arm"
"arm64"
"ppc64le"
"s390x"450122d to
9b11911
Compare
|
This one is failing on |
This was trying to re-enable a test that was previously disabled under SELinux, but I guess we didn't work around it after all. |
|
The integration test is failing with one that I've not seen before: Later, it can't find containers.conf in a few tests: |
|
@TomSweeneyRedHat that's our nemesis, #3710 |
75ed189 to
24481f5
Compare
tests/copy.bats
Outdated
| @test "copy-preserving-extended-attributes" { | ||
| createrandom ${TESTDIR}/randomfile | ||
| image="quay.io/libpod/fedora-minimal:34" | ||
| image="registry.fedoraproject.org/fedora-minimal:35" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A thought for later. Should we define ${FEDORA_MINIMAL} or some such in helpers.bat? That way if we need to bump from 35 to 36, we only have one place to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could as likely have left the version tag off of the image spec, since the test doesn't care about it as much, but don't let me stop you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with omitting the version spec is that the next (or next-next) version will introduce some sort of breakage that will cause us to scramble in a panic. . Example: containers/podman#12343
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also #3640. If there is a critical need to use f35 here, can we push a copy to quay instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't critical that it be Fedora or Fedora-based, more that it have working setcap, getfattr, and setfattr commands. I'll add comment there to try to clarify that. If you've another image in mind that would work better, I'm happy to switch to using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question was, is fedora-minimal:34 not working? If it no longer works, can we push a new image to quay? If it still works, can we keep it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it will. I switched to 35 mainly because I know 34 is going EOL in a little over a month. Changing it back to 34.
|
LGTM |
e9962ee to
3135ab8
Compare
|
Happy green test buttons. |
tests/helpers.bash
Outdated
| local htpasswd='testuser:$2y$05$OW6Qlf1ygRuqJxt/CYcBq.0MZARYLIvr.mgjksw2m7K4cwWkw3Pda' | ||
| if test "$1" = testuserfoo && test "$2" = testpassword ; then | ||
| htpasswd='testuserfoo:$2y$05$Pkly/9sA8iGY..2SaerFH.wr4qGPPaGZ66KMrvVmcCP8gaRPpeoeC' | ||
| elif test "${1:-testuser}" != testuser && test "${2:-testpassword}" != testpassword ; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just a complicated way of saying:
local testuser="${1:-testuser}"
local testpass="${2:-testpassword}"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That whole section probably makes more sense as a case statement. Reworking it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I don't understand is, why the special case at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an attempt to sort of future-proof that, but thinking on it more, it's better to just avoid needing htpasswd, so I'll drop that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
htpasswd is already a hard requirement for the buildah-tests package, in both fedora and rhel, because a registry is already mandatory for running tests (and has been from day one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use previously-computed hash values for passwords that we hard-code in the tests, we'll no longer need to call out to htpasswd when the tests are run. Are you saying that's harmful? I'm missing how that would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the hardcoding I most object to: although right now all tests use testuser/testpassword, we have the option (and should take advantage of it) of using randomly-generated user and password which would improve confidence in testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We check in "authenticate: cert and credentials" that we can successfully authenticate to the registry with a known-good username/password pair, and that we get an error when we intentionally supply values that we know the registry isn't configured to accept. What types of bugs do you see us catching by randomly selecting unique known-good values for each test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly my paranoia: with static values (credentials, input/output test strings) there's always a chance that you're not really testing what you think you're testing: that there's a leftover process somewhere and you're talking to it instead of the registry/httpserver/whatever that you think you're talking to. With unique values that worry is diminished.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I still like the idea of reducing the set of requirements that someone needs to have installed in order to run the tests, and it turns out we can generate the hashes for passwords ourselves by wrapping the right function call. I'll add that and switch the "authenticate: cert and credentials" test to randomize them.
tests/helpers.bash
Outdated
| echo error computing hashed password | ||
| exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about die "Error computing hashed password"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'll work. Changing it.
tests/helpers.bash
Outdated
| echo error creating new key and certificate | ||
| return 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, die might be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing it.
tests/helpers.bash
Outdated
| echo error determining listening port from log: | ||
| cat ${TESTDIR}/registry/registry.log | ||
| stop_registry | ||
| return 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just plain false is enough, that will abort bats for the given test
(sorry for all the single-comments; I'm just worried that this will merge too early. Feel free to batch up my comments until I say "done with review")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing it. No worries, I'll try to make sure it's all sorted before the next rebase.
tests/helpers.bash
Outdated
| if ! ${BUILDAH_BINARY} --storage-driver vfs --root "${REGISTRY_DIR}"/root --runroot "${REGISTRY_DIR}"/run push --cert-dir "${REGISTRY_DIR}" --creds "${1:-testuser}":"${2:-testpassword}" "${REGISTRY_IMAGE}" localhost:"${REGISTRY_PORT}"/registry; then | ||
| echo error pushing to /registry repository at localhost:$REGISTRY_PORT | ||
| stop_registry | ||
| return 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise, false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing it.
tests/helpers.bash
Outdated
| return 1 | ||
| fi | ||
|
|
||
| return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping it.
tests/helpers.bash
Outdated
| # wait for it to start logging things, then give it a second more | ||
| local waited=0 | ||
| while ! test -s "${TESTDIR}"/registry/registry.log ; do | ||
| if test $waited -ge $BUILDAH_TIMEOUT ; then | ||
| break | ||
| fi | ||
| sleep 1 | ||
| waited=$((${waited}+1)) | ||
| done | ||
| sleep 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of wait-loops that simply time out without failing. If you're going to time out, I like it big & bold. Would you consider:
# record the coprocess's ID and try to parse the listening port from the log
# we're separating all of this from the storage for any test that might call
# this function and using vfs to minimize the cleanup required
REGISTRY_PID="${COPROC_PID}"
REGISTRY_DIR="${TESTDIR}"/registry
local waited=0
REGISTRY_PORT=
while [[ -z "$REGISTRY_PORT" ]]; do
if [[ $waited -gt $BUILDAH_TIMEOUT ]]; then
echo "Could not determine listening port from log:"
sed -e 's/^/ >/' <${REGISTRY_DIR}/registry.log
false
fi
waited=$((waited+1))
sleep 1
REGISTRY_PORT=$(sed -ne 's^.*listening on.*:\([0-9]\+\),.*^\1^p' <${REGISTRY_DIR}/registry.log)
doneThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking this almost verbatim.
tests/helpers.bash
Outdated
| fi | ||
|
|
||
| # push the registry image we just started... to itself, as a confidence check | ||
| if ! ${BUILDAH_BINARY} --storage-driver vfs --root "${REGISTRY_DIR}"/root --runroot "${REGISTRY_DIR}"/run push --cert-dir "${REGISTRY_DIR}" --creds "${1:-testuser}":"${2:-testpassword}" "${REGISTRY_IMAGE}" localhost:"${REGISTRY_PORT}"/registry; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another argument for declaring local testuser/testpass variables at function start
edsantiago
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a few suggestions. Thanks for doing this, it greatly simplifies our gating-test setup.
When a test needs to talk to a registry server, launch one as part of the test rather than depending on it having been started by someone else. Use run_buildah where we used to use 'run buildah' without checking the return code, and in a few cases where we did check it. In the "from with non buildah container" test, use "podman create" with host networking, in an attempt to avoid messing with networking in cases where we're running on a system with a version of podman that will create a bridge with CNI that we'll also create with netavark. We're not sharing storage between the two invocations, so the logic that tries to detect this problem won't detect it. Signed-off-by: Nalin Dahyabhai <[email protected]>
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nalind, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind other
What this PR does / why we need it:
When a test needs to talk to a registry server, launch one as part of the test rather than depending on it having been started by someone else.
Use run_buildah where we used to use 'run buildah' without checking the return code, and in a few cases where we did check it.
In the "from with non buildah container" test, use "podman create" with host networking, in an attempt to avoid messing with networking in cases where we're running on a system with a version of podman that will create a bridge with CNI that we'll also create with netavark. We're not sharing storage between the two invocations, so the logic that tries to detect this problem won't detect it.
How to verify it
Updates to tests!
Which issue(s) this PR fixes:
None
Special notes for your reviewer:
This gets us closer to being able to run integration tests anywhere by pointing
batsat ourtestsdirectory.Does this PR introduce a user-facing change?