forked from os-autoinst/os-autoinst-distri-opensuse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As the enable WSL method has become obsolete and is causing some issues, we've decided to change the way how WSL is installed in the system. Also, to optimize the process, we will create a qcow image with WSL already enabled to save redundant test time
- Loading branch information
Pablo Herranz Ramírez
committed
Nov 20, 2023
1 parent
8f86a67
commit 474df6e
Showing
9 changed files
with
191 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# SUSE's openQA tests | ||
# | ||
# Copyright 2022 SUSE LLC | ||
# SPDX-License-Identifier: FSFAP | ||
|
||
# Summary: Install SUSE or openSUSE WSL images from the MS Store directly | ||
# Maintainer: qa-c <[email protected]> | ||
|
||
use Mojo::Base "windowsbasetest"; | ||
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'; | ||
|
||
$self->open_powershell_as_admin; | ||
# Set the version for WSL1 | ||
$self->run_in_powershell( | ||
cmd => 'wsl --set-default-version 1', | ||
timeout => 30 | ||
) unless (get_var('WSL2')); | ||
|
||
my $WSL_version = ''; | ||
if (is_sle('<=15-sp4')) { | ||
$WSL_version = "SUSE-Linux-Enterprise-Server-" . get_required_var("VERSION"); | ||
} elsif (is_sle('>=15-sp5')) { | ||
$WSL_version = "SUSE-Linux-Enterprise-" . get_required_var("VERSION"); | ||
} elsif (is_leap) { | ||
$WSL_version = "openSUSE-Leap-" . get_required_var("VERSION"); | ||
} else { | ||
$WSL_version = "openSUSE-Tumbleweed"; | ||
} | ||
my $install_from = get_required_var('WSL_INSTALL_FROM'); | ||
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 | ||
); | ||
record_info 'Port close', 'Closing serial port...'; | ||
$self->run_in_powershell(cmd => '$port.close()', code => sub { }); | ||
$self->run_in_powershell(cmd => 'exit', code => sub { }); | ||
$self->use_search_feature($WSL_version); | ||
assert_and_click 'wsl-suse-startup-search'; | ||
} elsif ($install_from eq 'msstore') { | ||
# Install required SUSE distro from the MS Store | ||
$self->run_in_powershell( | ||
cmd => "wsl --install --distribution $WSL_version", | ||
code => sub { | ||
assert_screen("yast2-wsl-firstboot-welcome", timeout => 300); | ||
} | ||
); | ||
} else { | ||
die("The value entered for WSL_INSTALL_FROM is not 'build' neither 'msstore'"); | ||
} | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# SUSE's openQA tests | ||
# | ||
# Copyright 2012-2019 SUSE LLC | ||
# SPDX-License-Identifier: FSFAP | ||
# | ||
# Summary: Configure windows 10 to host WSL image | ||
# Currently we have self signed images as sle12sp5 and leap | ||
# tumbleweed and sle15sp2 or higher contain a chain of certificates | ||
# In case of chain certificates, store only CA certificate | ||
# 1) Download the image and CA cert if any | ||
# 2) Enable developer mode Import certificates | ||
# 3) Import downloaded or embedded certificate | ||
# 4) Enable WSL feature | ||
# 5) Reboot | ||
# 6) Install WSL image | ||
# Maintainer: qa-c <[email protected]> | ||
|
||
use Mojo::Base qw(windowsbasetest); | ||
use Utils::Architectures qw(is_aarch64); | ||
use testapi; | ||
use version_utils qw(is_sle is_opensuse); | ||
|
||
sub run { | ||
my ($self) = @_; | ||
|
||
$self->open_powershell_as_admin; | ||
|
||
$self->power_configuration if (is_aarch64); | ||
|
||
if (get_var('WSL2')) { | ||
# WSL2 platform must be enabled from the MSstore from now on | ||
$self->run_in_powershell( | ||
cmd => "wsl --install --no-distribution", | ||
code => sub { | ||
unless (is_aarch64) { | ||
assert_screen(["windows-user-account-ctl-hidden", "windows-user-acount-ctl-allow-make-changes"], 240); | ||
assert_and_click "windows-user-account-ctl-hidden" if match_has_tag("windows-user-account-ctl-hidden"); | ||
assert_and_click "windows-user-acount-ctl-yes"; | ||
} | ||
assert_screen("windows-wsl-cli-install-finished", timeout => 900); | ||
} | ||
); | ||
# Disable HyperV in WSL2 | ||
$self->run_in_powershell( | ||
cmd => 'Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor -NoRestart', | ||
timeout => 60 | ||
); | ||
} else { | ||
# WSL1 will still be enabled in the legacy mode | ||
$self->run_in_powershell( | ||
cmd => 'Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart', | ||
timeout => 300 | ||
); | ||
} | ||
|
||
$self->reboot_or_shutdown(is_reboot => 1); | ||
$self->wait_boot_windows; | ||
} | ||
|
||
1; |
Oops, something went wrong.