2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-30 14:55:16 +00:00
Commit Graph

31 Commits

Author SHA1 Message Date
Daniel Hilst a095259a01 Merge pull request #7868 from VersatusHPC/test/r26-otherpkgs-upgrade-behavior
test(otherpkgs): exercise repository-scoped upgrades
2026-09-28 13:47:30 -03:00
Vinícius Ferrão afa6e05789 docs(test): document the BATS postscript sandbox 2026-09-25 12:49:09 -03:00
Vinícius Ferrão 76d8dfdd14 test(otherpkgs): move sandbox checks to BATS 2026-09-25 12:48:40 -03:00
Daniel Hilst eb595c698c Merge pull request #7834 from VersatusHPC/fix/ubuntu-subiquity-ppc64le-grub-ieee1275
fix(xcat-core): the Ubuntu ppc64le diskful install stops without grub-ieee1275
2026-09-24 10:57:04 -03:00
Daniel Hilst f8618ce746 test(xcat-core): an assertion about /run could not tell who wrote there
The error-command test ended with

    [ ! -e /run/testnode-logs.tar ]

meant to show the archive had not gone to the default path. It cannot show that.
The file may exist for reasons that have nothing to do with this test, in which case
the assertion fails while nothing is wrong; and its absence would be equally true if
the override had never worked at all. It answers a question about the host, not
about the run.

The positive assertion above it already carries the proof: the tar shadow writes a
marker, and the test greps for that marker in the path it passed. The output being
there is what shows the redirection went there.

Removing it changes nothing about what the test catches. With the override taken out
of the template, so the archive path is hard-coded again, the remaining assertion
still fails.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-24 10:24:54 -03:00
Daniel Hilst b72fd46366 Merge pull request #7851 from VersatusHPC/fix/updatenode-xcatpost-cleanup
fix(xcatdsklspost): updatenode leaves /xcatpost populated when site.cleanupdiskfullxcatpost is set
2026-09-24 10:21:49 -03:00
Daniel Hilst 7f635afbd8 Merge pull request #7850 from VersatusHPC/fix/otherpkgs-postscript-defects
fix(otherpkgs): the postscript truncates its syslog output and logs a failed install as installed
2026-09-24 10:17:19 -03:00
Daniel Hilst 9c2e733b99 fix(xcatdsklspost): the diskful cleanup deleted a diskless node's postscripts
site.cleanupdiskfullxcatpost names the node type it applies to, and site.5.rst
says "on the diskfull nodes". xcatdsklspost serves every type: updatenode calls
it for a diskless or statelite node as well, and the site value is one row that
reaches all of them. With cleanupdiskfullxcatpost=yes and cleanupxcatpost=no,
append_xcatpost_cleanup still appended the delete for those nodes.

The diskful branch now reads NODESETSTATE from the generated mypostscript and
appends nothing for netboot or statelite. That is the signal remoteshell,
hardeths, configeth, otherpkgs and servicenode already use for this question,
and mypostscript.tmpl exports it.

cleanupxcatpost is unchanged. It names no node type and keeps applying to every
one, which xcatdsklspost_xcatpost_cleanup.bats now asserts so a guard added to
the wrong branch shows up.

Four cases cover it: a netboot node and a statelite node keep their postscripts,
a diskful node is still cleaned, and cleanupxcatpost still empties a netboot
node. The first two fail against the parent commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-23 10:07:16 -03:00
Vinícius Ferrão 3d09f4a068 docs(test): describe the otherpkgs sandbox prerequisites 2026-09-22 03:08:26 -03:00
Daniel Hilst 2f715ac371 Merge pull request #7818 from VersatusHPC/release/2.19-rc1
ci(xcat-core): Fixes to get CI running for all 2.19 targets
2026-09-17 18:18:48 -03:00
Daniel Hilst b4735e10e2 test(xcat-core): the machine-type test accepts a cleanup that removes nothing
diskless_flat_vmothersetting_machine.bats checked the restore with a substring
match and checked the cleanup only for the absence of "unary operator
expected". A cleanup that writes the machine type back, or leaves it in place,
passed both.

The test now reads the value chdef receives. The restore must write exactly
machine:<type>, and must keep a setting the node already carries. The cleanup
must write an empty value when the machine type is all there is, and must leave
the other setting behind when there is one. The chdef stub brackets its
arguments so an empty value is not the same as no call.

