containers / toolbox

Tool for interactive command line environments on Linux
https://containertoolbx.org/
Apache License 2.0
2.38k stars 208 forks source link

test/system: Test that the HOSTNAME environment variable is set #1436

Closed debarshiray closed 5 months ago

debarshiray commented 5 months ago

Bash automatically sets the HOSTNAME environment variable to the name of the current host [1] as returned by gethostname(2), which is the same as hostname(1).

However, on Fedora, from Fedora 33 onwards, /etc/profile sets the HOSTNAME environment variable to hostnamectl --transient [2], and, from Fedora 35 onwards, it has a fallback to hostname(1) [3]. These two approaches return different values when used inside a Toolbx container. The former picks up the hostname of the host operating system, while the fallback gets the name that was set when creating the container with podman create --hostname toolbox ....

Hence, the value of HOSTNAME inside a Toolbx container for Fedora depends on whether the corresponding version of the fedora-toolbox image contained hostnamectl(1) or not.

[1] https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html

[2] setup commit eb9cc4dce89be24f https://pagure.io/setup/c/eb9cc4dce89be24f https://bugzilla.redhat.com/show_bug.cgi?id=1745245

[3] setup commit ddd74b5d971a734c https://pagure.io/setup/c/ddd74b5d971a734c https://pagure.io/setup/pull-request/28 https://bugzilla.redhat.com/show_bug.cgi?id=1938223

https://github.com/containers/toolbox/issues/558

softwarefactory-project-zuul[bot] commented 5 months ago

Build succeeded. https://softwarefactory-project.io/zuul/t/local/buildset/f46fe48f40cf450a89cf379450c887d9

:heavy_check_mark: unit-test SUCCESS in 7m 01s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 27s :heavy_check_mark: unit-test-restricted SUCCESS in 6m 01s :heavy_check_mark: system-test-fedora-rawhide SUCCESS in 30m 36s :heavy_check_mark: system-test-fedora-39 SUCCESS in 30m 29s :heavy_check_mark: system-test-fedora-38 SUCCESS in 29m 45s

softwarefactory-project-zuul[bot] commented 5 months ago

Build failed. https://softwarefactory-project.io/zuul/t/local/buildset/3aef2752f8f54bb6a730b707e7bcf363

:heavy_check_mark: unit-test SUCCESS in 6m 36s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 20s :heavy_check_mark: unit-test-restricted SUCCESS in 5m 50s :x: system-test-fedora-rawhide FAILURE in 34m 21s :x: system-test-fedora-39 FAILURE in 33m 07s :heavy_check_mark: system-test-fedora-38 SUCCESS in 32m 52s

debarshiray commented 5 months ago

Fedora's /etc/profile has it's own mechanism to set the HOSTNAME environment variable, which leads to:

fedora-rawhide | not ok 313 environment variables: HOSTNAME inside the default container in 3188ms
fedora-rawhide | # (from function `assert_line' in file test/system/libs/bats-assert/src/assert.bash, line 488,
fedora-rawhide | #  in test file test/system/220-environment-variables.bats, line 450)
fedora-rawhide | #   `assert_line --index 0 "toolbox"' failed
fedora-rawhide | #
fedora-rawhide | # -- line differs --
fedora-rawhide | # index    : 0
fedora-rawhide | # expected : toolbox
fedora-rawhide | # actual   : np0004424111.novalocal
fedora-rawhide | # --
softwarefactory-project-zuul[bot] commented 5 months ago

Build succeeded. https://softwarefactory-project.io/zuul/t/local/buildset/63f91926b07f49d4a67a25049cf31145

:heavy_check_mark: unit-test SUCCESS in 6m 56s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 14s :heavy_check_mark: unit-test-restricted SUCCESS in 6m 01s :heavy_check_mark: system-test-fedora-rawhide SUCCESS in 31m 39s :heavy_check_mark: system-test-fedora-39 SUCCESS in 30m 16s :heavy_check_mark: system-test-fedora-38 SUCCESS in 30m 58s