diff --git a/xCAT-test/unit/ubuntu_shared_pkglists.t b/xCAT-test/unit/ubuntu_shared_pkglists.t index ff1d0092e..3046c3985 100644 --- a/xCAT-test/unit/ubuntu_shared_pkglists.t +++ b/xCAT-test/unit/ubuntu_shared_pkglists.t @@ -39,7 +39,8 @@ sub resolved { } # The shared lists keep ntp for the releases that still carry it. aarch64 has no list of its own. -# The install compute profile gets a 24.04 list of its own next, so it is no longer pinned here. +# The install compute profile has a 24.04 list of its own, with chrony: the Subiquity template +# installs chrony and ntp cannot join it in one apt transaction (ubuntu_subiquity_pkglists.t). foreach my $case ( [ $install, 'service' ], [ $install, 'kvm' ], [ $netboot, 'compute' ] ) { my ( $dir, $profile ) = @$case; my ( $file, $p ) = resolved( $dir, $profile, 'ubuntu24.04.4', 'aarch64' ); @@ -47,6 +48,11 @@ foreach my $case ( [ $install, 'service' ], [ $install, 'kvm' ], [ $netboot, 'co ok( $p->{ntp}, "... which keeps ntp" ); ok( !$p->{$_}, "... and no longer names $_" ) for qw(libodbc1 qemu-kvm libvirt-bin); } +{ + my ( $file, $p ) = resolved( $install, 'compute', 'ubuntu24.04.4', 'aarch64' ); + is( $file, 'compute.ubuntu24.04.pkglist', 'the install compute profile on 24.04 resolves its own list' ); + ok( $p->{chrony} && !$p->{ntp}, '... which names chrony and not ntp' ); +} ok( packages_in("$install/service.pkglist")->{unixodbc}, 'the shared service list names unixodbc' ); ok( packages_in("$install/service.pkglist")->{'libdbd-pg-perl'}, '... and the PostgreSQL driver beside the MySQL one' ); diff --git a/xCAT-test/unit/ubuntu_subiquity_pkglists.t b/xCAT-test/unit/ubuntu_subiquity_pkglists.t new file mode 100644 index 000000000..393dee965 --- /dev/null +++ b/xCAT-test/unit/ubuntu_subiquity_pkglists.t @@ -0,0 +1,62 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use File::Spec; +use FindBin; +use Test::More; + +use lib "$FindBin::Bin/../../perl-xCAT"; +use lib "$FindBin::Bin/../../xCAT-server/lib/perl"; +use xCAT::Postage; +use xCAT::SvrUtils; + +# The Subiquity autoinstall installs the template's fixed packages and the osimage pkglist in one +# apt transaction, and the template names chrony. The shared compute.pkglist names ntp for the +# releases before Subiquity, and on the Subiquity releases ntp pulls ntpsec, which conflicts with +# chrony, so those releases need their own default list. The lists are resolved the way +# mkinstall resolves them and their packages are read the way ospkgs reads them. + +my $repo = File::Spec->rel2abs( File::Spec->catdir( $FindBin::Bin, '..', '..' ) ); +my $install = "$repo/xCAT-server/share/xcat/install/ubuntu"; +my $template = "$install/compute.subiquity.tmpl"; +plan skip_all => 'the Ubuntu install directory is not here' unless -d $install && -f $template; + +sub packages_in { + my ($path) = @_; + return { map { $_ => 1 } grep { length } split /,/, xCAT::Postage::get_pkglist_tex($path) }; +} + +sub resolved { + my ( $os, $arch ) = @_; + return xCAT::SvrUtils->get_pkglist_file_name( $install, 'compute', $os, $arch, $os =~ /^(ubuntu\d+\.\d+)/ ? $1 : $os ); +} + +open( my $tfh, '<', $template ) or die "$template: $!"; +my $body = do { local $/; <$tfh> }; +close($tfh); +my ($block) = $body =~ /^ packages:\n((?: - .*\n)+)/m; +my %fixed = map { $_ => 1 } ( $block =~ /^ - ([^#\s]+)$/mg ); +ok( $fixed{chrony}, 'the Subiquity template names chrony among its fixed packages' ); + +my %time_daemon = map { $_ => 1 } qw(chrony ntp ntpsec); +foreach my $case ( [ 'ubuntu20.04.6', 'x86_64' ], [ 'ubuntu20.04.6', 'ppc64le' ], + [ 'ubuntu22.04.5', 'x86_64' ], [ 'ubuntu22.04.5', 'ppc64le' ], + [ 'ubuntu24.04.4', 'x86_64' ], [ 'ubuntu24.04.4', 'ppc64le' ], [ 'ubuntu24.04.4', 'riscv64' ], + [ 'ubuntu26.04.1', 'x86_64' ], [ 'ubuntu26.04.1', 'riscv64' ] ) { + my ( $os, $arch ) = @$case; + my $file = resolved( $os, $arch ); + ok( $file, "$os $arch resolves a compute pkglist" ) or next; + my $packages = packages_in($file); + ok( $packages->{chrony}, "$os $arch: the list names chrony, the daemon the template installs" ); + ok( !$packages->{ntp} && !$packages->{ntpdate}, "$os $arch: ... and not ntp, which would conflict with it" ); + my @daemons = grep { $time_daemon{$_} } keys %{ { %fixed, %$packages } }; + is( scalar(@daemons), 1, "$os $arch: the autoinstall transaction carries exactly one time daemon" ); +} + +# The releases before Subiquity keep the shared list and its ntp. +my $legacy = resolved( 'ubuntu16.04.7', 'x86_64' ); +is( $legacy, "$install/compute.pkglist", '16.04 still resolves the shared list' ); +ok( packages_in($legacy)->{ntp}, '... which keeps ntp for the releases where chrony was not the default' ); + +done_testing();