2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-08-03 07:57:00 +00:00
Files
xcat-core/xCAT-test/integration/copycds_packages_integrity.t
T
Daniel Hilst 6ab9aca0b7 fix(xcat-core): split the source-only unit tests from the MN integration tests
Three of the files under xCAT-test/unit are not unit tests. They need an
installed management node rather than a checkout: copycds_packages_integrity.t
wants an /install populated by a real copycds, dhcp_kea_config_validation.t
wants a kea-dhcp4 binary that can read the config it generates, and
dhcp_kea_control_agent_smoke.t wants live kea-dhcp4 and kea-ctrl-agent
daemons running as root.

On a GitHub runner none of that exists, so all three plan skip_all. They were
the only three files skipping in the pull request run, which is not a
coincidence -- the skip is the symptom of them being filed in the wrong place.
A skipped test reports neither pass nor fail, so leaving them mixed in with
the unit tests trains the reader to scroll past skips in a directory where a
skip should mean something is wrong.

Move them to xCAT-test/integration, ship that directory alongside unit in
both the rpm and the deb, and drive it from a new xcattest testcase that
proves the installed copy on an MN. The case is deliberately not labelled
ci_test: the pull request workflow has no management node and must not pick
it up. check:rc==0 is the right gate for it -- prove exits non-zero on a real
failure, exits 0 when a test legitimately skips on a node without Kea, and
exits 2 if the directory is missing entirely, so a packaging regression still
fails the case.

Add a README.md to each directory recording which side of the line a new test
belongs on and how each suite is run.

xCAT-test/unit is now 44 files and 802 assertions with no skips at all; the
assertion count is unchanged, confirming the three moved files were
contributing nothing but skips.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-07-23 11:06:10 -03:00

43 lines
1.2 KiB
Perl

#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use File::Find;
# This test verifies that copycds does not leave empty Packages files
# alongside valid Packages.gz files. An empty Packages file causes
# apt's cdrom handler to fail with a hash mismatch during autoinstall.
my $installdir = $ENV{INSTALLDIR} || '/install';
plan skip_all => "$installdir not found" unless -d $installdir;
my @empty_packages;
my @ok_packages;
find(sub {
return unless $_ eq 'Packages';
return unless -f $File::Find::name;
my $gz = "$File::Find::name.gz";
if (-s $File::Find::name == 0 && -f $gz && -s $gz > 0) {
push @empty_packages, $File::Find::name;
} elsif (-s $File::Find::name > 0) {
push @ok_packages, $File::Find::name;
}
}, "$installdir");
if (@empty_packages || @ok_packages) {
is(scalar @empty_packages, 0,
'no empty Packages files alongside valid Packages.gz')
or diag("Empty Packages files found:\n " . join("\n ", @empty_packages));
cmp_ok(scalar @ok_packages, '>', 0,
'at least one non-empty Packages file exists')
if @ok_packages;
} else {
plan skip_all => "no apt repo trees found under $installdir";
}
done_testing();