Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract prepare_wsl to the Windows instalation testsuite #20976

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions schedule/wsl/install/create_windows_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ conditional_schedule:
unattended_install:
WIN_UNATTENDED:
'0':
- wsl/install/ms_win_firstboot
- wsl/install/win_firstboot

schedule:
- wsl/install/ms_win_installation
- wsl/install/win_installation
- '{{unattended_install}}'
- wsl/update_windows
- wsl/install/update_windows
- wsl/install/prepare_wsl
1 change: 0 additions & 1 deletion schedule/wsl/wsl_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ conditional_schedule:

schedule:
- wsl/boot_windows
- wsl/prepare_wsl
- wsl/install_wsl
- wsl/firstrun
- '{{enable_systemd}}'
Expand Down
34 changes: 32 additions & 2 deletions tests/wsl/prepare_wsl.pm → tests/wsl/install/prepare_wsl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ use Utils::Architectures qw(is_aarch64);
use testapi;
use version_utils qw(is_sle is_opensuse);

sub install_certificates {
my ($self) = @_;
my $ms_cert_store = 'cert:\\LocalMachine\\Root';
# We install both openSUSE and SLE to make the qcow "universal" as the Windows
# instalation DISTRI var is 'windows'.

# openSUSE certificate
$self->run_in_powershell(
cmd => 'Invoke-WebRequest -Uri "' . data_url('wsl/openSUSE-UEFI-CA-Certificate.crt') . '" -O C:\\Users\\Public\\image-ca-openSUSE.cert -UseBasicParsing',
);
$self->run_in_powershell(
cmd => 'Import-Certificate -FilePath C:\\Users\\Public\\image-ca-openSUSE.cert -CertStoreLocation ' . $ms_cert_store . ' -Verbose',
timeout => 120
);
# SLE certificate
$self->run_in_powershell(
cmd => 'Invoke-WebRequest -Uri "' . data_url('wsl/SLES-UEFI-CA-Certificate.crt') . '" -O C:\\Users\\Public\\image-ca-SLE.cert -UseBasicParsing',
);
$self->run_in_powershell(
cmd => 'Import-Certificate -FilePath C:\\Users\\Public\\image-ca-SLE.cert -CertStoreLocation ' . $ms_cert_store . ' -Verbose',
timeout => 120
);
}

sub run {
my ($self) = @_;

Expand Down Expand Up @@ -57,8 +81,14 @@ sub run {
) if get_var('HDD_1') =~ /24H2/;
}

$self->reboot_or_shutdown(is_reboot => 1);
$self->wait_boot_windows;
# Enable the 'developer mode' in Windows
$self->run_in_powershell(
cmd => 'New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name AllowDevelopmentWithoutDevLicense -PropertyType DWORD -Value 1'
);
$self->install_certificates;

# Poweroff machine to upload new image
$self->reboot_or_shutdown;
}

1;
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ sub run {
bmwqemu::diag("Applying updates while shutting down the machine...");
}
$self->wait_boot_windows;

# Shutdown
$self->reboot_or_shutdown;
}

1;
25 changes: 1 addition & 24 deletions tests/wsl/install_wsl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,6 @@ use testapi;
use version_utils;
use Utils::Architectures 'is_aarch64';

sub install_certificates {
my ($self) = @_;
my $certs = {
opensuse => 'wsl/openSUSE-UEFI-CA-Certificate.crt',
sle => 'wsl/SLES-UEFI-CA-Certificate.crt'
};
my $ms_cert_store = 'cert:\\LocalMachine\\Root';
my $cert_file_path = 'C:\Users\Public\image-ca.cert';
# The certificates should be downloaded from the web
$self->run_in_powershell(
cmd => 'Invoke-WebRequest -Uri "' . data_url($certs->{get_required_var('DISTRI')}) . '" -O "' . $cert_file_path . '" -UseBasicParsing',
);
$self->run_in_powershell(
cmd => 'Import-Certificate -FilePath "' . $cert_file_path . '" -CertStoreLocation ' . $ms_cert_store . ' -Verbose',
timeout => 120
);
}

sub run {
my ($self) = @_;
assert_screen 'windows-desktop';
Expand All @@ -54,19 +36,14 @@ sub run {
if ($install_from eq 'build') {
my $wsl_appx_filename = (split /\//, get_required_var('ASSET_1'))[-1];
my $wsl_appx_uri = "\\\\10.0.2.4\\qemu\\$wsl_appx_filename";
# Enable the 'developer mode' in Windows
$self->run_in_powershell(
cmd => 'New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name AllowDevelopmentWithoutDevLicense -PropertyType DWORD -Value 1'
);

# On Win 11 for Arm Build 25931, smb transfers don't work (poo#126083)
$wsl_appx_uri = data_url('ASSET_1') if is_aarch64;
$self->run_in_powershell(
cmd => "Start-BitsTransfer -Source $wsl_appx_uri -Destination C:\\\\$wsl_appx_filename",
timeout => 60
);

$self->install_certificates;

$self->run_in_powershell(
cmd => "Add-AppxPackage -Path C:\\$wsl_appx_filename",
timeout => 60
Expand Down
Loading