mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-12-04 08:07:04 +00:00
test(packaging): execute delivered Debian restart scripts
This commit is contained in:
@@ -26,7 +26,6 @@ SH
|
||||
sandbox=("$bwrap" --unshare-all --die-with-parent --new-session
|
||||
--ro-bind / / --tmpfs /tmp --tmpfs /opt --tmpfs /usr/sbin --proc /proc --dev /dev
|
||||
--bind "$fixture" /tmp/fixture --bind "$fixture/opt/xcat" /opt/xcat
|
||||
--ro-bind "$(repo_path xCAT-server/debian/prerm)" /tmp/prerm
|
||||
--setenv PATH /tmp/fixture/bin:/usr/bin:/bin --setenv RPM_INSTALL_PREFIX0 /opt/xcat)
|
||||
}
|
||||
|
||||
@@ -45,19 +44,3 @@ SH
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@test 'Debian removal stops and disables the UFTP listener' {
|
||||
run "${sandbox[@]}" /bin/sh /tmp/prerm remove
|
||||
[ "$status" -eq 0 ]
|
||||
grep -qx 'stop xcatd.service' "$fixture/systemctl.log"
|
||||
grep -qx 'disable --now xcat-uftp-listener.service' "$fixture/systemctl.log"
|
||||
}
|
||||
|
||||
@test 'Debian upgrade leaves the UFTP listener alone' {
|
||||
run "${sandbox[@]}" /bin/sh /tmp/prerm upgrade 2.19.1
|
||||
[ "$status" -eq 0 ]
|
||||
if grep -q uftp "$fixture/systemctl.log" 2>/dev/null; then
|
||||
echo 'an upgrade touched the listener'
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -26,12 +26,30 @@ sub checked {
|
||||
return $out;
|
||||
}
|
||||
|
||||
sub stage_deb_source {
|
||||
my ($package, $source, $work) = @_;
|
||||
checked('tar', '-cf', "$work/source.tar", '-C', $source, $package);
|
||||
checked('tar', '-xpf', "$work/source.tar", '-C', $work);
|
||||
my $live_root = "$package/debian/xcat-live-root-functions";
|
||||
if (-l "$work/$live_root") {
|
||||
unlink "$work/$live_root" or die "unlink $live_root: $!";
|
||||
copy("$source/$live_root", "$work/$live_root") or die "copy $live_root: $!";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
sub build_deb {
|
||||
my ($package, $source) = @_;
|
||||
$source //= repo_path('.');
|
||||
my $work = tempdir(CLEANUP => 1);
|
||||
checked('tar', '-cf', "$work/source.tar", '-C', $source, $package);
|
||||
checked('tar', '-xpf', "$work/source.tar", '-C', $work);
|
||||
stage_deb_source($package, $source, $work);
|
||||
if ($package eq 'perl-xCAT') {
|
||||
for my $name (qw(Version Gitinfo)) {
|
||||
next unless -f "$source/$name";
|
||||
copy("$source/$name", "$work/$name") or die "copy $name: $!";
|
||||
}
|
||||
write_binary("$work/Gitinfo", "lifecycle-test\n") unless -f "$work/Gitinfo";
|
||||
}
|
||||
if ($package eq 'xCAT-genesis-scripts') {
|
||||
my $arch = checked('dpkg-architecture', '-qDEB_HOST_ARCH');
|
||||
chomp $arch;
|
||||
|
||||
@@ -10,13 +10,49 @@ use XCAT::Test::Lifecycle;
|
||||
plan skip_all => 'Run as an ordinary user on Debian or Ubuntu'
|
||||
unless $^O eq 'linux' && $< != 0 && -f '/etc/debian_version';
|
||||
my %packages = map { $_ => XCAT::Test::Lifecycle::build_deb($_) }
|
||||
qw(xCAT-server xCATsn);
|
||||
qw(perl-xCAT xCAT-server xCATsn);
|
||||
|
||||
sub succeeds {
|
||||
my ($label, @result) = @_;
|
||||
is($result[0], 0, $label) or diag "$result[1]$result[2]";
|
||||
}
|
||||
|
||||
for my $event (qw(remove upgrade)) {
|
||||
subtest "Debian $event UFTP listener" => sub {
|
||||
my $root = XCAT::Test::Lifecycle->new;
|
||||
$root->{live} = 1;
|
||||
$root->write('/calls', '');
|
||||
$root->record_command('/test-bin/systemctl');
|
||||
$root->record_command('/opt/xcat/share/xcat/scripts/xcatd-init-compat');
|
||||
succeeds("run the built Debian $event script",
|
||||
$root->deb_script($packages{'xCAT-server'}, 'prerm', $event, '2.19.1'));
|
||||
if ($event eq 'remove') {
|
||||
like($root->read('/calls'), qr/^systemctl <stop> <xcatd\.service>$/m,
|
||||
'removal stops xcatd');
|
||||
like($root->read('/calls'), qr/^systemctl <disable> <--now> <xcat-uftp-listener\.service>$/m,
|
||||
'removal stops and disables the UFTP listener');
|
||||
} else {
|
||||
unlike($root->read('/calls'), qr/xcat-uftp-listener/,
|
||||
'an upgrade leaves the UFTP listener alone');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
for my $live (0, 1) {
|
||||
for my $event (qw(upgrade remove purge abort-upgrade)) {
|
||||
for my $installed (0, 1) {
|
||||
my $root = XCAT::Test::Lifecycle->new;
|
||||
$root->{live} = $live;
|
||||
$root->record_command('/opt/xcat/sbin/restartxcatd') if $installed;
|
||||
$root->write('/calls', '');
|
||||
succeeds("Debian perl-xCAT $event (proc=$live)",
|
||||
$root->deb_script($packages{'perl-xCAT'}, 'postrm', $event, '2.20.0'));
|
||||
is($root->read('/calls'), $live && $installed && $event eq 'upgrade' ? "restartxcatd <-r>\n" : '',
|
||||
'only an upgrade with proc and an installed helper requests a fast reload');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for my $mode (qw(without-proc live proc-chroot systemd-chroot)) {
|
||||
subtest $mode => sub {
|
||||
my $root = XCAT::Test::Lifecycle->new;
|
||||
@@ -91,7 +127,7 @@ SH
|
||||
'only the live root starts xcatd and reloads Apache');
|
||||
$root->write('/calls', '');
|
||||
succeeds('upgrade the Perl package through the real fast-restart command',
|
||||
$root->run('/bin/sh', '/source/perl-xCAT/debian/postrm', 'upgrade', '2.20.0'));
|
||||
$root->deb_script($packages{'perl-xCAT'}, 'postrm', 'upgrade', '2.20.0'));
|
||||
is($root->read('/calls'), $active ? "xcatd <-p> </var/run/xcatd.pid>\n" : '',
|
||||
'only the live root reaches xcatd through restartxcatd');
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ if (!-f '/etc/debian_version') {
|
||||
check_assets($reduced, 'reduced RPM: ', glob "$share/netboot/rocky/*.riscv64.*");
|
||||
} else {
|
||||
my $fixture = tempdir(CLEANUP => 1);
|
||||
XCAT::Test::Lifecycle::checked('cp', '-a', repo_path('xCAT-server'), "$fixture/xCAT-server");
|
||||
XCAT::Test::Lifecycle::stage_deb_source('xCAT-server', repo_path('.'), $fixture);
|
||||
my $profiles = "$fixture/xCAT-server/share/xcat";
|
||||
XCAT::Test::Lifecycle::checked('chmod', '-R', 'g+w', "$profiles/install", "$profiles/netboot");
|
||||
my $data = 'install/rh/compute.rhels10.riscv64.pkglist';
|
||||
|
||||
@@ -14,21 +14,6 @@ sub succeeds {
|
||||
is($result[0], 0, $label) or diag "$result[1]$result[2]";
|
||||
}
|
||||
|
||||
for my $live (0, 1) {
|
||||
for my $event (qw(upgrade remove purge abort-upgrade)) {
|
||||
for my $installed (0, 1) {
|
||||
my $root = XCAT::Test::Lifecycle->new;
|
||||
$root->{live} = $live;
|
||||
$root->record_command('/opt/xcat/sbin/restartxcatd') if $installed;
|
||||
$root->write('/calls', '');
|
||||
succeeds("Debian perl-xCAT $event (proc=$live)", $root->run('/bin/sh',
|
||||
'/source/perl-xCAT/debian/postrm', $event, '2.20.0'));
|
||||
is($root->read('/calls'), $live && $installed && $event eq 'upgrade' ? "restartxcatd <-r>\n" : '',
|
||||
'only an upgrade with proc and an installed helper requests a fast reload');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for my $package (qw(xCAT-OpenStack xCAT-UI perl-xCAT)) {
|
||||
my $records = XCAT::Test::Lifecycle::checked('rpmspec', '-q', '--qf', "%{NAME}\x1e%{POSTIN}\x1e",
|
||||
'--define', 'version 2.20.0', '--define', 'release 1', '--define', 'gitinfo test',
|
||||
|
||||
Reference in New Issue
Block a user