mirror of
https://github.com/xcat2/xcat-dep.git
synced 2026-11-29 22:02:16 +00:00
test(uftp): require uftp in every openEuler target
Every openEuler section of packages-manifest.conf must list uftp. The ppc64le section is no longer exempt from the package parity check with the EL10 ppc64le section, so its native input catalog must declare an owner for uftp. native/uftp-openeuler.t runs mockbuild-all.pl --dry-run and checks that an openEuler target plans the uftp builder in its own mock config, and only when its manifest section lists uftp. CI runs it with the other native tests.
This commit is contained in:
@@ -65,6 +65,7 @@ jobs:
|
||||
lib/XCAT/GenesisRelease.pm \
|
||||
mockbuild-all.pl \
|
||||
native/uftp-fixes.t \
|
||||
native/uftp-openeuler.t \
|
||||
t/build_utils.t \
|
||||
t/common-repo-gate.t \
|
||||
t/genesis_openembedded_release.t \
|
||||
@@ -110,7 +111,8 @@ jobs:
|
||||
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
||||
prove -v native/buildinfo_provenance.t native/goconserver-openeuler.t \
|
||||
native/openeuler-power-inputs.t native/openeuler-srpm.t \
|
||||
native/xnba-release-suffix.t native/uftp-fixes.t 2>&1 | tee native.tap
|
||||
native/xnba-release-suffix.t native/uftp-fixes.t \
|
||||
native/uftp-openeuler.t 2>&1 | tee native.tap
|
||||
# prove returns success when a test file skips all its checks.
|
||||
if grep -E '^1\.\.0 # SKIP|^native/[^ ]+\.t \.+ skipped' native.tap; then
|
||||
echo 'a native test file was skipped' >&2
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env perl
|
||||
# mockbuild-all.pl --dry-run must plan the uftp builder for an openEuler target whose manifest
|
||||
# section lists uftp, with the mock config of that target, and must not plan it otherwise.
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Cwd qw(abs_path);
|
||||
use File::Path qw(make_path);
|
||||
use File::Temp qw(tempdir);
|
||||
use FindBin qw($RealBin);
|
||||
use JSON::PP qw(encode_json);
|
||||
use Test::More;
|
||||
use Text::ParseWords qw(shellwords);
|
||||
|
||||
use lib "$RealBin/../lib", "$RealBin/../t/lib";
|
||||
use XCAT::BuildUtils qw(capture_command command_exists digest_file read_binary write_binary);
|
||||
use XCAT::GenesisReleaseTest qw(run_capture);
|
||||
|
||||
plan skip_all => 'Linux RPM tools and user namespaces are required'
|
||||
unless $^O eq 'linux' && !grep { !command_exists($_) } qw(rpm unshare);
|
||||
my $tmp = tempdir(CLEANUP => !$ENV{XCAT_TEST_KEEP});
|
||||
my @namespace = $> == 0 ? () : ('unshare', '--user', '--map-root-user');
|
||||
plan skip_all => 'User namespace is unavailable for the root check of mockbuild-all.pl'
|
||||
if @namespace && run_capture("$tmp/namespace.log", @namespace, 'true') != 0;
|
||||
my $collector = $ENV{XCAT_TEST_COLLECTOR} // abs_path("$RealBin/../mockbuild-all.pl");
|
||||
my $arch = capture_command('uname', '-m');
|
||||
|
||||
# Runs the dry-run on a tree whose builders die when executed, and returns the planned uftp
|
||||
# builder command line, or undef when the plan has none.
|
||||
sub planned_uftp {
|
||||
my ($target, $with_uftp) = @_;
|
||||
my $root = "$tmp/$target " . ($with_uftp ? 'with' : 'without') . ' uftp';
|
||||
make_path(map { "$root/$_" } qw(uftp goconserver openeuler));
|
||||
write_binary("$root/packages-manifest.conf",
|
||||
"[$target]\ngoconserver=0.*\n" . ($with_uftp ? "uftp=5.0.4\n" : ''));
|
||||
write_binary("$root/$_/mockbuild.pl", "die qq{dry-run executed a builder\\n};\n") for qw(uftp goconserver);
|
||||
if ($target eq 'openeuler-24.03-ppc64le') {
|
||||
my $key = 'openeuler/publisher.key';
|
||||
write_binary("$root/$key", 'dry-run key fixture');
|
||||
write_binary("$root/openeuler/24.03-ppc64le.inputs.json", encode_json({
|
||||
version => 1, target => $target,
|
||||
publisher_key => {path => $key, sha256 => digest_file("$root/$key"), fingerprint => ('A' x 40)},
|
||||
inputs => [map { {name => $_, type => 'owner', outputs => [$_], build_uid => 1000} }
|
||||
qw(goconserver uftp)],
|
||||
}));
|
||||
}
|
||||
local $ENV{MOCKBUILD_ALL_MOUNTNS} = 1;
|
||||
my $log = "$root.log";
|
||||
my $rc = run_capture($log, @namespace, $^X, $collector, '--repo-root', $root,
|
||||
'--xcat-source', $root, '--target', $target, '--output', "$root/output",
|
||||
'--build-timestamp', 1788718796, '--run-id', 'uftp-plan', '--skip-genesis', '--gpg-sign',
|
||||
'--max-parallel', 1, '--parallel-builds', 1, '--dry-run');
|
||||
is($rc, 0, "$target dry-run succeeds " . ($with_uftp ? 'with' : 'without') . ' uftp')
|
||||
or diag(read_binary($log));
|
||||
my ($command) = read_binary($log) =~ /^\+ ([^\n]*\Q$root\/uftp\/mockbuild.pl\E[^\n]*)$/m;
|
||||
return unless defined $command;
|
||||
# A native owner wraps the builder in its own shell commands.
|
||||
my @argv = shellwords($command);
|
||||
for (1 .. 3) {
|
||||
last if $argv[0] eq 'perl';
|
||||
@argv = shellwords($argv[-1]);
|
||||
}
|
||||
return \@argv;
|
||||
}
|
||||
|
||||
my @targets = ("alma+epel-9-$arch");
|
||||
push @targets, 'openeuler-24.03sp3-x86_64', 'openeuler-20.03sp4-x86_64' if $arch eq 'x86_64';
|
||||
push @targets, 'openeuler-24.03-ppc64le' if $arch eq 'ppc64le';
|
||||
for my $target (@targets) {
|
||||
my $argv = planned_uftp($target, 1);
|
||||
ok($argv, "$target plans the uftp builder");
|
||||
if ($argv) {
|
||||
is($argv->[0], 'perl', "$target runs the uftp builder with perl");
|
||||
my %options;
|
||||
for my $i (0 .. $#$argv - 1) { $options{$argv->[$i]} = $argv->[$i + 1]; }
|
||||
is($options{'--mock-cfg'}, $target, "$target builds uftp in its own mock config");
|
||||
ok(!exists $options{'--target-arch'}, "$target builds uftp natively");
|
||||
}
|
||||
ok(!planned_uftp($target, 0), "$target does not plan uftp when its manifest section lacks it");
|
||||
}
|
||||
done_testing();
|
||||
+5
-3
@@ -536,9 +536,11 @@ is(rpm_release(tempdir(CLEANUP => 1), 'nonexistent-pkg'), undef, 'rpm_release is
|
||||
or diag("missing ipxe-xcat in: @no_ipxe_xcat");
|
||||
is_deeply(\@missing, [], 'conserver-xcat is present in every legacy manifest target section')
|
||||
or diag("missing conserver-xcat in: @missing");
|
||||
# uftp is optional for xCAT like conserver-xcat, and BUILD.md documents it for every EL target.
|
||||
my @no_uftp = grep { !exists $m{$_}{uftp} } @targets, 'rocky-10-riscv64-xcat';
|
||||
is_deeply(\@no_uftp, [], 'uftp is present in every EL manifest target section')
|
||||
# uftp is optional for xCAT like conserver-xcat, and BUILD.md documents it for every EL and
|
||||
# openEuler target.
|
||||
my @no_uftp = grep { !exists $m{$_}{uftp} }
|
||||
@targets, 'rocky-10-riscv64-xcat', grep { /^openeuler-/ } sort keys %m;
|
||||
is_deeply(\@no_uftp, [], 'uftp is present in every EL and openEuler manifest target section')
|
||||
or diag("missing uftp in: @no_uftp");
|
||||
my @native_missing = grep { /^openeuler-/ && !exists $m{$_}{goconserver} } sort keys %m;
|
||||
is_deeply(\@native_missing, [], 'native manifest targets retain goconserver');
|
||||
|
||||
@@ -64,7 +64,6 @@ for my $path (
|
||||
my %exempt = (
|
||||
'conserver-xcat' => 'xCAT requires goconserver; no core rpm requires conserver-xcat',
|
||||
'elilo-xcat' => 'no core rpm requires elilo-xcat',
|
||||
'uftp' => 'no core rpm requires uftp',
|
||||
);
|
||||
my $reference = 'alma+epel-10-ppc64le';
|
||||
ok(scalar keys %{$manifest{$reference}}, "$reference is the reference section and is not empty");
|
||||
|
||||
Reference in New Issue
Block a user