ppc64le is red on the cleanup: the restore ladder writes
machine:pseries-rhel7.6.0 and the cleanup ladder removes machine:pseries-7.6.0,
so the node keeps the machine type. x86_64 and riscv64 pass.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-17 07:35:51 -03:00
Daniel Hilst e19a10396e test(xcat-core): the otherpkgs zypper test deletes the repository in both cases
run_zypper_local_repo extracted six lines of the zypper branch of otherpkgs and
evaluated each one in turn. The branch it measures is an if/else: the repository
is deleted only when the refresh fails. Evaluating the lines separately ran the
delete every time, so the test showed that zypper sd is reachable and never that
a repository which refreshes is kept.

The helper now evaluates the whole branch, from the #use zypper comment to the
apt branch that follows, with pmatch lifted from the same file. The success case
asserts rc=0 and no zypper sd; the failure case keeps its delete assertion.

Flipping the refresh test in otherpkgs to "if [ $? -ne 0 ]" turns both cases
red. The same mutation left the previous helper green, because it never
evaluated that line.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-17 07:34:03 -03:00
Daniel Hilst ac63d37843 test(xcat-core): the error-command test writes the log archive to /run
The first subiquity error command redirects tar's output into
/run/#HOSTNAME#-logs.tar. The test shadows tar, but the redirection belongs to
the shell and happens whether or not tar runs:

  $ bash -c 'tar() { :; }; ( tar ... >/run/testnode-logs.tar 2>/dev/null; exit 0 )'
  bash: line 1: /run/testnode-logs.tar: Permission denied
  exit=0

Unprivileged the open fails, "exit 0" swallows it and the test passes. CI runs
as root, where the same line creates or truncates that file on the host.

The archive path now comes from the environment, the way XCAT_ERROR_CONSOLE
already does in the same block, and points inside BATS_TEST_TMPDIR. The tar
shadow emits a marker so the test can tell the output reached the file it
named, and a second assertion says the default path under /run was not touched.

The new case fails until the template reads that variable.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-16 18:29:28 -03:00
Daniel Hilst b6e2810860 fix(xcat-core): the otherpkgs bats anchors match more than one block
Four cases in xCAT-test/bats/postscripts_otherpkgs.bats fail on the integrated
tree. extract_shell_if_block reports that the upgrade anchor occurs 4 times and
the url repository anchor occurs 2 times, where 1 is expected.

"if [ $hasyum -eq 1 ]; then" opens the upgrade block and also the yum branch of
the preremove, the install and the postremove blocks. "OTHERPKGDIR_INTERNET"
matches the guard that opens the url repository block and an assignment inside
that block. The earlier helper took the first match and said nothing.

otherpkgs_block now passes NTH and TOTAL through to extract_shell_if_block. The
two upgrade cases take occurrence 1 of 4, so a fifth identical line fails the
test instead of moving it. The two url repository cases anchor on the guard
line itself, which occurs once.

Both blocks the earlier helper took are the blocks the assertions describe, so
no case measured the wrong code. On the integrated tree bats -r xCAT-test/bats
gives 113 ok and 0 not ok. On this branch, where the helper is not yet
hardened, the file gives 18 ok.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-15 20:57:33 -03:00
Daniel Hilst e058c9afd9 fix(xcat-core): otherpkgs does not log a failed rpm install or removal
A failed package install through the rpm or dpkg fallback leaves no
record in syslog. The same holds for the four package removal branches
that run after the install. The postscript sets its return code, but a
reader of the node log sees nothing, because the package manager output
goes to the console only when VERBOSE is set.

In xCAT/postscripts/otherpkgs the fallback install block, and the yum,
zypper, apt and rpm removal blocks, set RETURNVAL on a non-zero status
and stop there. Only the three repository install branches send a
message with local4.err.

This change adds the same local4.err message to the five branches that
have none. Each message names the command that ran, as the repository
install branches do.

xCAT-test/bats/postscripts_otherpkgs.bats drives each block with a
package manager that returns a failure. Two cases assert the message is
present, and both fail on the parent commit. Two more assert the
success path still logs "installed." and "removed." alone.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-15 12:59:09 -03:00
Daniel Hilst 402a6f4a45 fix(xcat-core): otherpkgs prints the whole package list on every run
The otherpkgs postscript writes two diagnostic lines for each package
sublist: the split package array with its size, and the detected package
manager. On a list with tens of entries these lines fill the updatenode
output and the node log, and hide the install results.

The two echo commands sit in xCAT/postscripts/otherpkgs, after the
IFS split that builds pkgsarray, and no condition guards them. Every
other diagnostic in the script runs only when VERBOSE is set.

This change puts the two lines in the same "if [ $VERBOSE ]" block the
rest of the script uses.

