2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-10-21 15:18:19 +00:00
Files
xcat-core/xCAT-test/native
Daniel Hilst 926c076533 test(xcat-core): the mock result directory owner ignores include() and stale logs
mock_build_owner reads chrootuid and chrootgid from the text of the
rendered configuration. It does not see a value set in an included file,
an assignment with an inline comment or a double-quoted key, or an
include that overrides an earlier assignment. prepare_mock_resultdirs
then gives the result directories to the wrong uid, or to none.

prepare_mock_resultdirs changes only the two directories. A root build
that stopped part way leaves root-owned 0644 logs in them, and mock,
running as uid 1000, cannot append to them on the next run.

native/mock_resultdir_owner.t runs mock's loader on each configuration
case, and checks as root that uid 1000 can append to the stale logs in
both directories. Ubuntu ships no mock, so the workflow runs it in a
Fedora container and fails when it skips. The unit test checks, with
chown recorded, which owner the directories and their files get.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-12 11:02:51 -03:00
..

Native host tests

These tests use the source checkout with RPM tools, Linux namespaces or real service binaries. They are separate from unit/ and are not discovered by the default pull-request unit run. Run them explicitly on a disposable Linux host.

The postinstall case requires bubblewrap and the Perl modules used by the xCAT template renderer. It runs complete rendered installer and postboot scripts in private filesystems, with doubles for downloads and service commands:

prove xCAT-test/native/postinstall_bootstrap.t

It can run as root or an ordinary user with user namespaces enabled. This case checks service policy and ordering; it does not boot or reinstall an OS. The client steps cannot access the source tree or the server postscripts directory.

Run the package and unprivileged namespace cases as an ordinary user:

prove xCAT-test/native/buildrpms_openeuler.t \
      xCAT-test/native/buildrpms_release_openeuler.t \
      xCAT-test/native/genesis_openeuler*.t \
      xCAT-test/native/openeuler_genimage_bootfiles.t \
      xCAT-test/native/openeuler_package_policy.t

Run the isolated system cases as root:

sudo prove xCAT-test/native/ip_forwarding.t \
      xCAT-test/native/openeuler_genimage_transactions.t \
      xCAT-test/native/openeuler_install_repositories.t \
      xCAT-test/native/openeuler_networking.t \
      xCAT-test/native/openeuler_xcatroot.t \
      xCAT-test/native/remoteshell_hostkeys_openeuler.t \
      xCAT-test/native/syslog_openeuler*.t

The mock result directory case needs the mock Python library, and root for its ownership checks. The xcat_test workflow runs it as root in a Fedora container:

sudo prove xCAT-test/native/mock_resultdir_owner.t

The PostgreSQL case starts a private server with only a Unix socket. Run it as an ordinary user with XCAT_TEST_PG_BINDIR set to the directory containing initdb, pg_ctl, postgres, psql and createdb:

XCAT_TEST_PG_BINDIR=/usr/bin prove xCAT-test/native/pgsqlsetup_native_schema.t

Check the TAP output for skipped prerequisites. A successful prove exit with skipped cases does not qualify those cases.

Package lifecycle

Run these cases as an ordinary user with unprivileged Linux namespaces enabled. They use private filesystem, process and network namespaces, not host services.

On Debian or Ubuntu, install bubblewrap, debhelper, devscripts, fakeroot, quilt, ucf, debconf-utils, systemd, rpm, apache2, curl, libcapture-tiny-perl and libfile-slurper-perl, then run:

prove xCAT-test/native/xcatd_debian_lifecycle.t \
      xCAT-test/native/xcatd_restart_callers.t \
      xCAT-test/native/apache_package_lifecycle.t

On EL8 or EL10, install bubblewrap, rpm-build, systemd, chkconfig, initscripts, httpd, curl, tar, gzip, which, diffutils, procps-ng, perl-Capture-Tiny, perl-File-Slurper and perl-Test-Simple, then run:

prove xCAT-test/native/xcatd_rpm_lifecycle.t \
      xCAT-test/native/apache_rpm_configuration.t \
      xCAT-test/native/apache_package_lifecycle.t

These EL dependencies need EPEL plus PowerTools on EL8 or CRB on EL10.

Package transactions use native package tools and private package databases. Dependency resolution is bypassed to isolate maintainer-script behavior. Service registration uses real offline tools. Service dispatch uses command fixtures, while header checks start real Apache on an isolated loopback port. The service cases execute the installed unit's start command with a daemon fixture. RPM upgrades also cover the old package-owned init-script layout. The Debian Apache cases unpack built packages and execute their complete maintainer scripts. Restart-caller cases execute complete Debian scripts and RPM-rendered scriptlets without building the optional UI package.

The RPM Apache cases distinguish a root without /proc from a chroot with /proc mounted and a different PID 1 root. Debian and restart-caller cases check dispatch with and without /proc; these do not qualify chroot safety.

The configuration cases exercise EL and SUSE build-macro selections on native EL RPM tools. The legacy release identities select init policy, not a native EL6 or Ubuntu 14.04 environment. These cases do not qualify native SUSE package transactions, dependency resolution, a running xcatd daemon, or machine boot. The namespace fixture targets merged-/usr hosts. Container runs need namespace permissions and an init process that reaps orphaned children.