-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add guide to setup windows machine for WSL
Add guide to setup windows machine for running our integration tests on WSL instances
- Loading branch information
1 parent
c4ceef4
commit 68272c9
Showing
7 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
155 changes: 155 additions & 0 deletions
155
dev-docs/howtoguides/how_to_setup_windows_machine_for_wsl_testing.md
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,155 @@ | ||
# How to setup Windows machine for WSL testing | ||
|
||
To run our integration tests on WSL instances, we need to first setup a Windows machine | ||
to allows us to launch the WSL instances. Not only that, we also need to setup OpenSSH | ||
server to allow us to run ssh commands on the Windows machine. | ||
|
||
This how to guide will explain all the necessary steps for the setup, from launching the image | ||
from Azure to testing if WSL is correctly working on the machine. | ||
|
||
## Launching the image on Azure | ||
|
||
When launching the Windows instance on Azure, there a few configurations that need to be performed, | ||
otherwise we will not be able to launch WSL instances. | ||
|
||
First of all, select the `Windows 11` image and mark the `Security Type` as *Standard*. | ||
![windows_secuirty_type](windows-security-type.png) | ||
|
||
Set an username and password for the VM. Please set the username as *ubuntu*. | ||
We will use this account setting to manually login into the machine to run some commands there directly. | ||
![windows_secuirty_type](windows-ssh-setup.png) | ||
|
||
Finally, remember to also select the SSH inbound port for the machine | ||
![windows_secuirty_type](windows-setup-port.png) | ||
|
||
|
||
## Configure Bastion to login into the machine | ||
|
||
To login into the machine and access its GUI, you need to setup Bastion. | ||
After launching the machine, go for the *Connect with Bastion* option: | ||
![windows_secuirty_type](windows-bastion.png) | ||
![windows_secuirty_type](windows-deploy-bastion.png) | ||
|
||
After deploying Bastion, you just need to present your username and password to login into the | ||
machine. | ||
|
||
## Configuring Hyper-V | ||
|
||
After login into the machine through Bastion, you need to configure Hyper-V by following | ||
this [tutorial](https://learn.microsoft.com/en-us/azure/lab-services/how-to-enable-nested-virtualization-template-vm-using-script?tabs=powershell) | ||
|
||
## Installing winget | ||
|
||
For each Ubuntu distro, we will get the installers directly from the Microsoft store. | ||
To install such installers, we need to configure *winget*. | ||
|
||
To install *winget* on the machine, follow this [tutorial](https://winget.pro/winget-install-powershell/) | ||
|
||
```{note} | ||
if you see the following error when installing *winget*, restart the machine first: | ||
Add-AppxPackage : Deployment failed with HRESULT: 0x80073D02, The package could not be installed | ||
because resources it modifies are currently in use. | ||
``` | ||
|
||
## Installing wsl | ||
|
||
To install *wsl*, just run the following command, as an administrator, on powershell: | ||
|
||
```console | ||
$ wsl --install | ||
``` | ||
|
||
After that, we need to update WSL to the pre-release version by running: | ||
|
||
```console | ||
$ wsl --update --pre-release | ||
``` | ||
|
||
Now, install a Bionic instance to test the whole WSL setup is working as expected: | ||
|
||
```console | ||
$ winget install --id "9PNKSF5ZN4SW" --accept-source-agreements --accept-package-agreements --silent | ||
``` | ||
|
||
Now, create the image with: | ||
|
||
```console | ||
$ & ubuntu1804.exe install --root --ui=none | ||
``` | ||
|
||
After that, just test to see if we can run commands on the WSL instance: | ||
|
||
```console | ||
$ wsl -d Ubuntu-18.04 --exec lsb_release -a | ||
``` | ||
|
||
## Installing OpenSSH server | ||
|
||
To install OpenSSH server, follow these steps: | ||
|
||
1) Open *Settings* | ||
2) Go to *Apps* | ||
3) Go to *Optional Features* | ||
4) Go to *Add an optional feature* | ||
5) Search for *ssh* | ||
6) Install OpenSSH Server | ||
|
||
After installing the Service, open PowerShell and start-it by running: | ||
|
||
```console | ||
$ Start-Service sshd | ||
``` | ||
|
||
And set it to automatically start after boot: | ||
|
||
```console | ||
$ Set-Service -Name sshd -StartupType 'Automatic' | ||
``` | ||
|
||
### Configure the SSH keys | ||
|
||
We need to add a SSH public key into the Windows machine. | ||
|
||
To do that, follow these steps: | ||
|
||
1) Send the public key to the Windows machine: | ||
|
||
```console | ||
$ scp PUB_KEY_PATH ubuntu@IP:%programdata%/ssh | ||
``` | ||
|
||
2) SSH into the Windows machine | ||
3) Run the following commands: | ||
|
||
```console | ||
$ cd %programdata%/ssh | ||
``` | ||
|
||
```console | ||
$ type PUB_KEY_NAME >> administrators_authorized_keys | ||
``` | ||
|
||
```console | ||
$ icacls administrators_authorized_keys /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F" | ||
``` | ||
|
||
Now test SSH into the machine using your private key | ||
|
||
## Configure the machine to automatic logon | ||
|
||
To properly run *winget* commands after a machine reboot, an user | ||
needs to be already logged into the machine. To automate that process, | ||
follow this [tutorial](https://learn.microsoft.com/en-us/troubleshoot/windows-server/user-profiles-and-logon/turn-on-automatic-logon#use-registry-editor-to-turn-on-automatic-logon) | ||
|
||
Note that you also need to manually create the *DefaultUserName* and *DefaultPassword* files | ||
|
||
## Running the integration test | ||
|
||
After this setup, you should be able to use that machine to run the WSL tests automatically. | ||
Before running a WSL test, remember to set the following environment variables: | ||
|
||
* **UACLIENT_BEHAVE_WSL_IP_ADDRESS** | ||
* **UACLIENT_BEHAVE_WSL_PRIVKEY_PATH** | ||
* **UACLIENT_BEHAVE_WSL_PUBKEY_PATH** | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.