Skip to content
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

Use newer container naming in container BATS #1881

Conversation

ianballou
Copy link
Contributor

Since container repos now have slashes in them, the test needs updating.

I also updated the version requirement for the container push test since it should run on Katello 4.14. (It still needs investigation though :) )

I haven't been able to actually test this yet due to issues running the pipeline locally.

tContainerSlashesDefault
tPackageExists podman || tPackageInstall podman
podman login "${HOSTNAME}" -u admin -p changeme
CONTAINER_PULL_LABEL=$(echo "${ORGANIZATION_LABEL}/${PRODUCT_LABEL}/${CONTAINER_REPOSITORY_LABEL}"| tr '[:upper:]' '[:lower:]')
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding a new test, should we guard this variable behind a version check? Something like

Suggested change
CONTAINER_PULL_LABEL=$(echo "${ORGANIZATION_LABEL}/${PRODUCT_LABEL}/${CONTAINER_REPOSITORY_LABEL}"| tr '[:upper:]' '[:lower:]')
if tIsVersionNewer "${KATELLO_VERSION}" 4.16
CONTAINER_PULL_LABEL=$(echo "${ORGANIZATION_LABEL}/${PRODUCT_LABEL}/${CONTAINER_REPOSITORY_LABEL}"| tr '[:upper:]' '[:lower:]')
else
CONTAINER_PULL_LABEL=$(echo "${ORGANIZATION_LABEL}-${PRODUCT_LABEL}-${CONTAINER_REPOSITORY_LABEL}"| tr '[:upper:]' '[:lower:]')
fi

My reasoning is you always only run one or the other. If there was a version where you ran both tests then an additional test is obviously better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that works for me.

@ianballou ianballou force-pushed the bats-container-naming-change-update-scheme branch from 81184e2 to 66b06c2 Compare November 25, 2024 19:52
bats/fb-katello-container.bats Fixed Show fixed Hide fixed
bats/fb-katello-container.bats Fixed Show fixed Hide fixed
bats/fb-katello-container.bats Fixed Show fixed Hide fixed
bats/fb-katello-container.bats Fixed Show fixed Hide fixed
@ianballou ianballou force-pushed the bats-container-naming-change-update-scheme branch from 66b06c2 to 5d69ef3 Compare November 25, 2024 19:52
@ianballou ianballou force-pushed the bats-container-naming-change-update-scheme branch from 5d69ef3 to 516cb02 Compare November 25, 2024 19:54
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I haven't been able to actually test this yet due to issues running the pipeline locally.

I trust you on it. Do you want to merge this now?

@ianballou
Copy link
Contributor Author

Merging! It'll be broken tomorrow regardless if we don't merge this, so at least it should get us closer even if there's an issue here.

@ianballou ianballou merged commit 0409f28 into theforeman:master Nov 25, 2024
8 checks passed
@ianballou ianballou deleted the bats-container-naming-change-update-scheme branch November 25, 2024 22:20
@ekohl
Copy link
Member

ekohl commented Nov 26, 2024

I just ran a nightly pipeline and getting a failure:

not ok 9 almalinux9 install: try fetching container content
# (in test file fb-katello-client-global-registration.bats, line 81)
#   `podman pull "${HOSTNAME}/${CONTAINER_PULL_LABEL}"' failed with status 125
# $ [fb-katello-client-global-registration.bats, line 78]
# $ tPackageExists podman
# $$ [os_helper.bash, line 83]
# $$ tIsRedHatCompatible
# $$$ [os_helper.bash, line 4]
# $$$ [[ -f /etc/redhat-release ]]
# $$ [os_helper.bash, line 84]
# $$ rpm -q "$1" > /dev/null
# $ [fb-katello-client-global-registration.bats, line 79]
# $ podman login "${HOSTNAME}" -u admin -p changeme
# Login Succeeded!
# $ CONTAINER_PULL_LABEL=$(echo "${ORGANIZATION_LABEL}-${PRODUCT_LABEL}-${CONTAINER_REPOSITORY_LABEL}"| tr '[:upper:]' '[:lower:]')
# $ echo "${ORGANIZATION_LABEL}-${PRODUCT_LABEL}-${CONTAINER_REPOSITORY_LABEL}"
# $ tr '[:upper:]' '[:lower:]'
# $ podman pull "${HOSTNAME}/${CONTAINER_PULL_LABEL}"
# Trying to pull pipe-katello-server-nightly-almalinux9.example.com/test_organization-test_product-foremanbusybox:latest...
# Error: initializing source docker://pipe-katello-server-nightly-almalinux9.example.com/test_organization-test_product-foremanbusybox:latest: reading manifest latest in pipe-katello-server-nightly-almalinux9.example.com/test_organization-test_product-foremanbusybox: name unknown: test_organization-test_product-foremanbusybox was not found!

Note this is in a different file:

@test "try fetching container content" {
tPackageExists podman || tPackageInstall podman
podman login "${HOSTNAME}" -u admin -p changeme
CONTAINER_PULL_LABEL=$(echo "${ORGANIZATION_LABEL}-${PRODUCT_LABEL}-${CONTAINER_REPOSITORY_LABEL}"| tr '[:upper:]' '[:lower:]')
podman pull "${HOSTNAME}/${CONTAINER_PULL_LABEL}"
}

But also in the container file it's using dashes, not slashes. I can't quite see what the value of KATELLO_VERSION is.

@ianballou
Copy link
Contributor Author

We have container tests outside the container test file? Dang... Well I'll need to try it myself, I should be able to get the pipeline running locally if you did.

@ekohl
Copy link
Member

ekohl commented Nov 26, 2024

We have container tests outside the container test file? Dang...

In the global registration I think it's verifying that it sets up podman auth so you can pull container images.

But note that also the tests you modified don't pass. Really looks like either the version is wrong or the comparison.

Well I'll need to try it myself, I should be able to get the pipeline running locally if you did.

I'll admit I just relied on Jenkins and I only copied the results from there. It's been a while since I ran it locally.

@ianballou
Copy link
Contributor Author

In the global registration I think it's verifying that it sets up podman auth so you can pull container images.

I think I'll just remove the podman test, we don't have registration automation for setting up container registry authentication (yet :) )

But note that also the tests you modified don't pass. Really looks like either the version is wrong or the comparison.

Yeah, it was just wishful thinking assuming that I'd get those comparisons right the first try. I'm aiming to get it settled today.

@ekohl
Copy link
Member

ekohl commented Nov 26, 2024

I think I'll just remove the podman test, we don't have registration automation for setting up container registry authentication (yet :) )

I have some vague recollection we set up certificates for podman somewhere so it could pull, but I can't find that now.

@ianballou
Copy link
Contributor Author

ianballou commented Nov 26, 2024

I think I'll just remove the podman test, we don't have registration automation for setting up container registry authentication (yet :) )

I have some vague recollection we set up certificates for podman somewhere so it could pull, but I can't find that now.

I suppose testing that some other system can pull container content is worthwhile. The CA does need to be installed so podman can trust the repo. The tests on the nightly box itself wouldn't catch issues there.

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