xCAT-test/bats/postscripts_otherpkgs.bats runs the split and the lines
that follow it. One case asserts no output when VERBOSE is empty, and
fails on the parent commit. A second case asserts both lines are still
printed when VERBOSE is set.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-15 12:58:14 -03:00
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
Daniel Hilst 7bd04f012d fix(xcat-core): otherpkgs writes a trailing space into the generated baseurl
Line 297 of xCAT/postscripts/otherpkgs appends each http OTHERPKGDIR entry as "${dir} ,".
The list is split on the comma alone, so every url keeps the space, and the url repository
block writes "baseurl=<url> " into the yum repository file and "deb <url> " into the apt
source.

The separator no longer carries the space.

postscripts_otherpkgs.bats runs the split and the url repository block and compares the
generated baseurl and deb lines with the url. Against the unfixed script both differ by the
trailing space.

dnf 4.20 strips trailing whitespace from an ini value, and apt splits a source line on
whitespace, so no package manager reads the space today. The generated file is still wrong.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-14 15:55:25 -03:00
Daniel Hilst 70e31f2f15 fix(xcat-core): the otherpkgs url repository guard tests a literal string
Line 672 of xCAT/postscripts/otherpkgs reads [ -n "OTHERPKGDIR_INTERNET" ]. The $ is missing,
so the test is on the name of the variable and is always true. The guard cannot select the
case it was written for.

The guard now tests $OTHERPKGDIR_INTERNET.

postscripts_otherpkgs.bats extracts the condition from the script and runs it with the
variable empty and with an http entry. Against the unfixed script the empty case is true.

The block is inert when the variable is empty, because the loop inside it iterates an empty
array, so the run of the postscript does not change. The guard is still wrong.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-14 15:54:59 -03:00
Daniel Hilst 42746fae5a fix(xcat-core): otherpkgs logs a failed package install as installed
In xCAT/postscripts/otherpkgs the success message runs after the branch that records a
non-zero return, not inside an else. A node that fails to install its otherpkgs therefore
reports both "... failed." and "... installed." to syslog, and a reader that greps for the
success line sees a clean install. The same shape covers the four install sites and the four
removal sites.

Each success message now sits in the else branch of the status test.

postscripts_otherpkgs.bats drives the install and postremove blocks with a package manager
that fails, and uses refute_grep to require that no "installed."/"removed." message is sent.
Against the unfixed script both tests find the success message. refute_grep is new in
helpers/shell_source.bash, because bash ignores errexit for a command inverted with "!".

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-14 15:50:09 -03:00
Daniel Hilst a603b9d6c2 fix(xcat-core): otherpkgs sends the package manager output to syslog as one truncated message
The otherpkgs postscript passes the whole package manager transaction to logger as a single
message argument. rsyslog escapes every newline to #012 and cuts the message at 8 KiB, which
is where the Failed:, Error: and summary lines sit. A line that starts with -- is also read
as a logger option.

The seven sites in xCAT/postscripts/otherpkgs that log $result now pipe it to logger. logger
without a message argument reads standard input and sends one message per line.

postscripts_otherpkgs.bats drives the upgrade block and the two preremove blocks with logger
and the package manager shadowed, and counts the messages. Against the unfixed script the
three tests report one message where three are expected.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-14 15:49:07 -03:00
Daniel Hilst 501b1ba44d test(xcatdsklspost): cover the /xcatpost cleanup after an updatenode run
The site table has two attributes for the same directory and only one of them is
covered: nothing pins what xcatdsklspost appends to mypostscript for
site.cleanupdiskfullxcatpost, on the path every updatenode run takes.

Drive append_xcatpost_cleanup against a scratch /xcatpost, run the mypostscript
it writes, and assert on the directory that comes back: the postscripts are gone
after a run that succeeds, updateflag.awk stays, and a run that fails keeps
everything. Add refute_grep to the helpers, because a "! grep" line cannot fail a
bats test unless it is the last line of one.

Three of the six tests fail on this commit. xcatdsklspost reads CLEANUPXCATPOST
and never reads CLEANUPDISKFULLXCATPOST.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-14 15:44:56 -03:00
Daniel Hilst 6f635541e4 test(xcat-core): a missing deb converter makes the arch test skip, not fail
genesis_base_deb_arch.t stopped with a die when debuild-xcat-genesis-base was
absent, because a checkout without the converter has no deb rename to measure.
The BATS file skipped there instead, and a skip reads green.

