Skip to content

test/system: Don't assume that no container will have /etc/kernel - #1409

Merged
debarshiray merged 1 commit into
containers:mainfrom
petraglyph:home-fallback
Dec 7, 2023
Merged

debarshiray merged 1 commit into
containers:mainfrom
petraglyph:home-fallback

Conversation

@petraglyph

Copy link
Copy Markdown
Contributor

The test "run: Ensure that $HOME is used as a fallback working directory" assumes /etc/kernel will not be present in containers, but this is not the case for Ubuntu (and Debian) containers. This patch switches the test to using a temporary directory (under /var/tmp which is not mounted by toolboxes) to ensure fallback is activated.

@softwarefactory-delete-me

Copy link
Copy Markdown

@martymichal martymichal added the 2. Testing Related to testing of Toolbox - unit, system,.. label Dec 3, 2023

@debarshiray debarshiray left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your contribution!

We should definitely try to get the tests ready to be run on Ubuntu hosts, so that we can enable them in our CI. The tests do have lots of assumptions about running on Fedora hosts at the moment, which isn't good. So thanks for looking into that.

However, do Ubuntu hosts really not have /etc/kernel? So far, I tried Ubuntu 22.04, 22.10, 23.04 & 23.10 Desktop, and they all had `/etc/kernel.

I am not really opposed to the change, other than someone wanting to share /var/tmp between the host and container in future, but I want to understand the problem that you found.

@debarshiray debarshiray left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The commit message could be slightly better. Something like:
"test/system: Don't assume that all host OSes will have /etc/kernel"

Comment thread test/system/104-run.bats Outdated

pushd /etc/kernel
local testdir
testdir="$(mktemp -d '/var/tmp/toolbox-test-XXXX')"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpick: the single quotes aren't necessary.

debarshiray pushed a commit to petraglyph/toolbox that referenced this pull request Dec 4, 2023
@debarshiray

Copy link
Copy Markdown
Member

I took the liberty to address the nits and updated the branch by rebasing against main. I am waiting for your response to my earlier question.

@petraglyph

petraglyph commented Dec 4, 2023 •

Copy link
Copy Markdown
Contributor Author

Ubuntu hosts do have the /etc/kernel directory, but so do Ubuntu containers. So when the test is run using an Ubuntu container it just enters the container at /etc/kernel without being forced to fallback.

You can simulate this on fedora if you temporarily add the following to /etc/os-release

ID=ubuntu
VERSION_ID="22.04"

@softwarefactory-delete-me

Copy link
Copy Markdown

Any image or container that has APT or systemd may have /etc/kernel.
eg., the arch-toolbox and ubuntu-toolbox images.

containers#1409

Signed-off-by: Penn Bauman <[email protected]>
@debarshiray

Copy link
Copy Markdown
Member

Ubuntu hosts do have the /etc/kernel directory, but so do Ubuntu containers. So when the test is run using an Ubuntu container it just enters the container at /etc/kernel without being forced to fallback.

Aha, okay, you are right. I didn't read your initial comment carefully.

You can simulate this on fedora if you temporarily add the following to /etc/os-release

ID=ubuntu
VERSION_ID="22.04"

Thanks for the detailed example. Let's merge this once the CI finishes.

@debarshiray

Copy link
Copy Markdown
Member

@pennbauman Since you spent some time running the test on non-Fedora hosts, would you mind submitting a new PR that runs this "fallback working directory" test on other images, and not just the default one? eg., Arch Linux, RHEL, Ubuntu, etc. like we do elsewhere.

@softwarefactory-delete-me

Copy link
Copy Markdown

@debarshiray
debarshiray merged commit 2f3ee0e into containers:main Dec 7, 2023
@petraglyph

Copy link
Copy Markdown
Contributor Author

@debarshiray I was thinking that would be a good next step. I will look into that when I have some time.

@debarshiray

Copy link
Copy Markdown
Member

@debarshiray I was thinking that would be a good next step. I will look into that when I have some time.

Thanks!

@debarshiray debarshiray changed the title test/system: switch HOME fallback to tmp dir (fix for Ubuntu hosts) test/system: Don't assume that no container will have /etc/kernel Dec 18, 2023
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jan 29, 2026
Any image or container that has APT or systemd may have /etc/kernel.
eg., the arch-toolbox and ubuntu-toolbox images.

containers#1409
containers#1750

Signed-off-by: Penn Bauman <[email protected]>
(backported from commit 2f3ee0e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. Testing Related to testing of Toolbox - unit, system,..

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants