From 378ba7eba12c97015754c318617932b92ca5d676 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Fri, 11 Sep 2026 12:02:14 -0300 Subject: [PATCH] test(provtest): assert what the renderers produced, not that they ran The kickstart template carried no directive, so mkinstall rendered it correctly by doing nothing; it now carries a #TABLE: per node and an #INCLUDE:, and the fetched autoinst is asserted to hold the expanded values and no directive or #INCLUDEBAD:. The postscripts listing is walked as a node walks it: a name taken out of the index, then that leaf fetched -- Indexes and the alias are separate directives, and a tree listed but unreadable fails every postscript at once. And the kernel and initrd the config names are fetched over both transports and compared by sha256. --- .../autotest/testcase/provtest/provfixture.sh | 23 +++- xCAT-test/provtest/conf/http.conf | 105 ++++++++++++++++++ 2 files changed, 124 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/testcase/provtest/provfixture.sh b/xCAT-test/autotest/testcase/provtest/provfixture.sh index e1c5efb8a..50a4483a1 100755 --- a/xCAT-test/autotest/testcase/provtest/provfixture.sh +++ b/xCAT-test/autotest/testcase/provtest/provfixture.sh @@ -410,16 +410,26 @@ EOF } # The template mkinstall renders into /install/autoinst/: P-35 fetches the -# rendered result, so a finished file would not do. +# rendered result, so a finished file would not do. It carries a directive of +# each kind the renderer has to handle -- a #TABLE: read per node, an #INCLUDE: +# of a second file -- because a template with none of them is rendered correctly +# by doing nothing at all, and the HTTP stage asserts what came out. fabricate_template() { - local path=$1 - write_file "$path" <<'EOF' + local path=$1 include + include="$(dirname "$path")/provtest-include.tmpl" + write_file "$include" <<'EOF' +provtest_included yes +EOF + write_file "$path" < 0 + # The file is what mkinstall rendered, not the template it rendered from. + # The caller's template carries a #TABLE: directive for each value below and + # an #INCLUDE: of a second file; an installer handed the unrendered form + # fails at the first line it does not understand, and one handed an empty + # expansion installs with no repository and no address. + text matches ^provtest_xcatmaster %(master)s$ + text matches ^provtest_arch %(arch)s$ + text matches ^provtest_included yes$ + +[step leftover] +type = extract +from = $autoinst.text +# Template.pm substitutes every directive in one pass (Template.pm:297, 375-385), +# so one still in the file is one nothing recognised. #INCLUDEBAD: is what +# includefile writes in place of a file it could not open (Template.pm:1551) -- +# a rendered kickstart that names it is one an installer will read to the end +# and then stop. +pattern = #(?:TABLE|TABLEBLANKOKAY|INCLUDE|INCLUDEBAD|CRYPT|ENV|XCATVAR): +assert = + matched == no # --- P-33 ------------------------------------------------------------------- @@ -99,6 +120,69 @@ url = $repourl.value/%(repofile)s assert = status == 200 +# --- P-33, P-34, for the two files a node actually boots --------------------- + +[scenario boot-images-over-http] +description = The kernel and initrd the node was told to fetch are served over HTTP, byte for byte + +[step imageconfig] +type = tftp +path = %(knownfile)s +port = 69 +assert = + size > 0 + +[step kernelpath] +type = extract +from = $imageconfig.text +# grub2 writes the tftp root's own prefix into the path when the protocol is +# http (grub2.pm:274-277), which is exactly the alias the web server publishes +# that tree under -- so the same capture serves both fetches below. +pattern = ^\s*linux(?:efi|16)?\s+/?(?:tftpboot/)?(\S+) +assert = + matched == yes + +[step kerneltftp] +type = tftp +path = $kernelpath.value +port = 69 +assert = + size > 0 + +[step kernelhttp] +type = http +path = /tftpboot/$kernelpath.value +# Not the same claim as the tftp tree being served: this is the file the node +# was told to boot, fetched the way the node will fetch it. A truncated or +# stale copy behind the web server is a kernel that will not decompress, and +# nothing on the management node notices. +assert = + status == 200 + size > 0 + sha256 == $kerneltftp.sha256 + +[step initrdpath] +type = extract +from = $imageconfig.text +pattern = ^\s*initrd(?:efi|16)?\s+/?(?:tftpboot/)?(\S+) +assert = + matched == yes + +[step initrdtftp] +type = tftp +path = $initrdpath.value +port = 69 +assert = + size > 0 + +[step initrdhttp] +type = http +path = /tftpboot/$initrdpath.value +assert = + status == 200 + size > 0 + sha256 == $initrdtftp.sha256 + # --- P-37 ------------------------------------------------------------------- [scenario outside-the-aliases] @@ -128,6 +212,27 @@ assert = status == 200 size > 0 +[step scriptname] +type = extract +from = $listing.text +# The first entry that is a plain relative name: Apache's index also carries the +# sort links (`?C=N;O=D`), the parent (`/install/`) and any subdirectory, which +# ends in a slash. Taking a name out of the listing rather than naming one here +# is what makes the fetch below a walk of the tree the node sees. +pattern = 0 + # --- P-39 ------------------------------------------------------------------- [scenario port-the-node-was-told]