2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-10 19:46:24 +00:00

test(xCAT-test): drive the mirror choice with the osarch value genimage reads

The mirror assertions passed a Debian architecture straight in and so never
exercised the conversion genimage performs first. They now start from the xCAT
osarch value, which is what let the 32-bit x86 token reach the wrong archive.

Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com>
This commit is contained in:
Vinícius Ferrão
2026-09-06 02:57:13 -03:00
parent a2139d03ed
commit 56910729ce
2 changed files with 25 additions and 0 deletions
+5
View File
@@ -16,6 +16,11 @@ use xCAT::Utils;
# --- what debootstrap and the package lists are given ----------------------
is(xCAT::Utils->debian_arch('x86_64'), 'amd64',
'Debian calls x86_64 amd64');
# genimage passes this value to debootstrap --arch and reads it to pick the apt mirror, and
# debootstrap knows i386, not xCAT's x86.
is(xCAT::Utils->debian_arch('x86'), 'i386',
'debian_arch: the 32-bit x86 token becomes i386');
is(xCAT::Utils->debian_arch('ppc64el'), 'ppc64el',
'the Debian name for POWER LE is unchanged');
is(xCAT::Utils->debian_arch('ppc64le'), 'ppc64le',
@@ -14,6 +14,8 @@ use Test::More;
# evaluated here, so this test tracks the script rather than a copy of it.
my $repo_root = File::Spec->rel2abs( File::Spec->catdir( $FindBin::Bin, '..', '..' ) );
use lib "$FindBin::Bin/../../perl-xCAT";
require xCAT::Utils;
my $genimage_path = File::Spec->catfile(
$repo_root, 'xCAT-server', 'share', 'xcat', 'netboot', 'ubuntu', 'genimage'
);
@@ -29,6 +31,14 @@ my ($pick) = $src =~ /^\s*(my \$mirror = \(defined \$aptmirror\[0\].*?;)\s*$/ms;
ok( defined $pick, 'found the mirror override in genimage' )
or done_testing(), exit;
# genimage does not read osimage.osarch directly: it converts it first, so the value the selection
# sees is whatever xCAT::Utils::debian_arch returns. Driving the xCAT token through that conversion
# is what catches a token the map does not know.
sub choose_osarch {
my ( $osarch, $site ) = @_;
return choose( xCAT::Utils->debian_arch($osarch), $site );
}
sub choose {
my ( $uarch, $site ) = @_;
my $set = defined $site ? "('$site')" : "()";
@@ -57,4 +67,14 @@ is( choose( 'amd64', 'http://mirror.example.invalid/ubuntu' ),
is( choose( 'riscv64', '' ), 'http://ports.ubuntu.com/ubuntu-ports',
'an empty site.ubuntu_apt_mirror does not blank the mirror' );
# The architecture reaches the selection as an xCAT osarch value, not as a Debian one.
is( choose_osarch('x86_64'), 'http://archive.ubuntu.com/ubuntu',
'osarch x86_64 reaches the archive' );
is( choose_osarch('x86'), 'http://archive.ubuntu.com/ubuntu',
'osarch x86 reaches the archive, which is where i386 lives' );
is( choose_osarch('riscv64'), 'http://ports.ubuntu.com/ubuntu-ports',
'osarch riscv64 reaches the ports archive' );
is( choose_osarch('ppc64el'), 'http://ports.ubuntu.com/ubuntu-ports',
'osarch ppc64el reaches the ports archive' );
done_testing();