2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-27 12:52:16 +00:00

Merge master into feat/selinux-netboot

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-10-21 08:53:16 -03:00
39 changed files with 1020 additions and 786 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ jobs:
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential meson ninja-build pkg-config libnewt-dev \
libsystemd-dev python3-pyte bubblewrap systemd-journal-remote
- name: Enable isolated journal test namespaces
- name: Enable isolated console test namespaces
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
- name: Exercise the newt dialogs
run: /usr/bin/python3 xCAT-test/native/genesis_console_dialogs.py
+3 -3
View File
@@ -15,7 +15,7 @@ jobs:
- name: Install lifecycle test dependencies
run: sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests ucf debconf-utils systemd libxml-simple-perl apache2 curl
- name: Test Debian package lifecycle
run: prove -v xCAT-test/native/xcatd_debian_lifecycle.t xCAT-test/native/xcatd_restart_callers.t xCAT-test/native/apache_package_lifecycle.t xCAT-test/native/package_upgrade_logging.t
run: prove -v xCAT-test/native/xcatd_debian_lifecycle.t xCAT-test/native/xcatd_restart_callers.t xCAT-test/native/apache_package_lifecycle.t xCAT-test/native/package_upgrade_logging.t xCAT-test/native/profile_package_payload.t
- name: Install image test dependencies
if: ${{ !cancelled() }}
@@ -111,11 +111,11 @@ jobs:
- name: Install lifecycle test dependencies
run: |
dnf install -y epel-release
dnf --enablerepo=${{ matrix.repository }} install -y perl perl-Capture-Tiny perl-File-Slurper perl-Test-Simple perl-Test-Harness rpm-build bubblewrap systemd chkconfig initscripts tar gzip which diffutils httpd curl procps-ng
dnf --enablerepo=${{ matrix.repository }} install -y perl perl-Capture-Tiny perl-File-Slurper perl-Test-Simple perl-Test-Harness perl-DBI perl-DBD-SQLite perl-JSON perl-XML-Simple rpm-build bubblewrap systemd chkconfig initscripts tar gzip which diffutils httpd curl procps-ng
- name: Enable lifecycle test namespaces
run: sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
- name: Test RPM package lifecycle
run: su -s /bin/sh nobody -c 'prove -v xCAT-test/native/xcatd_rpm_lifecycle.t xCAT-test/native/apache_rpm_configuration.t xCAT-test/native/apache_package_lifecycle.t xCAT-test/native/package_upgrade_logging.t'
run: su -s /bin/sh nobody -c 'prove -v xCAT-test/native/xcatd_rpm_lifecycle.t xCAT-test/native/apache_rpm_configuration.t xCAT-test/native/apache_package_lifecycle.t xCAT-test/native/package_upgrade_logging.t xCAT-test/native/profile_package_payload.t'
selinux_policy_test:
runs-on: ubuntu-24.04
timeout-minutes: 20
+8
View File
@@ -5006,6 +5006,14 @@ sub splitkcmdline {
}
sub ubuntu_default_mirror {
my $arch = shift;
$arch = shift if defined($arch) && $arch eq 'xCAT::Utils';
return defined($arch) && $arch =~ /^(?:amd64|i386|x86|x86_64)$/
? 'http://archive.ubuntu.com/ubuntu'
: 'http://ports.ubuntu.com/ubuntu-ports';
}
###################################################################################
#subroutine debian_arch
#Usage: give the Debian architecture name for an xCAT architecture. The media, the
@@ -266,19 +266,36 @@ static bool genesis_journal_entry(sd_journal *journal, char *source, size_t sour
return true;
}
static void format_logs(char *text, size_t size) {
struct log_record {
char text[LOG_LINE_SIZE];
char *cursor;
unsigned int first_row;
unsigned int row_count;
bool selected;
};
struct log_view {
struct log_record records[LOG_LINE_COUNT];
unsigned int count;
unsigned int start;
};
static void free_log_view(struct log_view *view) {
for (unsigned int index = 0; index < LOG_LINE_COUNT; index++)
free(view->records[index].cursor);
}
static void load_logs(struct log_view *view, const char *selected_cursor) {
sd_journal *journal = NULL;
char lines[LOG_LINE_COUNT][LOG_LINE_SIZE] = {{0}};
unsigned int count = 0;
unsigned int next = 0;
int result;
if (size == 0)
return;
text[0] = '\0';
result = sd_journal_open(&journal, SD_JOURNAL_LOCAL_ONLY | SD_JOURNAL_SYSTEM);
if (result < 0) {
xcat_set_text(text, size, "Genesis journal is unavailable: %s", strerror(-result));
xcat_set_text(view->records[0].text, LOG_LINE_SIZE, "Genesis journal is unavailable: %s",
strerror(-result));
view->count = 1;
return;
}
@@ -289,6 +306,7 @@ static void format_logs(char *text, size_t size) {
char source[96] = "";
char timestamp[16] = "--:--:--";
uint64_t realtime;
struct log_record *record = &view->records[next];
if (!genesis_journal_entry(journal, source, sizeof(source)) ||
!journal_value(journal, "MESSAGE", message, sizeof(message)))
@@ -300,32 +318,25 @@ static void format_logs(char *text, size_t size) {
if (localtime_r(&seconds, &local_time) != NULL)
strftime(timestamp, sizeof(timestamp), "%H:%M:%S", &local_time);
}
snprintf(lines[next], sizeof(lines[next]), "%s %-24.24s %s", timestamp, source, message);
free(record->cursor);
record->cursor = NULL;
sd_journal_get_cursor(journal, &record->cursor);
record->selected =
selected_cursor != NULL && sd_journal_test_cursor(journal, selected_cursor) > 0;
snprintf(record->text, sizeof(record->text), "%s %-24.24s %s", timestamp, source, message);
next = (next + 1) % LOG_LINE_COUNT;
count++;
}
sd_journal_close(journal);
if (count == 0) {
xcat_set_text(text, size, "No Genesis journal entries are available.");
xcat_set_text(view->records[0].text, LOG_LINE_SIZE,
"No Genesis journal entries are available.");
view->count = 1;
return;
}
{
unsigned int available = count < LOG_LINE_COUNT ? count : LOG_LINE_COUNT;
unsigned int start = count < LOG_LINE_COUNT ? 0 : next;
unsigned int index;
size_t used = 0;
for (index = 0; index < available && used + 1 < size; index++) {
unsigned int line = (start + index) % LOG_LINE_COUNT;
int written =
snprintf(text + used, size - used, "%s%s", index > 0 ? "\n" : "", lines[line]);
if (written < 0 || (size_t)written >= size - used)
break;
used += (size_t)written;
}
}
view->count = count < LOG_LINE_COUNT ? count : LOG_LINE_COUNT;
view->start = count < LOG_LINE_COUNT ? 0 : next;
}
static unsigned int append_wrapped_log_record(newtComponent list_box, const char *record,
@@ -365,30 +376,48 @@ static unsigned int append_wrapped_log_record(newtComponent list_box, const char
return count;
}
static unsigned int populate_log_listbox(newtComponent list_box, const char *text) {
const char *record = text;
static unsigned int populate_log_listbox(newtComponent list_box, struct log_view *view) {
unsigned int count = 0;
while (*record != '\0') {
const char *end = strchr(record, '\n');
size_t length = end != NULL ? (size_t)(end - record) : strlen(record);
for (unsigned int index = 0; index < view->count; index++) {
struct log_record *record = &view->records[(view->start + index) % LOG_LINE_COUNT];
count = append_wrapped_log_record(list_box, record, length, count);
if (end == NULL)
break;
record = end + 1;
record->first_row = count + 1;
count = append_wrapped_log_record(list_box, record->text, strlen(record->text), count);
record->row_count = count + 1 - record->first_row;
}
if (count == 0)
count = append_wrapped_log_record(list_box, "", 0, count);
return count;
}
static const struct log_record *selected_log_record(const struct log_view *view,
unsigned int selected) {
for (unsigned int index = 0; index < view->count; index++) {
const struct log_record *record = &view->records[(view->start + index) % LOG_LINE_COUNT];
if (selected >= record->first_row && selected - record->first_row < record->row_count)
return record;
}
return NULL;
}
static unsigned int retained_log_row(const struct log_view *view, unsigned int offset) {
for (unsigned int index = 0; index < view->count; index++) {
const struct log_record *record = &view->records[(view->start + index) % LOG_LINE_COUNT];
if (record->selected) {
if (offset >= record->row_count)
offset = record->row_count - 1;
return record->first_row + offset;
}
}
return 1;
}
static void show_logs(void) {
struct newtExitStruct event;
newtComponent form;
newtComponent list_box;
char text[LOG_LINE_COUNT * LOG_LINE_SIZE];
char previous[LOG_LINE_COUNT * LOG_LINE_SIZE] = "";
struct log_view previous = {0};
unsigned int item_count = 0;
unsigned int selected = 0;
bool follow = true;
@@ -410,15 +439,17 @@ static void show_logs(void) {
newtPushHelpLine(" F3 Back Esc Back Up/Down Scroll End Follow");
while (!xcat_console_stop_requested) {
format_logs(text, sizeof(text));
if (previous[0] == '\0' || strcmp(previous, text) != 0) {
newtListboxClear(list_box);
item_count = populate_log_listbox(list_box, text);
if (follow || selected == 0 || selected > item_count)
selected = item_count;
newtListboxSetCurrentByKey(list_box, (void *)(uintptr_t)selected);
xcat_copy_printable(previous, sizeof(previous), text);
}
struct log_view current = {0};
const struct log_record *record = selected_log_record(&previous, selected);
unsigned int offset = record != NULL ? selected - record->first_row : 0;
load_logs(&current, !follow && record != NULL ? record->cursor : NULL);
newtListboxClear(list_box);
item_count = populate_log_listbox(list_box, &current);
selected = follow ? item_count : retained_log_row(&current, offset);
newtListboxSetCurrentByKey(list_box, (void *)(uintptr_t)selected);
free_log_view(&previous);
previous = current;
newtRefresh();
newtFormRun(form, &event);
if (event.reason == NEWT_EXIT_ERROR ||
@@ -452,6 +483,7 @@ static void show_logs(void) {
newtListboxSetCurrentByKey(list_box, (void *)(uintptr_t)selected);
}
free_log_view(&previous);
newtFormDestroy(form);
newtPopHelpLine();
newtPopWindow();
+1
View File
@@ -52,6 +52,7 @@ binary-arch:
chmod 755 $(rootdir)/share/xcat/ib/*
chmod 755 $(rootdir)/share/xcat/ib/netboot/sles/*
chmod 755 $(rootdir)/share/xcat/ib/netboot/rh/*
chmod -R go-w $(rootdir)/share/xcat/install $(rootdir)/share/xcat/netboot
chmod 644 $(rootdir)/lib/perl/xCAT_plugin/*
chmod 644 $(rootdir)/lib/perl/xCAT/*
chmod 644 $(rootdir)/xdsh/Context/*
+22 -26
View File
@@ -1819,6 +1819,21 @@ sub get_envlist
return ($envlist, $pkgtext);
}
sub _pkglist_line
{
my ($line, $trim_leading) = @_;
chomp($line);
$line =~ s/\s+$//;
$line =~ s/^\s*// if $trim_leading;
return if $line =~ /^\s*$/;
return
if ($line =~ /^\s*#/
&& $line !~ /^\s*#INCLUDE:[^#^\n]+#/
&& $line !~ /^\s*#NEW_INSTALL_LIST#/
&& $line !~ /^\s*#ENV:[^#^\n]+#/);
return $line;
}
#----------------------------------------------------------------------------
=head3 get_pkglist_text
@@ -1846,15 +1861,8 @@ sub get_pkglist_tex
{
while (readline(FILE1))
{
chomp($_); #remove newline
s/\s+$//; #remove trailing spaces
s/^\s*//; #remove leading blanks
next if /^\s*$/; #-- skip empty lines
next
if (/^\s*#/
&& !/^\s*#INCLUDE:[^#^\n]+#/
&& !/^\s*#NEW_INSTALL_LIST#/
&& !/^\s*#ENV:[^#^\n]+#/); #-- skip comments
$_ = _pkglist_line($_, 1);
next unless defined $_;
if (/^@(.*)/)
{ #for groups that has space in name
my $save = $1;
@@ -1925,15 +1933,8 @@ sub pkglist_file_records
open(my $fh, '<', $file) or return ("#INCLUDEBAD:cannot open pkglist file $file#");
while (my $line = <$fh>)
{
chomp($line);
$line =~ s/\s+$//;
$line =~ s/^\s*//;
next if $line eq '';
next
if ($line =~ /^#/
&& $line !~ /^#INCLUDE:[^#^\n]+#/
&& $line !~ /^#NEW_INSTALL_LIST#/
&& $line !~ /^#ENV:[^#^\n]+#/);
$line = _pkglist_line($line, 1);
next unless defined $line;
if ($line =~ /^#INCLUDE:([^#^\n]+)#(.*)$/ && $depth < 20)
{
my ($name, $note) = ($1, $2);
@@ -1974,14 +1975,9 @@ sub includefile
while (<INCLUDE>)
{
chomp($_); #remove newline
s/\s+$//; #remove trailing spaces
next if /^\s*$/; #-- skip empty lines
next
if (/^\s*#/
&& !/^\s*#INCLUDE:[^#^\n]+#/
&& !/^\s*#NEW_INSTALL_LIST#/
&& !/^\s*#ENV:[^#^\n]+#/); #-- skip comments
# Legacy includes preserve leading whitespace, unlike root package lists.
$_ = _pkglist_line($_, 0);
next unless defined $_;
if (/^@(.*)/)
{ #for groups that has space in name
my $save = $1;
+1 -11
View File
@@ -1831,17 +1831,7 @@ sub ubuntu_subiquity_apt_mirror
{
my ($osarch) = @_;
# Apt mirror for Subiquity installs. site.ubuntu_apt_mirror overrides; otherwise default to the
# public archive. The minimal live-server install media is not a complete package source, so a
# real mirror is always required -- set site.ubuntu_apt_mirror to a local full mirror for
# airgapped clusters (or to a geo/ports mirror as needed).
#
# archive.ubuntu.com publishes amd64 and i386 only. Every other architecture, ppc64el and
# riscv64 included, is on the ports archive. The osimage's architecture decides it, because
# pkgdir is whatever path the administrator configured.
my $default = (!$osarch || $osarch =~ /^(?:amd64|i386|x86|x86_64)$/)
? 'http://archive.ubuntu.com/ubuntu'
: 'http://ports.ubuntu.com/ubuntu-ports';
my $default = xCAT::Utils->ubuntu_default_mirror($osarch || 'amd64');
my $site_tab = xCAT::Table->new('site');
return $default unless $site_tab;
@@ -1,2 +0,0 @@
xcat/xcat-core/xCATsn
xcat/xcat-dep/rh10/riscv64/goconserver
@@ -0,0 +1 @@
../../netboot/rocky/service.rocky10.riscv64.otherpkgs.pkglist
@@ -1,79 +0,0 @@
# Use text install
text
# Use network installation
%include /tmp/repos
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
#KICKSTARTNET#
# Root password
rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password#
# Not run the Setup Agent on first boot
firstboot --disable
# Do not configure the X Window System
skipx
# System services
#services --enabled="chronyd"
# System timezone
timezone #TABLE:site:key=timezone:value# --utc
# Partition clearing information
zerombr
clearpart --all --initlabel
#XCAT_PARTITION_START#
%include /tmp/partitionfile
#XCAT_PARTITION_END#
# Do not configure any iptables rules
firewall --disable
selinux --disable
reboot
# riscv64: EL10 has no default crash kernel reservation for this architecture
# (kdumpctl get-default-crashkernel is empty), so the installer's kdump add-on
# would write the literal "crashkernel=auto", which the kernel ignores: nothing
# is reserved and kdump.service fails on every node. Leave kdump off here; a
# node that should take crash dumps gets a real reservation through
# linuximage.addkcmdline or bootparams.addkcmdline (crashkernel=<size>).
%addon com_redhat_kdump --disable
%end
# riscv64: the EL10 anaconda has no RISC-V EFI platform and always asks for the
# x86 UEFI boot loader packages (grub2-efi-x64, shim-x64), which do not exist
# for riscv64; tolerate that. The riscv64 package list pulls grub2-efi-riscv64
# and efibootmgr in explicitly.
%packages --ignoremissing
#INCLUDE_DEFAULT_PKGLIST#
%end
%pre
{
echo "Running Kickstart Pre-installation script..."
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.rhels10#
} &>>/tmp/pre-install.log
%end
%post --interpreter=/bin/bash
mkdir -p /var/log/xcat/
cat /tmp/pre-install.log >>/var/log/xcat/xcat.log
{
echo "Running Kickstart Post-installation script..."
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat.rhels10#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.rhels10.riscv64#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.rhels10#
} &>>/var/log/xcat/xcat.log
%end
# --ignoremissing above also hides a missing grub2-efi-riscv64, which would leave the
# node with no boot loader at all. Fail the installation instead of rebooting into
# firmware that has nothing to load.
%post --erroronfail --interpreter=/bin/bash
if [ ! -f /boot/efi/EFI/BOOT/BOOTRISCV64.EFI ] &&
! ls /boot/efi/EFI/*/grubriscv64.efi >/dev/null 2>&1; then
echo "riscv64: no grub2 UEFI boot loader on the ESP; grub2-efi-riscv64 is missing" \
>>/var/log/xcat/xcat.log
exit 1
fi
%end
@@ -0,0 +1 @@
compute.rhels10.riscv64.tmpl
@@ -1,16 +0,0 @@
@Minimal Install
kernel
chrony
net-tools
nfs-utils
openssh-server
openssl
rsync
util-linux
wget
python3
tar
bzip2
perl-interpreter
grub2-efi-riscv64
efibootmgr
@@ -0,0 +1 @@
../rh/compute.rhels10.riscv64.pkglist
@@ -1,79 +0,0 @@
# Use text install
text
# Use network installation
%include /tmp/repos
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
#KICKSTARTNET#
# Root password
rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password#
# Not run the Setup Agent on first boot
firstboot --disable
# Do not configure the X Window System
skipx
# System services
#services --enabled="chronyd"
# System timezone
timezone #TABLE:site:key=timezone:value# --utc
# Partition clearing information
zerombr
clearpart --all --initlabel
#XCAT_PARTITION_START#
%include /tmp/partitionfile
#XCAT_PARTITION_END#
# Do not configure any iptables rules
firewall --disable
selinux --disable
reboot
# riscv64: EL10 has no default crash kernel reservation for this architecture
# (kdumpctl get-default-crashkernel is empty), so the installer's kdump add-on
# would write the literal "crashkernel=auto", which the kernel ignores: nothing
# is reserved and kdump.service fails on every node. Leave kdump off here; a
# node that should take crash dumps gets a real reservation through
# linuximage.addkcmdline or bootparams.addkcmdline (crashkernel=<size>).
%addon com_redhat_kdump --disable
%end
# riscv64: the EL10 anaconda has no RISC-V EFI platform and always asks for the
# x86 UEFI boot loader packages (grub2-efi-x64, shim-x64), which do not exist
# for riscv64; tolerate that. The riscv64 package list pulls grub2-efi-riscv64
# and efibootmgr in explicitly.
%packages --ignoremissing
#INCLUDE_DEFAULT_PKGLIST#
%end
%pre
{
echo "Running Kickstart Pre-installation script..."
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.rhels10#
} &>>/tmp/pre-install.log
%end
%post --interpreter=/bin/bash
mkdir -p /var/log/xcat/
cat /tmp/pre-install.log >>/var/log/xcat/xcat.log
{
echo "Running Kickstart Post-installation script..."
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat.rhels10#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.rhels10.riscv64#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.rhels10#
} &>>/var/log/xcat/xcat.log
%end
# --ignoremissing above also hides a missing grub2-efi-riscv64, which would leave the
# node with no boot loader at all. Fail the installation instead of rebooting into
# firmware that has nothing to load.
%post --erroronfail --interpreter=/bin/bash
if [ ! -f /boot/efi/EFI/BOOT/BOOTRISCV64.EFI ] &&
! ls /boot/efi/EFI/*/grubriscv64.efi >/dev/null 2>&1; then
echo "riscv64: no grub2 UEFI boot loader on the ESP; grub2-efi-riscv64 is missing" \
>>/var/log/xcat/xcat.log
exit 1
fi
%end
@@ -0,0 +1 @@
../rh/compute.rhels10.riscv64.tmpl
@@ -1,2 +0,0 @@
xcat/xcat-core/xCATsn
xcat/xcat-dep/rh10/riscv64/goconserver
@@ -0,0 +1 @@
../../netboot/rocky/service.rocky10.riscv64.otherpkgs.pkglist
@@ -1,5 +0,0 @@
openssh-server
chrony
gawk
nfs-common
snmpd
@@ -0,0 +1 @@
compute.ubuntu20.04.pkglist
@@ -1,5 +0,0 @@
openssh-server
chrony
gawk
nfs-common
snmpd
@@ -0,0 +1 @@
compute.ubuntu20.04.pkglist
@@ -1,5 +0,0 @@
openssh-server
chrony
gawk
nfs-common
snmpd
@@ -0,0 +1 @@
compute.ubuntu20.04.pkglist
@@ -1,15 +0,0 @@
bash
nfs-common
openssl
isc-dhcp-client
libc-bin
openssh-server
openssh-client
wget
vim
rsync
busybox-static
gawk
bind9-dnsutils
chrony
gpg
@@ -0,0 +1 @@
compute.ubuntu26.04.x86_64.pkglist
@@ -1,11 +0,0 @@
openssh-server
ntp
gawk
nfs-common
snmpd
qemu-kvm
libvirt-bin
bridge-utils
libcap2-bin
vlan
tmux
@@ -0,0 +1 @@
kvm.ubuntu12.04.pkglist
@@ -1,11 +0,0 @@
openssh-server
ntp
gawk
nfs-common
snmpd
qemu-kvm
libvirt-bin
bridge-utils
libcap2-bin
vlan
tmux
@@ -0,0 +1 @@
kvm.ubuntu12.04.pkglist
@@ -1,33 +0,0 @@
./boot*
./usr/include*
./usr/lib/locale*
./usr/lib64/perl5/Encode/CN*
./usr/lib64/perl5/Encode/JP*
./usr/lib64/perl5/Encode/TW*
./usr/lib64/perl5/Encode/KR*
./lib/kbd/keymaps/i386*
./lib/kbd/keymaps/mac*
./lib/kbd/keymaps/include*
./usr/local/include*
./usr/local/share/man*
./usr/share/man*
./usr/share/cracklib*
./usr/share/doc*
./usr/share/gnome*
./usr/share/i18n*
+./usr/share/i18n/en_US*
./usr/share/info*
./usr/share/locale/*
+./usr/share/locale/en_US*
+./usr/share/locale/C*
+./usr/share/locale/locale.alias
+./usr/lib/locale/locale-archive
+./usr/lib/locale/en*
+./usr/lib/locale/C*
./usr/share/omf*
./usr/share/vim/site/doc*
./usr/share/vim/vim74/doc*
./usr/share/zoneinfo*
./var/cache/man*
./var/lib/yum*
./tmp*
@@ -0,0 +1 @@
../rocky/compute.rocky10.riscv64.exlist
@@ -1,30 +0,0 @@
@minimal-environment
initscripts
chrony
kernel
net-tools
nfs-utils
openssh-server
rsync
tar
util-linux
wget
python3
tar
bzip2
bc
dracut
dracut-network
NetworkManager
rsyslog
hostname
e2fsprogs
ethtool
parted
openssl
openssh-clients
bash
vim-minimal
rpm
iputils
perl-interpreter
@@ -0,0 +1 @@
../rocky/compute.rocky10.riscv64.pkglist
@@ -1,62 +0,0 @@
#!/bin/sh
#-- Do not remove following line if you want to make use of CVS version tracking
#-- $Id: compute.postinstall,v 1.21 2008/09/04 12:05:45 sikorsky Exp $
#-- jurij.sikorsky@t-systems.cz
#--
#-- this script is run after all packages from $profile.pkglist are installed
#--
#-- it gets these arguments:
#--
#-- $1 = install root (chroot directory for profile)
#-- $2 = OS version
#-- $3 = architecture
#-- $4 = profile name
#-- $5 = work dir (where genimage is located)
#--
#--
installroot=$1
osver=$2
arch=$3
profile=$4
workdir=$5
#-- Example how /etc/fstab can be automatically generated during image generation:
cat <<END >$installroot/etc/fstab
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
END
#-- Uncomment the line contains "cons" in /etc/inittab
#cons:12345:respawn:/sbin/smart_agetty -L 38400 console
#echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab
#-- Disable SELinux in the rootimg
#-- Redhat 7.3 will install selinux-policy and selinux is enabled by default
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
if [ -f "$installroot/etc/selinux/config" ]
then
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
fi
#--for redhat 8 and 8.1
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
then
rm -f $FIREWALLD
fi
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
then
rm -f $FIREWALLD1
fi
#-- Example of booted image versioning
#-- We want to know, with what configuration (version of the image) each node was booted.
#-- Hence, we keep image definition files and postscripts in CVS. During image generation we create file /etc/IMGVERSION and fill it with CVS "$Id$" of files with image definition (.pkglist, .exlist, .repolist, .postinstall). Then, during boot, each "CVS enabled" postscript (see /install/postscripts/cvs_template.sh and /install/postscripts/cvs_template.pl) adds one line to /etc/IMGVERSION. Then you can determine in any time what image you are running and what postscipts in which versions were run.
#cat /dev/null > $installroot/etc/IMGVERSION
#for ext in pkglist exlist postinstall repolist; do
# [ -r $workdir/$profile.$ext ] && cat $workdir/$profile.$ext | grep -E '^[[:space:]]*#.*[[:space:]]\$Id' >> $installroot/etc/IMGVERSION
#done
@@ -0,0 +1 @@
../rocky/compute.rocky10.riscv64.postinstall
@@ -1,33 +0,0 @@
./boot*
./usr/include*
./usr/lib/locale*
./usr/lib64/perl5/Encode/CN*
./usr/lib64/perl5/Encode/JP*
./usr/lib64/perl5/Encode/TW*
./usr/lib64/perl5/Encode/KR*
./lib/kbd/keymaps/i386*
./lib/kbd/keymaps/mac*
./lib/kbd/keymaps/include*
./usr/local/include*
./usr/local/share/man*
./usr/share/man*
./usr/share/cracklib*
./usr/share/doc*
./usr/share/gnome*
./usr/share/i18n*
+./usr/share/i18n/en_US*
./usr/share/info*
./usr/share/locale/*
+./usr/share/locale/en_US*
+./usr/share/locale/C*
+./usr/share/locale/locale.alias
+./usr/lib/locale/locale-archive
+./usr/lib/locale/en*
+./usr/lib/locale/C*
./usr/share/omf*
./usr/share/vim/site/doc*
./usr/share/vim/vim74/doc*
./usr/share/zoneinfo*
./var/cache/man*
./var/lib/yum*
./tmp*
@@ -0,0 +1 @@
../rocky/compute.rocky10.riscv64.exlist
@@ -1,2 +0,0 @@
xcat/xcat-core/xCATsn
xcat/xcat-dep/rh10/riscv64/goconserver
@@ -0,0 +1 @@
../rocky/service.rocky10.riscv64.otherpkgs.pkglist
@@ -1,30 +0,0 @@
@minimal-environment
chrony
kernel
net-tools
nfs-utils
openssh-server
rsync
tar
util-linux
wget
perl-DBD-MySQL
perl-DBD-Pg
perl-lib
python3
tar
bzip2
bc
dracut
dracut-network
rsyslog
hostname
e2fsprogs
ethtool
parted
openssl
openssh-clients
bash
vim-minimal
rpm
iputils
@@ -0,0 +1 @@
../rocky/service.rocky10.riscv64.pkglist
@@ -1,62 +0,0 @@
#!/bin/sh
#-- Do not remove following line if you want to make use of CVS version tracking
#-- $Id: compute.postinstall,v 1.21 2008/09/04 12:05:45 sikorsky Exp $
#-- jurij.sikorsky@t-systems.cz
#--
#-- this script is run after all packages from $profile.pkglist are installed
#--
#-- it gets these arguments:
#--
#-- $1 = install root (chroot directory for profile)
#-- $2 = OS version
#-- $3 = architecture
#-- $4 = profile name
#-- $5 = work dir (where genimage is located)
#--
#--
installroot=$1
osver=$2
arch=$3
profile=$4
workdir=$5
#-- Example how /etc/fstab can be automatically generated during image generation:
cat <<END >$installroot/etc/fstab
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
END
#-- Uncomment the line contains "cons" in /etc/inittab
#cons:12345:respawn:/sbin/smart_agetty -L 38400 console
#echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab
#-- Disable SELinux in the rootimg
#-- Redhat 7.3 will install selinux-policy and selinux is enabled by default
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
if [ -f "$installroot/etc/selinux/config" ]
then
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
fi
#--for redhat 8 and 8.1
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
then
rm -f $FIREWALLD
fi
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
then
rm -f $FIREWALLD1
fi
#-- Example of booted image versioning
#-- We want to know, with what configuration (version of the image) each node was booted.
#-- Hence, we keep image definition files and postscripts in CVS. During image generation we create file /etc/IMGVERSION and fill it with CVS "$Id$" of files with image definition (.pkglist, .exlist, .repolist, .postinstall). Then, during boot, each "CVS enabled" postscript (see /install/postscripts/cvs_template.sh and /install/postscripts/cvs_template.pl) adds one line to /etc/IMGVERSION. Then you can determine in any time what image you are running and what postscipts in which versions were run.
#cat /dev/null > $installroot/etc/IMGVERSION
#for ext in pkglist exlist postinstall repolist; do
# [ -r $workdir/$profile.$ext ] && cat $workdir/$profile.$ext | grep -E '^[[:space:]]*#.*[[:space:]]\$Id' >> $installroot/etc/IMGVERSION
#done
@@ -0,0 +1 @@
../rocky/compute.rocky10.riscv64.postinstall
@@ -1,33 +0,0 @@
./boot*
./usr/include*
./usr/lib/locale*
./usr/lib64/perl5/Encode/CN*
./usr/lib64/perl5/Encode/JP*
./usr/lib64/perl5/Encode/TW*
./usr/lib64/perl5/Encode/KR*
./lib/kbd/keymaps/i386*
./lib/kbd/keymaps/mac*
./lib/kbd/keymaps/include*
./usr/local/include*
./usr/local/share/man*
./usr/share/man*
./usr/share/cracklib*
./usr/share/doc*
./usr/share/gnome*
./usr/share/i18n*
+./usr/share/i18n/en_US*
./usr/share/info*
./usr/share/locale/*
+./usr/share/locale/en_US*
+./usr/share/locale/C*
+./usr/share/locale/locale.alias
+./usr/lib/locale/locale-archive
+./usr/lib/locale/en*
+./usr/lib/locale/C*
./usr/share/omf*
./usr/share/vim/site/doc*
./usr/share/vim/vim74/doc*
./usr/share/zoneinfo*
./var/cache/man*
./var/lib/yum*
./tmp*
@@ -0,0 +1 @@
compute.rocky10.riscv64.exlist
@@ -1,62 +0,0 @@
#!/bin/sh
#-- Do not remove following line if you want to make use of CVS version tracking
#-- $Id: compute.postinstall,v 1.21 2008/09/04 12:05:45 sikorsky Exp $
#-- jurij.sikorsky@t-systems.cz
#--
#-- this script is run after all packages from $profile.pkglist are installed
#--
#-- it gets these arguments:
#--
#-- $1 = install root (chroot directory for profile)
#-- $2 = OS version
#-- $3 = architecture
#-- $4 = profile name
#-- $5 = work dir (where genimage is located)
#--
#--
installroot=$1
osver=$2
arch=$3
profile=$4
workdir=$5
#-- Example how /etc/fstab can be automatically generated during image generation:
cat <<END >$installroot/etc/fstab
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
END
#-- Uncomment the line contains "cons" in /etc/inittab
#cons:12345:respawn:/sbin/smart_agetty -L 38400 console
#echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab
#-- Disable SELinux in the rootimg
#-- Redhat 7.3 will install selinux-policy and selinux is enabled by default
#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy"
if [ -f "$installroot/etc/selinux/config" ]
then
sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config
fi
#--for redhat 8 and 8.1
#-- Need to disable firewalld, otherwise, the remoteshell script will not able to get all the SSH keys
FIREWALLD="$installroot/etc/systemd/system/multi-user.target.wants/firewalld.service"
if [[ -f "$FIREWALLD" || -L "$FIREWALLD" ]]
then
rm -f $FIREWALLD
fi
FIREWALLD1="$installroot/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service"
if [[ -f "$FIREWALLD1" || -L "$FIREWALLD1" ]]
then
rm -f $FIREWALLD1
fi
#-- Example of booted image versioning
#-- We want to know, with what configuration (version of the image) each node was booted.
#-- Hence, we keep image definition files and postscripts in CVS. During image generation we create file /etc/IMGVERSION and fill it with CVS "$Id$" of files with image definition (.pkglist, .exlist, .repolist, .postinstall). Then, during boot, each "CVS enabled" postscript (see /install/postscripts/cvs_template.sh and /install/postscripts/cvs_template.pl) adds one line to /etc/IMGVERSION. Then you can determine in any time what image you are running and what postscipts in which versions were run.
#cat /dev/null > $installroot/etc/IMGVERSION
#for ext in pkglist exlist postinstall repolist; do
# [ -r $workdir/$profile.$ext ] && cat $workdir/$profile.$ext | grep -E '^[[:space:]]*#.*[[:space:]]\$Id' >> $installroot/etc/IMGVERSION
#done
@@ -0,0 +1 @@
compute.rocky10.riscv64.postinstall
@@ -1,22 +0,0 @@
bash
nfs-common
openssl
isc-dhcp-client
libc-bin
linux-image-generic
openssh-server
openssh-client
wget
rsync
busybox-static
gawk
bind9-dnsutils
tar
gzip
xz-utils
cpio
chrony
util-linux-extra
iproute2
dracut
dracut-network
@@ -0,0 +1 @@
compute.ubuntu24.04.x86_64.pkglist
@@ -1,18 +0,0 @@
bash
nfs-common
openssl
isc-dhcp-client
libc-bin
linux-image-generic
openssh-server
openssh-client
wget
rsync
busybox-static
gawk
bind9-dnsutils
tar
gzip
xz-utils
cpio
chrony
@@ -0,0 +1 @@
compute.ubuntu26.04.x86_64.pkglist
@@ -259,11 +259,7 @@ unless ($onlyinitrd) {
# site.ubuntu_apt_mirror overrides; otherwise default to the public archive. A live-server
# ISO is never a complete debootstrap source, so a real mirror is always required here.
my @aptmirror = xCAT::TableUtils->get_site_attribute("ubuntu_apt_mirror");
# archive.ubuntu.com publishes amd64 and i386 only. Every other architecture, ppc64el
# and riscv64 included, is on the ports archive.
my $default = ($uarch =~ /^(?:amd64|i386)$/)
? 'http://archive.ubuntu.com/ubuntu'
: 'http://ports.ubuntu.com/ubuntu-ports';
my $default = xCAT::Utils->ubuntu_default_mirror($uarch);
my $mirror = (defined $aptmirror[0] && length $aptmirror[0])
? $aptmirror[0] : $default;
(my $codename = $osver) =~ s/^ubuntu//;
+4 -3
View File
@@ -27,10 +27,11 @@ sub checked {
}
sub build_deb {
my ($package) = @_;
my ($package, $source) = @_;
$source //= repo_path('.');
my $work = tempdir(CLEANUP => 1);
checked('tar', '-cf', "$work/source.tar", '-C', repo_path('.'), $package);
checked('tar', '-xf', "$work/source.tar", '-C', $work);
checked('tar', '-cf', "$work/source.tar", '-C', $source, $package);
checked('tar', '-xpf', "$work/source.tar", '-C', $work);
my $previous = getcwd();
chdir "$work/$package" or die "chdir: $!";
local $ENV{PWD} = getcwd();
+21 -6
View File
@@ -262,6 +262,9 @@ permissions and an init process that reaps orphaned children.
evaluate machine and package policy, install local-file recipes into temporary
directories, generate extension manifests and reject invalid extension
metadata. It does not extract or evaluate recipe source fragments.
The NetworkManager case supplies an installed-unit fixture and runs the
recipe's install append to check the wait-online policy. It does not verify
the unit format produced by an upstream NetworkManager build.
The POWER patch case keeps BitBake's machine prepends and replaces only the
upstream kernel task body with a no-op. It applies the real patch to a small
metadata fixture, checks repeat runs and verifies that patch errors propagate.
@@ -292,15 +295,27 @@ Meson, Ninja, pkg-config, and development packages for Newt and systemd.
dependencies plus the `pyte` Python package, bubblewrap,
systemd-journal-remote and journalctl. It runs the linked console in a
pseudo-terminal and checks help and diagnostics navigation, scrolling,
return to the main screen, and F3 journal filtering, order and history limits.
live status updates, diagnostic snapshots, and return to the main screen.
The F3 cases check journal filtering, order, history limits, follow mode,
paused selection, navigation and reopening. Rollover cases check expired
entries, duplicate messages and wrapped lines. The F12 cases check cancellation,
confirmation, terminal input, successful and nonzero exits, repeated launches
and executable errors.
It checks termination from the main screen, not from inside a dialog.
The journal cases need working Linux user and mount namespaces. On Ubuntu
24.04, the CI job enables them with
The journal and shell cases need working Linux user and mount namespaces.
On Ubuntu 24.04, the CI job enables them with
`sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0`.
They import private journal files and verify their contents with journalctl
before opening F3. They do not start a journal service or read the host
journal. Missing tools or namespace support fail the tests; they do not skip.
The journal cases import private journal files, including appends while F3
is open, and verify each import with journalctl. They do not start a journal
service or read the host journal. Missing tools or namespace support fail
the tests; they do not skip.
The shell cases mount a fixture directory over `/usr/libexec` in a private
namespace to replace the external shell launcher. The real console handles
confirmation, child execution, waiting and terminal restoration.
The per-test temporary root is the only writable host-backed directory.
The libexec mount is read-only. Other writable mounts are private.
The real maintenance shell is not run.
The Genesis runtime BATS cases need Bash, Perl, OpenSSL, coreutils, diffutils
and bubblewrap. The credential-file cases use a private `/etc` in a Linux
+382 -21
View File
@@ -7,6 +7,7 @@ import os
from pathlib import Path
import pty
import select
import shlex
import signal
import struct
import subprocess
@@ -38,7 +39,9 @@ class ConsoleTerminal(unittest.TestCase):
self.addCleanup(temporary.cleanup)
root = Path(temporary.name)
self.root = root
environment = {"PATH": os.environ["PATH"], "LC_ALL": "C.UTF-8", "TERM": "xterm"}
environment = {"PATH": os.environ["PATH"], "LC_ALL": "C.UTF-8", "TERM": "xterm",
"NEWT_COLORS": "listbox=black,white\nactlistbox=black,white\n"
"sellistbox=white,red\nactsellistbox=white,red"}
for name in ("CMDLINE_FILE", "UPTIME_FILE", "OS_RELEASE", "STATUS_DIR", "STATE_FILE",
"DESTINY_FILE", "RESPONSE_FILE", "SYS_ROOT", "PROC_ROOT", "EXTENSION_DIR", "PROVIDER_DIR"):
environment["XCAT_" + name] = str(root / name.lower())
@@ -59,6 +62,16 @@ class ConsoleTerminal(unittest.TestCase):
def console_command(self):
return [str(self.binary)]
def isolated_prefix(self, mounts):
command = ["bwrap", "--unshare-all", "--die-with-parent", "--ro-bind", "/", "/",
"--dev", "/dev", "--proc", "/proc", "--tmpfs", "/run", "--tmpfs", "/var/log",
*mounts]
result = subprocess.run(command + ["/bin/true"], text=True,
capture_output=True, timeout=10)
self.assertEqual(result.returncode, 0,
"Console tests require working Bubblewrap namespaces: " + result.stderr)
return command
def stop(self):
if self.process.poll() is None:
self.process.terminate()
@@ -75,17 +88,31 @@ class ConsoleTerminal(unittest.TestCase):
return "\n".join(self.screen.display)
def wait_text(self, text):
return self.wait_screen(lambda display: text in display, repr(text))
def wait_screen(self, predicate, description):
deadline = time.monotonic() + 5
while time.monotonic() < deadline:
display = self.read_screen(0.1)
if text in display:
if predicate(display):
return display
self.assertIsNone(self.process.poll(), display)
self.fail(f"Terminal did not show {text!r}:\n{display}")
self.fail(f"Terminal did not show {description}:\n{display}")
def assert_screen_stays(self, predicate, description, duration):
deadline = time.monotonic() + duration
while time.monotonic() < deadline:
display = self.read_screen(0.1)
self.assertTrue(predicate(display), f"{description}:\n{display}")
self.assertIsNone(self.process.poll(), display)
def key(self, sequence):
os.write(self.master, sequence)
def visible_text(self, display):
return " ".join("".join(character if character.isascii() else " "
for character in display).split())
class ConsoleDialogs(ConsoleTerminal):
def test_help_and_diagnostics_scroll_close_and_reopen(self):
@@ -103,21 +130,70 @@ class ConsoleDialogs(ConsoleTerminal):
self.wait_text(first)
self.wait_text(help_line)
self.key(other_key)
self.assertIn(title, self.read_screen(0.2))
self.key(b"\x1b[6~" * 20)
self.wait_text(last)
self.assertIn(title, self.wait_text(last))
self.key(close_key)
self.wait_text("Genesis status")
self.wait_text("F1 Help")
self.process.send_signal(signal.SIGTERM)
self.assertEqual(self.process.wait(timeout=5), 0)
def publish(self, name, text):
target = self.root / name
target.parent.mkdir(parents=True, exist_ok=True)
temporary = target.with_suffix(".tmp")
temporary.write_text(text)
temporary.replace(target)
def test_status_refresh_and_diagnostic_snapshot(self):
self.publish("response_file", "XCAT_NODE_NAME=updated-node\n")
self.assertRegex(self.wait_text("updated-node"), r"Node +updated-node")
self.publish("status_dir/action.env", "SCHEMA=1\nSTATE=RUNNING\n"
"DETAIL=Preparing test action\nUPDATED_SECONDS=100\n")
self.assertIn("RUNNING", self.wait_text("Preparing test action"))
self.key(b"\x1bOQ")
self.wait_text("Node: updated-node")
self.publish("response_file", "XCAT_NODE_NAME=short-node\n")
self.publish("status_dir/action.env", "SCHEMA=1\nSTATE=FAILED\n"
"DETAIL=Test action failed\nRECOVERY=Check test input\nUPDATED_SECONDS=101\n")
self.key(b"\x1b[6~" * 20)
self.wait_text("Provider names:")
self.key(b"\x1b[5~" * 20)
display = self.wait_text("Node: updated-node")
self.assertNotIn("short-node", display)
self.assert_screen_stays(lambda display: "Node: updated-node" in display
and "short-node" not in display,
"Diagnostics changed before reopening", 2)
self.key(b"\x1bOQ")
display = self.wait_text("Check test input")
self.assertRegex(display, r"Node +short-node +")
self.assertIn("FAILED", display)
self.assertIn("Test action failed", display)
self.assertNotIn("updated-node", display)
self.key(b"\x1bOQ")
self.wait_text("Node: short-node")
def test_rendered_help_explains_read_only_pages_logs_and_shell(self):
self.key(b"\x1bOP")
display = self.wait_text("Screen fields")
text = self.visible_text(display)
self.assertIn("Status pages are read-only.", text)
self.assertIn("confirmed root maintenance shell", text)
self.key(b"\x1b[6~" * 20)
display = self.wait_text("Up and Down scroll this page.")
text = self.visible_text(display)
self.assertIn("F3 opens recent Genesis logs", text)
self.assertIn("press End to resume.", text)
self.assertIn("F12 asks before opening", text)
self.assertIn("Exit returns here.", text)
class ConsoleJournal(ConsoleTerminal):
"""Read real journal files in a private machine and journal namespace.
Requires bubblewrap, systemd-journal-remote, journalctl and user namespaces.
The host filesystem is read-only; /run and /var/log are private mounts.
The host filesystem is read-only except for the fixture directory.
/run and /var/log are private tmpfs mounts with the journal bound read-only.
No journal service is started and no host journal is read or changed.
"""
@@ -128,46 +204,223 @@ class ConsoleJournal(ConsoleTerminal):
journal_directory = journal_root / self.machine_id
journal_directory.mkdir(parents=True)
self.journal = journal_directory / "system.journal"
self.entries = []
machine_id_file = self.root / "machine-id"
machine_id_file.write_text(self.machine_id + "\n")
sandbox = [
"bwrap", "--unshare-all", "--die-with-parent", "--ro-bind", "/", "/",
"--dev", "/dev", "--proc", "/proc", "--tmpfs", "/run", "--tmpfs", "/var/log",
self.sandbox = self.isolated_prefix([
"--bind", str(self.root), str(self.root),
"--ro-bind", str(machine_id_file), "/etc/machine-id",
"--ro-bind", str(journal_root), "/var/log/journal",
]
result = subprocess.run(sandbox + ["/bin/true"], text=True,
capture_output=True, timeout=10)
self.assertEqual(result.returncode, 0,
"Journal tests require working Bubblewrap namespaces: " + result.stderr)
return sandbox + [str(self.binary)]
])
return self.sandbox + [str(self.binary)]
def write_journal(self, entries):
def write_journal(self, entries, interval=1000000):
records = []
for sequence, (message, unit, identifier) in enumerate(entries, 1):
for sequence, (message, unit, identifier) in enumerate(entries, len(self.entries) + 1):
records.append(
f"__REALTIME_TIMESTAMP={1700000000000000 + sequence * 1000000}\n"
f"__MONOTONIC_TIMESTAMP={sequence * 1000000}\n"
f"__REALTIME_TIMESTAMP={1700000000000000 + sequence * interval}\n"
f"__MONOTONIC_TIMESTAMP={sequence * interval}\n"
f"_MACHINE_ID={self.machine_id}\n_BOOT_ID={self.boot_id}\n"
f"_SYSTEMD_UNIT={unit}\nSYSLOG_IDENTIFIER={identifier}\n"
f"MESSAGE={message}\n\n")
result = subprocess.run(
["/usr/lib/systemd/systemd-journal-remote", "--split-mode=none",
self.sandbox + ["/usr/lib/systemd/systemd-journal-remote", "--split-mode=none",
"--output=" + str(self.journal), "-"],
input="".join(records), text=True, capture_output=True, timeout=10)
self.assertEqual(result.returncode, 0, result.stderr)
self.entries.extend(entries)
exported = subprocess.check_output(
["journalctl", "--file=" + str(self.journal), "--output=json", "--no-pager"],
text=True, timeout=10)
actual = [json.loads(line) for line in exported.splitlines()]
self.assertEqual([(entry["MESSAGE"], entry["_SYSTEMD_UNIT"], entry["SYSLOG_IDENTIFIER"])
for entry in actual], entries)
for entry in actual], self.entries)
def open_logs(self):
self.key(b"\x1bOR")
self.wait_text("Genesis logs")
self.wait_text("F3 Back")
def selected_rows(self):
return ["".join(self.screen.buffer[row][column].data
for column in range(self.screen.columns)
if self.screen.buffer[row][column].bg == "red").strip()
for row in range(self.screen.lines)]
def selected_text(self):
return "\n".join(self.selected_rows()).strip()
def wait_selected(self, text):
return self.wait_screen(lambda display: self.selected_text().endswith(text),
f"selected log entry {text!r}")
def assert_selection_stays(self, text):
self.assert_screen_stays(lambda display: self.selected_text() == text,
"Selected journal entry changed", 3)
def test_paused_entry_survives_history_rollover(self):
self.write_journal([(f"RECORD-{number:04d}", "other.service", "xcat-genesis-register")
for number in range(1, 130)])
self.open_logs()
self.wait_selected("RECORD-0129")
self.key(b"\x1b[H")
self.wait_selected("RECORD-0002")
self.key(b"\x1b[B" * 60)
self.wait_selected("RECORD-0062")
selected = self.selected_text()
for number in (130, 131):
self.write_journal([(f"RECORD-{number:04d}", "other.service", "xcat-genesis-register")])
self.assert_selection_stays(selected)
self.key(b"\x1b[F")
self.wait_selected("RECORD-0131")
self.write_journal([("FOLLOWED", "other.service", "xcat-genesis-register")])
self.wait_selected("FOLLOWED")
def test_expired_selection_stays_paused_at_oldest_entry(self):
self.write_journal([(f"RECORD-{number:04d}", "other.service", "xcat-genesis-register")
for number in range(1, 130)])
self.open_logs()
self.wait_selected("RECORD-0129")
self.key(b"\x1b[H")
self.wait_selected("RECORD-0002")
for first, last, oldest in ((130, 140, 12), (140, 270, 142)):
self.write_journal([(f"RECORD-{number:04d}", "other.service", "xcat-genesis-register")
for number in range(first, last)])
self.wait_selected(f"RECORD-{oldest:04d}")
self.assert_selection_stays(self.selected_text())
if first == 130:
self.key(b"\x1b[B" * 50)
self.wait_selected("RECORD-0062")
self.write_journal([("STILL-PAUSED", "other.service", "xcat-genesis-register")])
self.wait_selected("RECORD-0143")
self.key(b"\x1b[F")
self.wait_selected("STILL-PAUSED")
def test_duplicate_text_keeps_the_selected_record(self):
self.write_journal([("DUPLICATE" if number in (60, 62, 63) else f"RECORD-{number:04d}",
"other.service", "xcat-genesis-register")
for number in range(1, 130)], interval=1)
self.open_logs()
self.wait_selected("RECORD-0129")
self.key(b"\x1b[H")
self.wait_selected("RECORD-0002")
self.key(b"\x1b[B" * 58)
self.wait_selected("DUPLICATE")
duplicate = self.selected_text()
self.key(b"\x1b[B")
self.wait_selected("RECORD-0061")
self.key(b"\x1b[B")
self.wait_selected("DUPLICATE")
self.assertEqual(self.selected_text(), duplicate)
self.write_journal([("APPENDED", "other.service", "xcat-genesis-register")], interval=1)
self.assert_selection_stays(duplicate)
self.key(b"\x1b[A")
self.wait_selected("RECORD-0061")
self.key(b"\x1b[H")
self.wait_selected("RECORD-0003")
def test_wrapped_selection_survives_history_rollover(self):
self.write_journal([
(" ".join(f"OLD-{number:02d}" for number in range(20)),
"other.service", "xcat-genesis-register"),
(" ".join(f"CONTEXT-{number:02d}" for number in range(16)) + " SELECTED-TAIL",
"other.service", "xcat-genesis-register"),
] + [(f"RECORD-{number:04d}", "other.service", "xcat-genesis-register")
for number in range(3, 129)])
self.open_logs()
self.wait_selected("RECORD-0128")
self.key(b"\x1b[H")
self.wait_screen(lambda display: "OLD-00" in self.selected_text(), "oldest wrapped entry")
for _ in range(12):
if self.selected_text().endswith("CONTEXT-08"):
break
previous = self.selected_text()
self.key(b"\x1b[B")
self.wait_screen(lambda display: self.selected_text() != previous, "next wrapped row")
self.assertTrue(self.selected_text().endswith("CONTEXT-08"), self.selected_text())
selected = self.selected_text()
self.assertIn("OLD-00", self.read_screen(0))
self.write_journal([("APPENDED", "other.service", "xcat-genesis-register")])
self.wait_screen(lambda display: "OLD-00" not in display, "expired wrapped entry removed")
self.assert_selection_stays(selected)
self.key(b"\x1b[B")
self.wait_selected("CONTEXT-14")
self.key(b"\x1b[B")
self.wait_selected("SELECTED-TAIL")
self.key(b"\x1b[B")
self.wait_selected("RECORD-0003")
def visible_entries(self):
return [message for message, unit, identifier in self.entries
if any(message in line for line in self.screen.display)]
def assert_paused(self, text):
before = self.selected_rows()
self.assertIn(text, self.selected_text())
self.assert_screen_stays(lambda display: self.selected_rows() == before,
"Paused journal selection moved", 5)
def test_logs_follow_pause_and_reopen(self):
self.write_journal([
("FIRST", "xcat-genesis-register.service", "unit-fixture"),
("TAIL", "other.service", "xcat-genesis-discovery"),
])
self.open_logs()
self.wait_selected("TAIL")
self.write_journal([("FOLLOWED", "other.service", "xcat-genesis-register")])
self.wait_selected("FOLLOWED")
self.key(b"\x1b[H")
self.wait_selected("FIRST")
self.write_journal([("PAUSED", "other.service", "xcat-genesis-register")])
self.wait_text("PAUSED")
self.assert_paused("FIRST")
self.key(b"\x1b[F")
self.wait_selected("PAUSED")
self.write_journal([("END-FOLLOWED", "other.service", "xcat-genesis-register")])
self.wait_selected("END-FOLLOWED")
for index, close_key in enumerate((b"\x1bOR", b"\x1b")):
with self.subTest(close_key=close_key):
self.key(b"\x1b[H")
self.wait_selected("FIRST")
self.key(close_key)
self.wait_text("Genesis status")
self.open_logs()
self.wait_selected("END-FOLLOWED" if index == 0 else "REOPENED-0")
message = f"REOPENED-{index}"
self.write_journal([(message, "other.service", "xcat-genesis-register")])
self.wait_selected(message)
def test_logs_arrow_and_page_keys_pause_and_resume(self):
self.write_journal([(f"HISTORY-{number:03d}", "other.service", "xcat-genesis-register")
for number in range(40)])
self.open_logs()
self.wait_selected("HISTORY-039")
for up, down in ((b"\x1b[A", b"\x1b[B"), (b"\x1b[5~", b"\x1b[6~")):
with self.subTest(up=up):
previous_tail = f"HISTORY-{len(self.entries) - 1:03d}"
if up == b"\x1b[A":
paused = f"HISTORY-{len(self.entries) - 2:03d}"
else:
visible = self.visible_entries()
self.assertGreater(len(visible), 2)
paused = visible[0]
self.key(up)
self.wait_selected(paused)
message = f"HISTORY-{len(self.entries):03d}"
self.write_journal([(message, "other.service", "xcat-genesis-register")])
self.assert_paused(paused)
self.key(down)
self.wait_selected(previous_tail)
message = f"HISTORY-{len(self.entries):03d}"
self.write_journal([(message, "other.service", "xcat-genesis-register")])
self.assert_paused(previous_tail)
self.key(down)
self.key(down)
self.wait_selected(message)
following = f"HISTORY-{len(self.entries):03d}"
self.write_journal([(following, "other.service", "xcat-genesis-register")])
self.wait_selected(following)
def test_empty_journal(self):
self.open_logs()
self.wait_text("No Genesis journal entries are available.")
@@ -225,5 +478,113 @@ class ConsoleJournal(ConsoleTerminal):
self.wait_text("RECORD-0129")
class ConsoleShell(ConsoleTerminal):
"""Mount a fixture libexec directory containing the external shell launcher.
The linked console still owns confirmation, fork/exec, waiting and redraw.
The per-test temporary root is the only writable host-backed directory.
The libexec mount is read-only.
/run and /var/log are private tmpfs mounts.
"""
def console_command(self):
directory = self.root / "libexec"
(directory / "xcat").mkdir(parents=True)
self.launcher = directory / "xcat/genesis-maintenance-shell"
self.calls = self.root / "shell-calls"
self.input = self.root / "shell-input"
self.write_launcher(0)
return self.isolated_prefix([
"--bind", str(self.root), str(self.root),
"--ro-bind", str(directory), "/usr/libexec",
]) + [str(self.binary)]
def write_launcher(self, exit_status):
self.launcher.write_text(
"#!/bin/sh\n"
f"printf '%s\\n' started >> {shlex.quote(str(self.calls))}\n"
"printf 'SHELL-RUNNING\\n'\n"
"IFS= read -r answer\n"
f"printf '%s\\n' \"$answer\" > {shlex.quote(str(self.input))}\n"
f"exit {exit_status}\n")
self.launcher.chmod(0o755)
def shell_dialog_text(self, display):
lines = display.splitlines()
for row, line in enumerate(lines):
if "Maintenance shell" not in line:
continue
left, right = line.rfind("┌"), line.find("┐")
if left < 0 or right <= left:
continue
content = []
for line in lines[row + 1:]:
if line[left:right + 1].startswith("└") and line[right] == "┘":
return self.visible_text("\n".join(content))
content.append(line[left + 1:right])
return ""
def confirm_shell(self):
self.key(b"\x1b[24~")
display = self.wait_screen(
lambda text: "Open a root maintenance shell?" in self.shell_dialog_text(text),
"maintenance shell confirmation")
self.assertIn("Provisioning services continue in the background.",
self.shell_dialog_text(display))
def wait_main(self):
def is_main(display):
return ("Maintenance shell" not in display
and "SHELL-RUNNING" not in display
and "Genesis diagnostics" not in display
and "Genesis status" in display)
self.wait_screen(is_main, "the restored status console")
self.assert_screen_stays(is_main, "The restored status console changed", 1)
def test_cancel_does_not_launch_shell(self):
self.confirm_shell()
self.assertFalse(self.calls.exists())
self.key(b"\t\r")
self.wait_main()
self.assertFalse(self.calls.exists())
self.key(b"\x1bOP")
self.wait_text("Genesis help")
def test_confirmed_shell_accepts_input_and_returns_to_console(self):
for count, exit_status in enumerate((0, 7), 1):
with self.subTest(launch=count, exit_status=exit_status):
self.write_launcher(exit_status)
self.confirm_shell()
self.assertEqual(self.calls.read_text() if self.calls.exists() else "",
"started\n" * (count - 1))
self.key(b"\r")
self.wait_text("SHELL-RUNNING")
self.assertEqual(self.calls.read_text(), "started\n" * count)
self.key(f"operator-input-{count}\r".encode())
self.wait_main()
self.assertEqual(self.input.read_text(), f"operator-input-{count}\n")
self.assertIsNone(self.process.poll())
self.key(b"\x1bOQ")
self.wait_text("Genesis diagnostics")
self.key(b"\x1bOQ")
self.wait_main()
def test_shell_exec_error_is_reported_and_console_recovers(self):
self.launcher.unlink()
self.confirm_shell()
self.key(b"\r")
display = self.wait_screen(
lambda text: "No such file or directory" in self.shell_dialog_text(text),
"the maintenance shell executable error")
self.assertIn("The maintenance shell could not be opened: No such file or directory",
self.shell_dialog_text(display))
self.assertFalse(self.calls.exists())
self.key(b"\r")
self.wait_main()
self.key(b"\x1bOP")
self.wait_text("Genesis help")
if __name__ == "__main__":
unittest.main(verbosity=2)
+52
View File
@@ -308,6 +308,58 @@ class GenesisMetadata(unittest.TestCase):
with self.assertRaises(bb.process.ExecutionError):
bb.build.exec_func("do_kernel_metadata", data, dirs=[data.getVar("WORKDIR")])
def test_networkmanager_does_not_enable_wait_online(self):
def entries(file):
result = []
section = None
for line in file.read_text().splitlines():
line = line.strip()
if not line or line.startswith(("#", ";")):
continue
if line.startswith("[") and line.endswith("]"):
section = line[1:-1]
else:
self.assertIsNotNone(section)
key, value = line.split("=", 1)
result.append((section, key.strip(), value.strip()))
return result
data = self.task_data("networkmanager")
# Preserve the recipe appends while replacing the external Meson installation.
data.setVar("do_install", 'cp -a "${WORKDIR}/meson-install/." "${D}/"\n', parsing=True)
root = Path(data.getVar("D"))
fixture = Path(data.getVar("WORKDIR")) / "meson-install"
sources = Path(data.getVar("UNPACKDIR"))
(sources / "networkmanager.initd").write_text("#!/bin/sh\nexit 0\n")
units = fixture / data.getVar("systemd_system_unitdir").lstrip("/")
units.mkdir(parents=True)
unit = units / "NetworkManager.service"
installed_unit = root / unit.relative_to(fixture)
rule = fixture / data.getVar("nonarch_base_libdir").lstrip("/") / "udev/rules.d/84-nm-drivers.rules"
rule.parent.mkdir(parents=True)
rule.touch()
expected = ("[Unit]\nDescription=NetworkManager fixture\n"
"[Service]\nExecStart=/usr/sbin/NetworkManager --no-daemon\n"
"[Install]\nWantedBy=multi-user.target\n"
"Alias=dbus-org.freedesktop.NetworkManager.service\n"
"Also=fixture-auxiliary.service\nAlso=fixture-second.service\n")
unit.write_text(expected)
expected_entries = entries(unit)
directive = "Also=NetworkManager-wait-online.service\n"
fixtures = {
"absent": expected,
"first": expected.replace("[Install]\n", "[Install]\n" + directive),
"last": expected + directive,
"repeated": expected + directive * 2,
}
for name, fixture_text in fixtures.items():
with self.subTest(directive=name):
unit.write_text(fixture_text)
for unused in range(2):
bb.build.exec_func("do_install", data, dirs=[data.getVar("WORKDIR")])
self.assertEqual(entries(installed_unit), expected_entries)
unit.write_bytes(installed_unit.read_bytes())
def test_installed_network(self):
data, root = self.install("xcat-genesis-network")
file = self.installed(data, root, "sysconfdir", "NetworkManager/conf.d/10-xcat-genesis.conf", 0o644)
@@ -0,0 +1,91 @@
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use File::Basename qw(dirname);
use File::Temp qw(tempdir);
use File::Slurper qw(read_binary);
use Fcntl qw(S_IMODE);
use Test::More;
use XCAT::Test::File qw(repo_path);
use XCAT::Test::Lifecycle;
use XCAT::Test::RPM;
use XCAT::Test::Process qw(run_command);
plan skip_all => 'requires Linux package tools' unless $^O eq 'linux';
die 'run package builds as an unprivileged user' unless $>;
my $root = tempdir(CLEANUP => 1);
if (-f '/etc/debian_version') {
my $deb = XCAT::Test::Lifecycle::build_deb('xCAT-server');
XCAT::Test::Lifecycle::checked('dpkg-deb', '-x', $deb, $root);
} else {
my $rpm = XCAT::Test::RPM->build('xCAT-server', 1);
XCAT::Test::Lifecycle::checked('bash', '-o', 'pipefail', '-c',
'cd "$1" && rpm2cpio "$2" | cpio -idm --quiet', 'bash', $root, $rpm);
}
my $share = repo_path('xCAT-server/share/xcat');
my @assets = grep { /riscv64\./ }
glob "$share/{install,netboot}/{rh,rocky}/*";
ok(@assets, 'finds the RISC-V profile assets');
my @ubuntu = glob "$share/{install,netboot}/ubuntu/*.pkglist";
ok(@ubuntu, 'finds the Ubuntu package lists');
push @assets, @ubuntu;
sub check_assets {
my ($payload, $label, @sources) = @_;
for my $source (@sources) {
my $relative = substr($source, length($share) + 1);
my $delivered = "$payload/opt/xcat/share/xcat/$relative";
ok(-r $delivered, "$label$relative is readable after extraction") or next;
is(read_binary($delivered), read_binary($source), "$label$relative retains its complete contents");
is(sprintf('%04o', S_IMODE((stat($delivered))[2])), $source =~ /\.postinstall$/ ? '0755' : '0644',
"$label$relative has the packaged permissions");
}
}
check_assets($root, '', @assets);
my ($status, $output) = run_command($^X,
repo_path('xCAT-test/unit/profile_customization.t'), "$root/opt/xcat");
is($status, 0, 'packaged profiles resolve and remain independently customizable') or diag($output);
if (!-f '/etc/debian_version') {
local $ENV{fsm} = 1;
my $reduced = tempdir(CLEANUP => 1);
my $rpm = XCAT::Test::RPM->build('xCAT-server', 1);
XCAT::Test::Lifecycle::checked('bash', '-o', 'pipefail', '-c',
'cd "$1" && rpm2cpio "$2" | cpio -idm --quiet', 'bash', $reduced, $rpm);
ok(!-e "$reduced/opt/xcat/share/xcat/install", 'the reduced RPM omits install profiles');
ok(!-e "$reduced/opt/xcat/share/xcat/netboot/rh", 'the reduced RPM omits RHEL netboot profiles');
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");
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';
my $postinstall = 'netboot/rocky/compute.rocky10.riscv64.postinstall';
chmod(oct('0666'), "$profiles/$data") == 1 or die "chmod: $!";
for my $mask ('0022', '0002') {
subtest "Debian writable sources with umask $mask" => sub {
my $previous = umask oct($mask);
my $deb = XCAT::Test::Lifecycle::build_deb('xCAT-server', $fixture);
umask $previous;
my $staged = dirname($deb) . '/xCAT-server/share/xcat';
for my $input ($profiles, $staged) {
is(sprintf('%04o', S_IMODE((stat("$input/$data"))[2])), '0666',
'data source permissions survive staging and packaging');
is(sprintf('%04o', S_IMODE((stat("$input/$postinstall"))[2])), '0775',
'postinstall source permissions survive staging and packaging');
}
my $payload = tempdir(CLEANUP => 1);
XCAT::Test::Lifecycle::checked('dpkg-deb', '-x', $deb, $payload);
check_assets($payload, '', @assets);
for my $path (qw(install install/rh netboot netboot/rocky netboot/ubuntu/genimage)) {
is(sprintf('%04o', S_IMODE((stat("$payload/opt/xcat/share/xcat/$path"))[2])),
'0755', "$path remains executable without group or other write access");
}
};
}
}
done_testing();
@@ -18,12 +18,16 @@ my $explicit = 'https://image.example.invalid/ubuntu';
for my $case (
['amd64 default', {arch => 'x86_64'}, 'amd64', $archive, 'noble'],
['i386 default', {arch => 'x86'}, 'i386', $archive, 'noble'],
['Debian amd64 spelling', {arch => 'amd64'}, 'amd64', $archive, 'noble'],
['Debian i386 spelling', {arch => 'i386'}, 'i386', $archive, 'noble'],
['POWER default', {arch => 'ppc64el'}, 'ppc64el', $ports, 'noble'],
['POWER alternate spelling', {arch => 'ppc64le'}, 'ppc64le', $ports, 'noble'],
['RISC-V default', {arch => 'riscv64'}, 'riscv64', $ports, 'noble'],
['s390x default', {arch => 's390x'}, 's390x', $ports, 'noble'],
['site overrides archive', {mirror => $site}, 'amd64', $site, 'noble'],
['site overrides ports', {arch => 'riscv64', mirror => $site}, 'riscv64', $site, 'noble'],
['cleared site keeps default', {arch => 'riscv64', mirror => ''}, 'riscv64', $ports, 'noble'],
['cleared site keeps archive', {mirror => ''}, 'amd64', $archive, 'noble'],
['pkgdir overrides site', {mirror => $site,
pkgdir => "/work/packages,$explicit jammy main"}, 'amd64', $explicit, 'jammy'],
['first pkgdir mirror wins', {pkgdir =>
+118
View File
@@ -0,0 +1,118 @@
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use File::Slurper qw(write_text);
use File::Temp qw(tempdir);
use Test::More;
use XCAT::Test::File qw(repo_path);
my $dir = tempdir(CLEANUP => 1);
$ENV{XCATROOT} = repo_path('xCAT-server');
$ENV{XCATCFG} = "$dir/config";
mkdir $ENV{XCATCFG} or die "mkdir $ENV{XCATCFG}: $!";
require lib;
lib->import(repo_path('perl-xCAT'), repo_path('xCAT-server/lib/perl'));
require xCAT::Postage;
my @lines = (
'', ' ', '# comment', ' # indented comment',
' 0 ', ' openssh-server ', ' @Group With Space ',
' d-i tasksel/first multiselect standard,ssh-server ',
' #NEW_INSTALL_LIST# ', ' #ENV:SETTING=value# ',
' curl # inline note ', ' -snmpd ', '#INCLUDE:', '#ENV:',
'#NEW_INSTALL_LIST_EXTRA#', ' gawk',
);
write_text("$dir/lines.pkglist", join("\n", @lines));
my @records = (
'0', 'openssh-server', '@Group With Space',
'd-i tasksel/first multiselect standard,ssh-server',
'#NEW_INSTALL_LIST#', '#ENV:SETTING=value#',
'curl # inline note', '-snmpd', 'gawk',
);
is_deeply([xCAT::Postage->get_pkglist_records("$dir/lines.pkglist")],
\@records, 'record reader filters comments and preserves package-list directives');
is(xCAT::Postage->get_pkglist_tex("$dir/lines.pkglist"), join(',', @records),
'legacy root reader applies the same line policy before joining records');
is(xCAT::Postage::get_pkglist_tex("$dir/lines.pkglist"), join(',', @records),
'legacy function calls use the same policy as method calls');
is_deeply([xCAT::Postage::get_pkglist_records("$dir/lines.pkglist")],
\@records, 'record function calls use the same policy as method calls');
write_text("$dir/included-lines.pkglist", "#INCLUDE:lines.pkglist#\n");
is(xCAT::Postage->get_pkglist_tex("$dir/included-lines.pkglist"),
' 0, openssh-server, @Group With Space, d-i tasksel/first multiselect standard,ssh-server, #NEW_INSTALL_LIST#, #ENV:SETTING=value#, curl # inline note, -snmpd, gawk',
'legacy includes retain leading whitespace but remove trailing whitespace');
write_text("$dir/crlf.pkglist", " bc\r\n\t# comment\r\n0\r\nlast");
is_deeply([xCAT::Postage->get_pkglist_records("$dir/crlf.pkglist")],
[qw(bc 0 last)], 'record reader accepts CRLF and an unterminated last line');
is(xCAT::Postage->get_pkglist_tex("$dir/crlf.pkglist"), 'bc,0,last',
'legacy reader accepts CRLF and an unterminated last line');
mkdir "$dir/sub" or die "mkdir $dir/sub: $!";
write_text("$dir/root.pkglist", "before\n#INCLUDE:sub/middle.pkglist# # tail note\nafter\n");
write_text("$dir/sub/middle.pkglist", " #INCLUDE:leaf.pkglist#\n bc \n");
write_text("$dir/leaf.pkglist", "curl\n");
write_text("$dir/sub/leaf.pkglist", "wrong-directory\n");
is_deeply([xCAT::Postage->get_pkglist_records("$dir/root.pkglist")],
['before', 'curl', 'bc # tail note', 'after'],
'record includes retain root-relative lookup, order and a trailing note');
is(xCAT::Postage->get_pkglist_tex("$dir/root.pkglist"),
'before, curl, bc # tail note,after',
'legacy nested includes preserve whitespace and append the note after expansion');
local $ENV{XCAT_PKGLIST_TEST_INCLUDE} = "$dir/leaf.pkglist";
write_text("$dir/env.pkglist", '#INCLUDE:${XCAT_PKGLIST_TEST_INCLUDE}#' . "\n");
is_deeply([xCAT::Postage->get_pkglist_records("$dir/env.pkglist")], ['curl'],
'record includes expand an environment variable to an absolute filename');
is(xCAT::Postage->get_pkglist_tex("$dir/env.pkglist"), 'curl',
'legacy includes expand an environment variable to an absolute filename');
write_text("$dir/empty.pkglist", "\n# comment only\n");
is_deeply([xCAT::Postage->get_pkglist_records("$dir/empty.pkglist")], [],
'a comment-only file has no records');
is(xCAT::Postage->get_pkglist_tex("$dir/empty.pkglist"), '',
'a comment-only file has empty legacy text');
write_text("$dir/empty-include.pkglist", "before\n#INCLUDE:empty.pkglist# # note\nafter\n");
is_deeply([xCAT::Postage->get_pkglist_records("$dir/empty-include.pkglist")],
[qw(before after)], 'record reader omits a note on an empty include');
is(xCAT::Postage->get_pkglist_tex("$dir/empty-include.pkglist"),
'before, # note,after', 'legacy reader keeps a note after an empty include');
my $missing = "$dir/missing.pkglist";
my $missing_record = "#INCLUDEBAD:cannot open pkglist file $missing#";
is_deeply([xCAT::Postage->get_pkglist_records($missing)], [$missing_record],
'a missing root file yields a record error');
is(xCAT::Postage->get_pkglist_tex($missing), '',
'a missing root file yields empty legacy text');
write_text("$dir/missing-include.pkglist", "before\n#INCLUDE:missing.pkglist#\nafter\n");
is_deeply([xCAT::Postage->get_pkglist_records("$dir/missing-include.pkglist")],
['before', $missing_record, 'after'], 'record reader continues after a missing include');
is(xCAT::Postage->get_pkglist_tex("$dir/missing-include.pkglist"),
"before,$missing_record,after", 'legacy reader continues after a missing include');
my $files = "$dir/leaf.pkglist,$missing,$dir/leaf.pkglist";
is_deeply([xCAT::Postage->get_pkglist_records($files)],
['curl', $missing_record, 'curl'], 'record reader preserves file order and repeated packages');
is(xCAT::Postage->get_pkglist_tex($files), 'curl,,curl',
'legacy reader retains the empty slot for a missing middle file');
write_text("$dir/inline.pkglist", "first #INCLUDE:leaf.pkglist# last\n");
is_deeply([xCAT::Postage->get_pkglist_records("$dir/inline.pkglist")],
['first #INCLUDE:leaf.pkglist# last'], 'record reader leaves a non-leading include unchanged');
is(xCAT::Postage->get_pkglist_tex("$dir/inline.pkglist"), 'first curl last',
'legacy reader expands a non-leading include');
for my $depth (0 .. 20) {
my $next = $depth + 1;
write_text("$dir/depth$depth.pkglist", "#INCLUDE:depth$next.pkglist#\n");
}
write_text("$dir/depth21.pkglist", "curl\n");
is_deeply([xCAT::Postage->get_pkglist_records("$dir/depth0.pkglist")],
['#INCLUDE:depth21.pkglist#'], 'record reader retains its include-depth limit');
is(xCAT::Postage->get_pkglist_tex("$dir/depth0.pkglist"), 'curl',
'legacy reader continues beyond the record reader depth limit');
done_testing();
+152
View File
@@ -0,0 +1,152 @@
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use lib "$FindBin::Bin/../../perl-xCAT", "$FindBin::Bin/../../xCAT-server/lib/perl";
use File::Copy qw(copy);
use File::Path qw(make_path);
use File::Slurper qw(read_binary write_binary);
use File::Temp qw(tempdir);
use Fcntl qw(S_IMODE);
use Test::More;
use XCAT::Test::File qw(repo_path);
my $prefix = shift @ARGV // repo_path('xCAT-server');
my $work = tempdir(CLEANUP => 1);
$ENV{XCATROOT} = $prefix;
$ENV{XCATCFG} = "SQLite:$work/db";
make_path("$work/db", "$work/install");
require xCAT::SvrUtils;
require xCAT::Postage;
require xCAT::Table;
my %packages = (
'install/compute' => ['@Minimal Install', qw(kernel chrony net-tools nfs-utils
openssh-server openssl rsync util-linux wget python3 tar bzip2
perl-interpreter grub2-efi-riscv64 efibootmgr)],
'netboot/compute' => ['@minimal-environment', qw(initscripts chrony kernel
net-tools nfs-utils openssh-server rsync tar util-linux wget python3 tar
bzip2 bc dracut dracut-network NetworkManager rsyslog hostname e2fsprogs
ethtool parted openssl openssh-clients bash vim-minimal rpm iputils
perl-interpreter)],
'netboot/service' => ['@minimal-environment', qw(chrony kernel net-tools
nfs-utils openssh-server rsync tar util-linux wget perl-DBD-MySQL
perl-DBD-Pg perl-lib python3 tar bzip2 bc dracut dracut-network rsyslog
hostname e2fsprogs ethtool parted openssl openssh-clients bash
vim-minimal rpm iputils)],
);
my @cases;
for my $family (['rh', 'rhels10'], ['rocky', 'rocky10']) {
my ($directory, $os) = @$family;
for my $profile (qw(compute service)) {
push @cases, map { ['install', $directory, $profile, $os, 'riscv64', $_] }
qw(tmpl pkglist);
push @cases, map { ['netboot', $directory, $profile, $os, 'riscv64', $_] }
qw(pkglist exlist postinstall);
}
push @cases, map { [$_, $directory, 'service', $os, 'riscv64', 'otherpkgs.pkglist'] }
qw(install netboot);
}
my $ubuntu_compute = [qw(openssh-server chrony gawk nfs-common snmpd)];
my $ubuntu_kvm = [qw(openssh-server ntp gawk nfs-common snmpd qemu-kvm
libvirt-bin bridge-utils libcap2-bin vlan tmux)];
for my $release (qw(20.04 22.04 24.04 26.04)) {
push @cases, ['install', 'ubuntu', 'compute', "ubuntu$release", 'aarch64',
'pkglist', "compute.ubuntu$release.pkglist", $ubuntu_compute];
}
for my $release (qw(12.04 14.04 16.04)) {
push @cases, ['install', 'ubuntu', 'kvm', "ubuntu$release", 'x86_64',
'pkglist', "kvm.ubuntu$release.pkglist", $ubuntu_kvm];
}
push @cases, ['install', 'ubuntu', 'compute', 'ubuntu26.04', 'riscv64',
'pkglist', 'compute.ubuntu26.04.riscv64.pkglist',
[qw(bash nfs-common openssl isc-dhcp-client libc-bin openssh-server
openssh-client wget vim rsync busybox-static gawk bind9-dnsutils chrony gpg)]];
for my $release (qw(24.04 26.04)) {
my @expected = qw(bash nfs-common openssl isc-dhcp-client libc-bin
linux-image-generic openssh-server openssh-client wget rsync
busybox-static gawk bind9-dnsutils tar gzip xz-utils cpio chrony);
push @expected, qw(util-linux-extra iproute2 dracut dracut-network)
if $release eq '24.04';
push @cases, ['netboot', 'ubuntu', 'compute', "ubuntu$release", 'riscv64',
'pkglist', "compute.ubuntu$release.riscv64.pkglist", \@expected];
}
for my $case (@cases) {
my ($kind, $directory, $profile, $os, $arch, $extension, $name, $expected_packages) = @$case;
my $base = "$prefix/share/xcat/$kind/$directory";
$name //= "$profile.$os.$arch.$extension";
$expected_packages //= $packages{"$kind/$profile"};
subtest "$kind/$directory/$name" => sub {
my $selected = $extension eq 'postinstall'
? xCAT::SvrUtils->get_postinstall_file_name($base, $profile, "$os.2", $arch)
: xCAT::SvrUtils::get_file_name($base, $extension, $profile, "$os.2", $arch);
is($selected, "$base/$name", 'retains the public profile filename');
ok(defined($selected) && -r $selected, 'selected asset is readable') or return;
my $mode = S_IMODE((stat($selected))[2]);
if ($extension eq 'postinstall') {
ok($mode & oct('100'), 'postinstall asset is executable by its owner');
} else {
is($mode & oct('111'), 0, 'data asset is not executable');
}
my $original = read_binary($selected);
my $custom = "$work/$name";
copy($selected, $custom) or die "copy $selected: $!";
is(read_binary($custom), $original, 'a custom copy contains the complete asset');
if ($extension eq 'otherpkgs.pkglist') {
is_deeply([xCAT::Postage::get_pkglist_records($selected)],
['xcat/xcat-core/xCATsn', 'xcat/xcat-dep/rh10/riscv64/goconserver'],
'the service node retains its architecture-specific packages');
}
if ($extension eq 'pkglist' && $expected_packages) {
is_deeply([xCAT::Postage::get_pkglist_records($selected)],
$expected_packages, 'retains package order and repeated entries');
}
};
}
my $site = xCAT::Table->new('site', -create => 1) or die 'Cannot create site table';
$site->setAttribs({key => 'installdir'}, {value => "$work/install"});
$site->close();
my $custom = "$work/install/custom/install/rocky";
make_path($custom);
my $name = 'compute.rocky10.riscv64';
copy("$prefix/share/xcat/install/rocky/$name.tmpl", "$custom/$name.tmpl") or die $!;
write_binary("$custom/$name.pkglist", "local-package\n");
my ($status, $error) = xCAT::SvrUtils->update_tables_with_templates(
'rocky10.2', 'riscv64', '/install/media', 'fixture');
is($status, 0, 'discovers the custom and shipped profiles') or diag($error);
my $images = xCAT::Table->new('linuximage') or die 'Cannot open linuximage table';
my $compute = $images->getAttribs({imagename => 'rocky10.2-riscv64-install-compute'}, 'template', 'pkglist');
is($compute->{template}, "$custom/$name.tmpl", 'image discovery prefers the custom template');
is($compute->{pkglist}, "$custom/$name.pkglist", 'image discovery prefers the custom package list');
is(xCAT::Postage::get_pkglist_tex($compute->{pkglist}), 'local-package',
'the selected custom package list reaches the package reader');
my $service = $images->getAttribs({imagename => 'rocky10.2-riscv64-install-service'}, 'template');
is($service->{template}, "$prefix/share/xcat/install/rocky/service.rocky10.riscv64.tmpl",
'a different profile still uses its shipped template');
$images->close();
my $rh_custom = "$work/install/custom/install/rh";
make_path($rh_custom);
my $rh_name = 'compute.rhels10.riscv64.tmpl';
my $shipped = read_binary("$prefix/share/xcat/install/rh/$rh_name");
write_binary("$rh_custom/$rh_name", $shipped . "\n# custom compute template\n");
($status, $error) = xCAT::SvrUtils->update_tables_with_templates(
'rhels10.2', 'riscv64', '/install/media', 'fixture');
is($status, 0, 'discovers the customized canonical profile and shipped alias') or diag($error);
$images = xCAT::Table->new('linuximage') or die 'Cannot open linuximage table';
$compute = $images->getAttribs({imagename => 'rhels10.2-riscv64-install-compute'}, 'template');
is($compute->{template}, "$rh_custom/$rh_name", 'image discovery selects the custom canonical profile');
$service = $images->getAttribs({imagename => 'rhels10.2-riscv64-install-service'}, 'template');
is($service->{template}, "$prefix/share/xcat/install/rh/service.rhels10.riscv64.tmpl",
'the service profile retains its shipped alias');
is(read_binary($service->{template}), $shipped,
'the shipped alias does not inherit the custom canonical profile');
$images->close();
done_testing();
+59 -47
View File
@@ -3,59 +3,71 @@ use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use File::Temp qw(tempdir);
use Test::More;
use YAML::PP;
use XCAT::Test::File qw(repo_path);
# archive.ubuntu.com publishes amd64 and i386 only, so a ppc64el or riscv64 stateful install
# is handed a mirror that carries no package for it. The architecture being installed is the
# last component of the media directory.
my $dir = tempdir(CLEANUP => 1);
$ENV{XCATROOT} = repo_path('xCAT-server');
$ENV{XCATCFG} = "SQLite:$dir";
require lib;
lib->import(repo_path('perl-xCAT'), repo_path('xCAT-server/lib/perl'));
require xCAT::Template;
BEGIN {
package xCAT::Table;
our $value;
sub new { return bless {}, shift }
sub getAttribs { return defined $value ? { value => $value } : undef }
$INC{'xCAT/Table.pm'} = __FILE__;
my $archive = 'http://archive.ubuntu.com/ubuntu';
my $ports = 'http://ports.ubuntu.com/ubuntu-ports';
my $override = 'https://mirror.example.invalid/ubuntu';
my $yaml = YAML::PP->new();
my $site = xCAT::Table->new('site', -create => 1);
die 'Cannot create the site table' unless $site;
for my $setting ('missing', 'override', 'cleared') {
$site->setAttribs({key => 'ubuntu_apt_mirror'}, {value => $override})
if $setting eq 'override';
$site->setAttribs({key => 'ubuntu_apt_mirror'}, {value => ''})
if $setting eq 'cleared';
for my $case (
['x86_64', $archive], ['amd64', $archive],
['x86', $archive], ['i386', $archive],
['ppc64el', $ports], ['ppc64le', $ports],
['riscv64', $ports], ['s390x', $ports],
[undef, $archive], ['', $archive],
) {
my ($arch, $default) = @$case;
my $mirror = $setting eq 'override' ? $override : $default;
my $name = defined($arch) ? "'$arch'" : 'undefined';
is(xCAT::Template::ubuntu_subiquity_apt_mirror($arch), $mirror,
"$setting site, $name architecture: selected mirror");
for my $release (qw(ubuntu22.04 ubuntu24.04)) {
my $rendered = xCAT::Template::ubuntu_subiquity_apt_config($release, $arch);
my $apt = $yaml->load_string($rendered)->{apt};
is_deeply($apt->{'mirror-selection'}->{primary}, [{uri => $mirror}],
"$setting site, $name architecture, $release: primary mirror in YAML");
if ($release eq 'ubuntu22.04') {
is($apt->{sources}->{'xcat-ubuntu-archive.list'}->{source},
"deb $mirror \$RELEASE main restricted universe multiverse",
"$setting site, $name architecture: classic archive source");
is($apt->{sources}->{'xcat-ubuntu-updates.list'}->{source},
"deb $mirror \$RELEASE-updates main restricted universe multiverse",
"$setting site, $name architecture: classic updates source");
} else {
ok(!exists $apt->{sources},
"$setting site, $name architecture: no duplicate Deb822 sources");
}
}
}
}
$site->close();
use lib "$FindBin::Bin/../../perl-xCAT";
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
my $module = "$FindBin::Bin/../../xCAT-server/lib/perl/xCAT/Template.pm";
plan skip_all => 'Template.pm not found' unless -r $module;
eval { require $module; 1 } or plan skip_all => "could not load Template.pm: $@";
my $mirror = \&xCAT::Template::ubuntu_subiquity_apt_mirror;
# The osimage's architecture decides the mirror. pkgdir cannot: it is whatever path the
# administrator configured, so an amd64 image under /srv/custom-media would be read as a
# non-x86 architecture and sent to the ports archive.
is( $mirror->('riscv64'), 'http://ports.ubuntu.com/ubuntu-ports',
'a riscv64 image takes the ports archive' );
is( $mirror->('ppc64el'), 'http://ports.ubuntu.com/ubuntu-ports',
'a ppc64el image takes the ports archive' );
is( $mirror->('ppc64le'), 'http://ports.ubuntu.com/ubuntu-ports',
'the other spelling of ppc64 takes the ports archive' );
for my $x86 (qw(x86_64 amd64 x86 i386)) {
is( $mirror->($x86), 'http://archive.ubuntu.com/ubuntu',
"an $x86 image keeps the main archive" );
}
# With no architecture there is nothing to key on, so the previous default stands.
is( $mirror->(undef), 'http://archive.ubuntu.com/ubuntu',
'an unknown architecture keeps the previous default' );
# site.ubuntu_apt_mirror still wins, which is how an airgapped cluster points at its own.
{
local $xCAT::Table::value = 'http://mirror.example.invalid/ubuntu';
is( $mirror->('riscv64'), 'http://mirror.example.invalid/ubuntu',
'site.ubuntu_apt_mirror overrides the ports archive' );
is( $mirror->('x86_64'), 'http://mirror.example.invalid/ubuntu',
'site.ubuntu_apt_mirror overrides the main archive' );
}
{
local $xCAT::Table::value = '';
is( $mirror->('riscv64'), 'http://ports.ubuntu.com/ubuntu-ports',
'an empty site.ubuntu_apt_mirror does not blank the mirror' );
no warnings qw(redefine once);
local *xCAT::Table::new = sub { return };
is(xCAT::Template::ubuntu_subiquity_apt_mirror('riscv64'), $ports,
'unavailable site table keeps the architecture default');
is(xCAT::Template::ubuntu_subiquity_apt_mirror(undef), $archive,
'unavailable site table and architecture keep the main archive');
}
done_testing();