setup() now asserts the script is readable.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-14 10:26:13 -03:00
Daniel Hilst e2ef0662aa test(xcat-core): the machine-type test is written as a Perl program
diskless_flat_vmothersetting_machine.t measures shell. It lifts two commands
out of reg_linux_diskless_installation_flat, renders the xcattest placeholders,
writes a wrapper that shadows lsdef and chdef, and shells out. The Perl adds
nothing the shell cannot state, and the case file it reads is shell itself.

The test moves to xCAT-test/bats, which the xcat_test workflow already runs. It
keeps what it proved: on ppc64le, x86_64 and riscv64 the restore writes a
machine type rather than an empty vmothersetting, the check that follows it
passes, and the remove path compares two defined strings. A command that stops
matching fails the test instead of covering nothing.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-14 10:14:00 -03:00
Daniel Hilst d5fd9027df test(xcat-core): the subiquity error-command test is written as a Perl program
ubuntu_subiquity_error_commands.t measures shell. It parses the error-commands
block out of compute.subiquity.tmpl, renders each item, writes a wrapper that
shadows nc, tar and tail, and shells out. The Perl adds nothing the shell
cannot state, and the reader follows two languages to reach two assertions.

The test moves to xCAT-test/bats, which the xcat_test workflow already runs. It
keeps what it proved: the error commands return instead of waiting for a
collector an unattended install does not have, and they write the end of the
curtin log to the console the installer names. An error-commands block that
stops matching fails the test instead of covering nothing.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-14 10:11:30 -03:00
Daniel Hilst 4b9572a0a3 test(xcat-core): the Genesis shell tests are written as Perl programs
Eight unit tests measure shell code: the Genesis dracut cmdline hooks, doxcat,
getcert, the two Genesis deb builders, go-xcat and the genesis test case. The
Perl in each one is scaffolding. It reads the script, lifts a block out with a
regular expression, writes a wrapper, shells out and reads the files back. A
reader follows two languages to reach one assertion, and the scaffolding is
longer than the assertion.

xCAT-test/bats already states this kind of assertion in the language of the
thing under test, and the xcat_test workflow runs it. The eight files move
there. Each one keeps what it proved: the rpm architecture becomes the Debian
architecture and names the deb it supersedes, the dracut hook picks the console
mode the multiplexer can provide, the hook gives root the home directory /,
getcert stops when the image ships no openssl, the genesis case defines its
node with the architecture of the management node and fails when nodeset fails,
doxcat picks dhcpcd where the release drops the ISC client, and go-xcat names
the Genesis packages the packaging builds.

helpers/shell_source.bash gains refute_grep. bash ignores errexit for a command
inverted with "!", so "! grep" anywhere but the last line of a test can never
fail it.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-14 10:07:49 -03:00
Vinícius Ferrão 58828b7a0e test(xCAT-test): cover the cuda install status of ospkgs
The ospkgs apt block runs with a shadowed apt-get that fails only for the
cuda install, and RETURNVAL must carry that status. Against the previous
script the test fails with RETURNVAL=0.

Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com>
2026-09-09 20:29:09 -03:00
Vinícius Ferrão c7b442598e test(xCAT-test): cover the apt calls of ospkgs and otherpkgs
xcat_apt_get is sourced from xcatpkgutils.sh and called with a shadowed
apt-get that records its environment and arguments. The apt block of
ospkgs and the two apt commands of otherpkgs are extracted from the
scripts and executed the same way, since neither script can be sourced.
Against the previous scripts 6 of the 7 tests fail: the helper does not
exist, and the recorded calls carry --force-yes.

Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com>
2026-09-09 20:17:58 -03:00
Daniel Hilst a8e770c42e fix(xcat-core): Prevent BATS checks from missing failures
Negative checks could pass when a later command succeeded. The diskless test also read host state and wrote to the host wget log.

The SSH fallback test did not prove that the restart waited for the killed process.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-08 15:28:04 -03:00
Daniel Hilst cc36d25c35 test(xcat-core): Keep xcatdsklspost download local
xcatdsklspost can run before xcatlib.sh is available beside it in stateless and statelite image contexts. Moving download_postscripts into xcatlib.sh could leave the legacy postscript without its callee when it is copied by itself into the image.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-08 13:10:13 -03:00
Daniel Hilst 58c030a8f3 test(xcat-core): Move BATS tests beside unit tests
Shell unit tests were introduced under xCAT-test/autotest/bats, but the existing source-tree unit suite already lives directly under xCAT-test/unit. Keeping the BATS suite under xCAT-test/bats makes the unit-test layout consistent and keeps autotest reserved for xcattest-driven functional cases.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-08 13:03:34 -03:00