mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-08 20:50:44 +00:00
test(genesis): tighten s390x coverage
This commit is contained in:
@@ -38,7 +38,6 @@ push @config, @{ xCAT::DHCP::BootPolicy->isc_client_architecture_lines(
|
||||
net => '192.0.2.0',
|
||||
prefix => 24,
|
||||
s390x_qemu_config_present => 1,
|
||||
s390x_dpm_config_present => 1,
|
||||
) }, "}\n";
|
||||
|
||||
my $configuration_root = -d '/etc/dhcp' ? '/etc/dhcp' : '/etc';
|
||||
|
||||
@@ -51,12 +51,6 @@ my $json = $backend->render_dhcp4_config(
|
||||
{ name => 'path-prefix', data => 'pxelinux.cfg/s390x/' },
|
||||
],
|
||||
},
|
||||
{
|
||||
name => 'xcat-s390x-dpm-192.168.122.0_24',
|
||||
test => 'option[93].hex == 0x0020',
|
||||
additional_only => JSON::true,
|
||||
'boot-file-name' => 'pxelinux.cfg/s390x/192.168.122.0_24.dpm',
|
||||
},
|
||||
{
|
||||
name => 'xcat-uefi-x64',
|
||||
test => "(option[93].hex == 0x0007 or option[93].hex == 0x0009 or option[93].hex == 0x0010) and not ((option[77].exists and (option[77].text == 'xNBA' or option[77].hex == 0x784e4241 or substring(option[77].hex,1,4) == 'xNBA')))",
|
||||
@@ -84,7 +78,6 @@ my $json = $backend->render_dhcp4_config(
|
||||
additional_client_classes => [
|
||||
'xcat-opal-v3-192.168.122.0-24',
|
||||
'xcat-s390x-qemu-192.168.122.0_24',
|
||||
'xcat-s390x-dpm-192.168.122.0_24',
|
||||
],
|
||||
option_data => [
|
||||
{ name => 'routers', data => '192.168.122.1' },
|
||||
|
||||
@@ -221,7 +221,6 @@ my $s390x = xCAT::DHCP::BootPolicy->kea_s390x_network_classes(
|
||||
net => '10.0.0.0',
|
||||
prefix => 24,
|
||||
qemu_config_present => 1,
|
||||
dpm_config_present => 1,
|
||||
);
|
||||
is_deeply(
|
||||
$s390x,
|
||||
@@ -243,12 +242,6 @@ is_deeply(
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name => 'xcat-s390x-dpm-10.0.0.0_24',
|
||||
test => 'option[93].hex == 0x0020',
|
||||
additional_only => 1,
|
||||
'boot-file-name' => 'pxelinux.cfg/s390x/10.0.0.0_24.dpm',
|
||||
},
|
||||
],
|
||||
's390x firmware receives its supported network configuration method',
|
||||
);
|
||||
@@ -259,23 +252,6 @@ is_deeply(
|
||||
[],
|
||||
's390x classes require a generated network configuration',
|
||||
);
|
||||
is_deeply(
|
||||
xCAT::DHCP::BootPolicy->kea_s390x_network_classes(
|
||||
net => '10.0.0.0',
|
||||
prefix => 24,
|
||||
dpm_config_present => 1,
|
||||
),
|
||||
[
|
||||
{
|
||||
name => 'xcat-s390x-dpm-10.0.0.0_24',
|
||||
test => 'option[93].hex == 0x0020',
|
||||
additional_only => 1,
|
||||
'boot-file-name' => 'pxelinux.cfg/s390x/10.0.0.0_24.dpm',
|
||||
},
|
||||
],
|
||||
's390x policies follow the configurations available on the network',
|
||||
);
|
||||
|
||||
my @legacy_isc_config = (
|
||||
"#xCAT generated dhcp configuration\n",
|
||||
"\n",
|
||||
|
||||
@@ -15,7 +15,6 @@ my $rendered = join '', @{ xCAT::DHCP::BootPolicy->isc_client_architecture_lines
|
||||
net => '192.0.2.0',
|
||||
prefix => 24,
|
||||
s390x_qemu_config_present => 1,
|
||||
s390x_dpm_config_present => 1,
|
||||
) };
|
||||
|
||||
like(
|
||||
@@ -40,8 +39,8 @@ like(
|
||||
);
|
||||
like(
|
||||
$rendered,
|
||||
qr/client-architecture = 00:1f \{ #QEMU s390x\n\s+option path-prefix = "pxelinux\.cfg\/s390x\/";\n\s+option conf-file = "192\.0\.2\.0_24";\n\s+\} else if option client-architecture = 00:20 \{ #IBM Z DPM\n\s+filename "pxelinux\.cfg\/s390x\/192\.0\.2\.0_24\.dpm";/,
|
||||
's390x firmware receives its supported network configuration method',
|
||||
qr/client-architecture = 00:1f \{ #QEMU s390x\n\s+option path-prefix = "pxelinux\.cfg\/s390x\/";\n\s+option conf-file = "192\.0\.2\.0_24";/,
|
||||
'QEMU s390x receives its network configuration',
|
||||
);
|
||||
|
||||
my @riscv_ids = $rendered =~ /client-architecture = (00:1[9a-e])/g;
|
||||
@@ -59,13 +58,14 @@ my $fallback_pos = index($rendered, 'substring(filename,0,1) = null');
|
||||
|
||||
cmp_ok($aarch64_pos, '<', $tftp_pos, 'riscv64 follows the aarch64 branch');
|
||||
cmp_ok($tftp_pos, '<', $http_pos, 'the TFTP branch precedes the HTTP branch');
|
||||
cmp_ok($http_pos, '<', $opal_pos, 'the HTTP branch precedes the OPAL branch');
|
||||
cmp_ok($http_pos, '<', $fallback_pos, 'the HTTP branch is reachable before the fallback');
|
||||
like($rendered, qr/filename "\/yaboot";\n\s*\}\n\z/, 'the policy ends with the existing yaboot fallback');
|
||||
|
||||
my $without_s390x = join '', @{ xCAT::DHCP::BootPolicy->isc_client_architecture_lines(
|
||||
next_server => '192.0.2.10', net => '192.0.2.0', prefix => 24,
|
||||
) };
|
||||
unlike($without_s390x, qr/client-architecture = 00:(?:1f|20)/,
|
||||
unlike($without_s390x, qr/client-architecture = 00:1f/,
|
||||
'ISC does not advertise s390x without a generated network configuration');
|
||||
|
||||
done_testing();
|
||||
|
||||
@@ -141,10 +141,6 @@ make_path($s390x_config_dir);
|
||||
open(my $s390x_config, '>', "$s390x_config_dir/10.0.0.0_24")
|
||||
or die "Unable to create s390x test configuration: $!";
|
||||
close($s390x_config);
|
||||
open($s390x_config, '>', "$s390x_config_dir/10.0.0.0_24.dpm")
|
||||
or die "Unable to create s390x DPM test configuration: $!";
|
||||
close($s390x_config);
|
||||
|
||||
{
|
||||
no warnings 'redefine';
|
||||
local *xCAT::NetworkUtils::thishostisnot = sub { return 0; };
|
||||
@@ -154,13 +150,9 @@ close($s390x_config);
|
||||
);
|
||||
my %classes = map { $_->{name} => $_ } @{ $subnet->{client_classes} };
|
||||
ok($classes{'xcat-s390x-qemu-10.0.0.0_24'}, 'the Kea subnet includes QEMU s390x boot policy');
|
||||
ok($classes{'xcat-s390x-dpm-10.0.0.0_24'}, 'the Kea subnet includes IBM Z DPM boot policy');
|
||||
is_deeply(
|
||||
[ grep { /^xcat-s390x-/ } @{ $subnet->{additional_client_classes} } ],
|
||||
[
|
||||
'xcat-s390x-qemu-10.0.0.0_24',
|
||||
'xcat-s390x-dpm-10.0.0.0_24',
|
||||
],
|
||||
['xcat-s390x-qemu-10.0.0.0_24'],
|
||||
'the s390x policy is evaluated only for its subnet',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -872,6 +872,12 @@ like( $extension_class, qr/Restricted Genesis extensions must set LICENSE_FLAGS/
|
||||
like( $extension_class, qr/"sha256":/,
|
||||
'extension manifests record the image digest' );
|
||||
|
||||
my $smoke_extension = read_file(
|
||||
'xCAT-genesis-builder/oe/meta-xcat-genesis/recipes-extensions/images/xcat-genesis-extension-smoke.bb'
|
||||
);
|
||||
like( $smoke_extension, qr/^XCAT_GENESIS_EXTENSION_NAME = "xcat-smoke"$/m,
|
||||
'open smoke extension exercises the build path' );
|
||||
|
||||
my $preset = read_file(
|
||||
'xCAT-genesis-builder/oe/meta-xcat-genesis/recipes-core/xcat-genesis-init/files/00-xcat-genesis.preset'
|
||||
);
|
||||
|
||||
@@ -114,8 +114,8 @@ like(
|
||||
);
|
||||
like(
|
||||
$mknb_pod,
|
||||
qr/\bs390x\b/,
|
||||
'the mknb man page lists the s390x target',
|
||||
qr/x86.*x86_64.*ppc64.*ppc64le.*armv7hf.*aarch64.*riscv64.*s390x/s,
|
||||
'the mknb man page lists every exact OpenEmbedded architecture',
|
||||
);
|
||||
unlike(
|
||||
$mknb_pod,
|
||||
|
||||
@@ -83,6 +83,19 @@ write_file(
|
||||
#include "console.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
int xcat_test_uname(struct utsname *name) {
|
||||
const char *architecture = getenv("XCAT_TEST_ARCH");
|
||||
|
||||
memset(name, 0, sizeof(*name));
|
||||
snprintf(name->machine, sizeof(name->machine), "%s",
|
||||
architecture != NULL ? architecture : "x86_64");
|
||||
snprintf(name->release, sizeof(name->release), "test-kernel");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
struct console_state state;
|
||||
@@ -97,6 +110,7 @@ C
|
||||
is(
|
||||
system(
|
||||
$compiler, '-D_POSIX_C_SOURCE=200809L',
|
||||
'-Duname=xcat_test_uname',
|
||||
'-std=c17', '-Wall', '-Wextra', '-Wpedantic', '-Werror',
|
||||
'-I', $source_dir, $identity_test_source,
|
||||
File::Spec->catfile( $source_dir, 'state.c' ),
|
||||
@@ -191,6 +205,7 @@ my %environment = (
|
||||
XCAT_PROC_ROOT => $proc_root,
|
||||
XCAT_EXTENSION_DIR => $extensions,
|
||||
XCAT_PROVIDER_DIR => $providers,
|
||||
XCAT_TEST_ARCH => 'x86_64',
|
||||
);
|
||||
|
||||
sub run_console {
|
||||
@@ -245,10 +260,7 @@ LPAR UUID: 93724168-fda3-429b-8b28-a5d245dcb3ff
|
||||
VM00 UUID: 82038f2a-1344-aaf7-1a85-2a7250be2076
|
||||
SYSINFO
|
||||
write_file( $cmdline, "xcatd=192.0.2.10:3001\n" );
|
||||
( $status, $output ) = run_console();
|
||||
is( $status, 0, 'plain console accepts IBM Z identity' );
|
||||
like( $output, qr/^serial: not reported$/m,
|
||||
'console does not present the shared IBM Z machine serial as guest identity' );
|
||||
$environment{XCAT_TEST_ARCH} = 's390x';
|
||||
my ( $probe_status, $probe_output ) = run_identity_probe();
|
||||
is( $probe_status, 0, 'console loads IBM Z diagnostics' );
|
||||
is(
|
||||
@@ -273,6 +285,8 @@ SYSINFO
|
||||
like( $probe_output,
|
||||
qr/^uuid=93724168-fda3-429b-8b28-a5d245dcb3ff$/m,
|
||||
'console uses the LPAR UUID when no guest UUID is available' );
|
||||
unlink( File::Spec->catfile( $proc_root, 'sysinfo' ) );
|
||||
$environment{XCAT_TEST_ARCH} = 'x86_64';
|
||||
write_file( File::Spec->catfile( $dmi_root, 'product_serial' ),
|
||||
"TEST-SERIAL-001\n" );
|
||||
write_file( File::Spec->catfile( $dmi_root, 'product_uuid' ),
|
||||
|
||||
@@ -401,7 +401,7 @@ write_file( File::Spec->catfile( $device_tree, 'model' ),
|
||||
write_file( File::Spec->catfile( $device_tree, 'system-id' ),
|
||||
"IBM,02AB123\0" );
|
||||
write_file( File::Spec->catfile( $proc_root, 'cpuinfo' ),
|
||||
"processor : 0\ncpu : POWER9\nprocessor : 1\ncpu : POWER9\nplatform : PowerNV\n" );
|
||||
"cpu : POWER9\ncpu : POWER9\nplatform : PowerNV\n" );
|
||||
$environment{XCAT_TEST_ARCH} = 'ppc64le';
|
||||
$environment{XCAT_TEST_RESPONSE} = 'restart';
|
||||
is( run_script( $discover_script, \%environment ), 0,
|
||||
@@ -415,8 +415,8 @@ like( $packet, qr{<serial>02AB123</serial>},
|
||||
'Power discovery reports the system serial' );
|
||||
like( $packet, qr{<platform>PowerNV</platform>},
|
||||
'Power discovery reports the firmware platform' );
|
||||
like( $packet, qr{<cpucount>4</cpucount>},
|
||||
'Power discovery keeps the existing processor count' );
|
||||
like( $packet, qr{<cpucount>2</cpucount>},
|
||||
'Power discovery counts processor records' );
|
||||
like( $packet,
|
||||
qr{<uuid>9009-42a-02ab123-525400000002</uuid>},
|
||||
'Power discovery creates a stable fallback UUID' );
|
||||
|
||||
@@ -169,19 +169,13 @@ write_file(
|
||||
"$tftpdir/pxelinux.cfg/s390x/192.0.2.0_24",
|
||||
"# pxelinux.cfg xCAT Genesis s390x\nstale config\n",
|
||||
);
|
||||
write_file(
|
||||
"$tftpdir/pxelinux.cfg/s390x/192.0.2.0_24.dpm",
|
||||
"# pxelinux.cfg xCAT Genesis s390x\nstale DPM config\n",
|
||||
);
|
||||
write_file("$tftpdir/pxelinux.cfg/s390x/default", "admin fallback\n");
|
||||
($removed, $remove_error) =
|
||||
xCAT_plugin::mknb::_remove_openembedded_genesis($tftpdir, 's390x');
|
||||
is($remove_error, undef, 's390x boot artifacts can be retired cleanly');
|
||||
is($removed, 6, 's390x image and generated discovery configurations are retired');
|
||||
is($removed, 5, 's390x image and generated discovery configurations are retired');
|
||||
ok(!-e "$tftpdir/pxelinux.cfg/s390x/192.0.2.0_24",
|
||||
'retiring s390x removes the generated discovery configuration');
|
||||
ok(!-e "$tftpdir/pxelinux.cfg/s390x/192.0.2.0_24.dpm",
|
||||
'retiring s390x removes the generated DPM configuration');
|
||||
is(read_file("$tftpdir/pxelinux.cfg/s390x/default"), "admin fallback\n",
|
||||
'retiring s390x preserves administrator-owned configurations');
|
||||
|
||||
@@ -194,18 +188,12 @@ write_file(
|
||||
"$special_tftpdir/pxelinux.cfg/s390x/192.0.2.0_24",
|
||||
"# pxelinux.cfg xCAT Genesis s390x\nconfiguration\n",
|
||||
);
|
||||
write_file(
|
||||
"$special_tftpdir/pxelinux.cfg/s390x/192.0.2.0_24.dpm",
|
||||
"# pxelinux.cfg xCAT Genesis s390x\nDPM configuration\n",
|
||||
);
|
||||
($removed, $remove_error) =
|
||||
xCAT_plugin::mknb::_remove_openembedded_genesis($special_tftpdir, 's390x');
|
||||
is($remove_error, undef, 's390x cleanup accepts a TFTP path with shell metacharacters');
|
||||
is($removed, 5, 's390x cleanup removes every generated artifact from that path');
|
||||
is($removed, 4, 's390x cleanup removes every generated artifact from that path');
|
||||
ok(!-e "$special_tftpdir/pxelinux.cfg/s390x/192.0.2.0_24",
|
||||
's390x cleanup does not expand the TFTP path as a glob');
|
||||
ok(!-e "$special_tftpdir/pxelinux.cfg/s390x/192.0.2.0_24.dpm",
|
||||
's390x cleanup removes DPM configurations from the literal path');
|
||||
|
||||
my $failed_kernel = "$tftpdir/xcat/genesis.kernel.aarch64";
|
||||
make_path($failed_kernel);
|
||||
|
||||
@@ -536,18 +536,6 @@ unlike(
|
||||
qr/192\.168\.149\.100/,
|
||||
's390x configurations do not use the later floating address',
|
||||
);
|
||||
my $s390x_dpm_path = "$s390x_qemu_path.dpm";
|
||||
is(
|
||||
read_config($s390x_dpm_path),
|
||||
"# pxelinux.cfg xCAT Genesis s390x\n"
|
||||
. "DEFAULT xCAT\n"
|
||||
. "label xCAT\n"
|
||||
. " kernel=xcat/genesis.kernel.s390x\n"
|
||||
. " initrd=xcat/genesis.fs.s390x.gz\n"
|
||||
. " append=xcatd=192.168.148.10:3001 xcat.bootloader=s390-ccw console=ttysclp0\n",
|
||||
'the DPM configuration uses the IBM Z network-boot syntax',
|
||||
);
|
||||
|
||||
write_text($s390x_qemu_path, "admin network configuration\n");
|
||||
%xCAT::TableUtils::site_extra = ( dhcpinterfaces => 'eth0,eth1:noboot' );
|
||||
$xCAT::NetworkUtils::nic_ips = { eth0 => '10.0.0.1', eth1 => '192.168.148.10' };
|
||||
@@ -561,7 +549,15 @@ is(
|
||||
%xCAT::TableUtils::site_extra = ();
|
||||
$xCAT::NetworkUtils::nic_ips = undef;
|
||||
$responses = run_mknb('s390x');
|
||||
generation_succeeded($responses, 's390x configuration is restored after removing :noboot');
|
||||
ok(
|
||||
scalar(grep { ref($_) eq 'HASH' && $_->{error} && "@{$_->{error}}" =~ /Refusing to replace unmanaged/ } @{$responses}),
|
||||
's390x refuses to replace an administrator-owned configuration',
|
||||
);
|
||||
is(read_config($s390x_qemu_path), "admin network configuration\n",
|
||||
'the administrator-owned configuration is unchanged');
|
||||
unlink($s390x_qemu_path);
|
||||
$responses = run_mknb('s390x');
|
||||
generation_succeeded($responses, 's390x configuration is restored after removing the unmanaged file');
|
||||
|
||||
my $s390x_failure_root = "$tmpdir/tftpboot-s390x-failure";
|
||||
make_path("$s390x_failure_root/pxelinux.cfg/s390x/192.168.144.0_20");
|
||||
@@ -599,7 +595,6 @@ $xCAT::NetworkUtils::nic_ips = { eth0 => '10.0.0.1', eth1 => '192.168.148.10' };
|
||||
$responses = run_mknb('s390x');
|
||||
generation_succeeded($responses, 's390x configuration generation honors :noboot');
|
||||
ok(!-e $s390x_qemu_path, 'a :noboot network gets no QEMU s390x configuration');
|
||||
ok(!-e $s390x_dpm_path, 'a :noboot network gets no IBM Z DPM configuration');
|
||||
%xCAT::TableUtils::site_extra = ();
|
||||
$xCAT::NetworkUtils::nic_ips = undef;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user