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/integration
Vinícius Ferrão da3c4e9dfe test(dhcp): cover the iPXE feature options of an upgraded configuration
makedhcp adds the missing ISC declarations after the gpxe option space,
and the missing Kea definitions after the existing ones, once. Indented
ISC declarations and declarations with more blanks count. An ISC
configuration without the gpxe space gives an error and stays as it is,
and so does a Kea definition of option 175 without the gpxe
encapsulation, and makedhcp then writes nothing.

makedhcp writes the ISC configuration and restarts dhcpd at once. When
the configuration declares no gpxe option space, or makedhcp cannot
write the file or restart dhcpd, it reports the error and changes no
subnet or host. A marker beside the configuration stays until a restart
succeeds, so the next run restarts dhcpd before it changes a host.
Without a dhcpd.conf, or with one that xCAT did not write, it gives no
error and goes on to write a new configuration. Kea restarts to load the
definitions, also when the Control Agent applies the host reservations.

Every option code stays a number: JSON::XS writes a number that Perl has
used as a string as a JSON string, and Kea rejects it. kea-dhcp4 -t
checks an upgraded and a current configuration that makedhcp writes
back.
2026-10-02 20:11:18 -03:00
..

xCAT-test/integration

Integration tests. These run against an installed management node -- they need a real xCAT installation, and depending on the test a populated /install, a service binary they can execute, or a live daemon.

They are driven by xcattest through the testcase in ../autotest/testcase/integration/, which proves the copy installed by the xcat-test package:

prove -I/opt/xcat/lib/perl -I/opt/xcat/lib/perl/xCAT \
      -r /opt/xcat/share/xcat/tools/autotest/integration

Run the case by hand on an MN with:

xcattest -f <cluster.conf> -t integration_tests

The case carries the ci_test label, so it also runs on every pull request: the xcat_test GitHub Actions workflow installs and configures xCAT on the runner, which makes that runner a (single node) management node, and then runs every ci_test case against it.

Note the -I flags: unlike the unit tests these run from the installed location, so they pick up xCAT modules from /opt/xcat/lib/perl rather than from a source tree.

The case checks rc==0 and output=~Files=7,. The file count checks that prove found all seven files, which catches a packaging regression or a test renamed away from .t without updating the count. It does not prove that environment-gated cases ran; inspect the TAP output for skips. Add to that number when you add a test. A missing directory is already caught by rc==0 -- prove -r on a path that does not exist exits 2.

Note also that github_action_xcat_test.pl invokes each case through sudo, so in CI these tests run as root while the unit tests run unprivileged. That is the right way round -- integration tests legitimately need to write to places like /etc/kea, whereas running the unit tests as root would let permission-related assertions pass for the wrong reason.

What belongs here

A test belongs in integration/ when it needs something the checkout cannot provide:

Test Requires
copycds_packages_integrity.t /install populated by a real copycds
dhcp_isc_config_validation.t a dhcpd binary that can read the generated config, as root
dhcp_kea_config_validation.t a kea-dhcp4 binary that can read the generated config
dhcp_kea_control_agent_smoke.t live kea-dhcp4 and kea-ctrl-agent, root, and the Kea host-commands hook
html_form_runtime_dependency.t the installed HTML::Form module
openeuler_package_postscripts.t Linux root, private mount namespaces and DNF; tests complete package postscripts with command doubles and an isolated repository directory
openeuler_postscript_repositories.t Linux root, private mount namespaces, DNF and RPM signing tools; tests actual signed repository transactions in isolated install roots

Environment guards

openeuler_postscript_repositories.t builds and signs RPM fixtures and runs real DNF transactions. Enable it explicitly on a disposable openEuler host:

sudo env XCAT_NATIVE_REPOSITORIES=1 prove -v \
    xCAT-test/integration/openeuler_postscript_repositories.t

The Perl test builds the RPM fixtures directly. Its DNF adapter records arguments and uses only local fixture repositories, with a fixed fixture release version.

Tests with optional runtime dependencies guard with plan skip_all -- an MN with no Kea installed should skip the Kea tests, not go red. The HTML::Form test is different: it verifies a required installed dependency and fails when that module is absent. A skip in this directory is therefore expected and normal.

Which tests actually run consequently varies by node. On a GitHub runner, for example, /install is empty so copycds_packages_integrity.t skips, while dhcp_kea_config_validation.t does run because the case executes as root and can therefore validate from /etc/kea.

dhcp_kea_control_agent_smoke.t is opt-in on top of that:

plan skip_all => 'set XCAT_KEA_LIVE_SMOKE=1 to run live Kea daemon smoke test'
  unless $ENV{XCAT_KEA_LIVE_SMOKE};

It starts real Kea daemons, so it stays off unless asked for. Do not enable it on a node whose DHCP service is in use.

What does not belong here

Anything that only needs the checkout. Those go in ../unit and run on every pull request, which is much faster feedback than waiting for a cluster test.