2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-30 14:55:16 +00:00
Files
xcat-core/xCAT-test/bats
Daniel Hilst 73c293f03e fix(xcat-core): otherpkgs refreshes a zypper repository it did not add
The local otherpkgs repository is written with the alias xcat-otherpkgs$localrepoindex, where
localrepoindex is urlrepoindex plus the array index. Lines 833 and 843 of
xCAT/postscripts/otherpkgs then refresh and delete xcat-otherpkgs$index. With http OTHERPKGDIR
entries present urlrepoindex is not zero, so zypper names a repository that block did not add:
the refresh fails for a repository that exists, and the delete removes another one.

Both lines now use $localrepoindex. The log and the echo of a failed SDK repository add name
$bname, which is what zypper ar used; they said bname without the $.

postscripts_otherpkgs.bats drives the add, the refresh and the delete with zypper shadowed and
urlrepoindex set to 2, and reads the alias back out of the repository file the script wrote.
Against the unfixed script the refresh and the delete name xcat-otherpkgs0 while the file says
xcat-otherpkgs2, and the SDK log carries no repository name.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-14 15:56:14 -03:00
..

xCAT-test/bats

Shell-script unit tests live here and run with:

bats -r xCAT-test/bats

The GitHub Actions xcat_test workflow runs this command after the Perl .t unit tests. Use BATS for shell behavior that can be exercised from the source tree without an installed xCAT, a live management node, or real services.

Prefer sourcing an existing shell library or sourceable script and calling the function under test. Keep reusable install-template helpers in xCAT-server/share/xcat/install/scripts/scriptlib, and reusable postscript helpers in xCAT/postscripts/xcatlib.sh. Use scratch directories and shadowed commands so tests cannot write to the host.

Extraction helpers in helpers/shell_source.bash are only for legacy code that cannot safely be sourced yet. Do not add Perl .t tests that grep shell source when the behavior can be tested with BATS.