mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-21 07:08:12 +00:00
test(packimage): cover an image directory with a space
The removal of abandoned stages, a publication that removes the other archive formats, and rmimage must work in an image directory with a space. A directory or file that the first word of its path names must stay.
This commit is contained in:
@@ -65,4 +65,24 @@ ok(!-e "$dir/.packimage-$host+KEEPPREV", 'a temporary directory that keeps the p
|
||||
ok(!-e "$dir/.rootimg-previous-KEPTARCH", 'a previous archive that a failed publication kept is removed with the image');
|
||||
ok(-e "$dir/notes.txt", 'a file that is not part of the image stays');
|
||||
|
||||
{
|
||||
# The image directory has a space, and the first word of its path names another directory, which stays.
|
||||
my $spaced = "$fixture/install/netboot/custom images/lite";
|
||||
make_path("$spaced/rootimg/etc", "$spaced/.rootimg-previous-KEPTARCH", "$fixture/install/netboot/custom/keep");
|
||||
write_text("$spaced/$_", "$_\n") for qw(rootimg.cpio.gz rootimg-statelite.gz.sha256);
|
||||
xCAT::Table->new('osimage')->setAttribs({ imagename => 'spaced' },
|
||||
{ osvers => 'rhels9.6', osarch => 'x86_64', profile => 'compute', provmethod => 'statelite' });
|
||||
xCAT::Table->new('linuximage')->setAttribs({ imagename => 'spaced' }, { rootimgdir => $spaced });
|
||||
my @spaced_responses;
|
||||
{
|
||||
no warnings 'once';
|
||||
local %::XCATSITEVALS = (installdir => "$fixture/install", tftpdir => "$fixture/tftpboot");
|
||||
xCAT_plugin::rmimage::process_request({ arg => ['spaced'] }, sub { push @spaced_responses, @_ }, sub { });
|
||||
}
|
||||
is(join("\n", map { @{ $_->{error} || [] } } @spaced_responses), '', 'rmimage of an image directory with a space reports no error');
|
||||
ok(!-e "$spaced/rootimg.cpio.gz" && !-e "$spaced/rootimg-statelite.gz.sha256", 'the archives of the image directory with a space are removed');
|
||||
ok(!-e "$spaced/.rootimg-previous-KEPTARCH", 'a kept previous archive of the image directory with a space is removed');
|
||||
ok(-d "$fixture/install/netboot/custom/keep", 'the directory that the first word of the image directory names stays');
|
||||
}
|
||||
|
||||
done_testing();
|
||||
|
||||
@@ -283,4 +283,27 @@ for my $failed ('rootimg.cpio.gz', 'rootimg.cpio.gz.metainfo') {
|
||||
is(read_binary("$dir/rootimg.cpio.gz.sha256"), "checksum of v1\n", 'the previous checksum content goes back instead');
|
||||
}
|
||||
|
||||
{
|
||||
# glob splits a pattern at a space, so the first word of an image directory with a space named another path.
|
||||
my $dir = "$fixture/custom images/node";
|
||||
make_path("$fixture/custom/keep", $dir);
|
||||
my ($stage) = xCAT::SvrUtils->rootimg_stage($dir);
|
||||
my $path = "$stage";
|
||||
$stage->unlink_on_destroy(0);
|
||||
undef $stage;
|
||||
xCAT::SvrUtils->remove_abandoned_rootimg_stages($dir);
|
||||
ok(!-e $path, 'an abandoned stage in an image directory with a space is removed');
|
||||
ok(-d "$fixture/custom/keep", 'the directory that the first word of the image directory names stays');
|
||||
|
||||
$dir = "$fixture/other images/node";
|
||||
make_path("$dir/.stage");
|
||||
write_text("$fixture/other", "file that the first word of the image directory names\n");
|
||||
write_text("$dir/rootimg.tar.xz", "archive in another format\n");
|
||||
write_text("$dir/.stage/rootimg.cpio.gz", "new archive\n");
|
||||
is(xCAT::SvrUtils->publish_rootimg("$dir/.stage/rootimg.cpio.gz", "$dir/rootimg.cpio.gz", 1), undef,
|
||||
'an archive is published in an image directory with a space');
|
||||
ok(!-e "$dir/rootimg.tar.xz", 'the archive in another format is removed from the image directory with a space');
|
||||
ok(-e "$fixture/other", 'the file that the first word of the image directory names stays');
|
||||
}
|
||||
|
||||
done_testing();
|
||||
|
||||
Reference in New Issue
Block a user