From 452b93503459e7fb33ff6a3db99b7a12031ccac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Wed, 13 Sep 2023 11:18:31 +0200 Subject: [PATCH 01/25] Allow using pre-built artifacts --- end-to-end/main_test.go | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/end-to-end/main_test.go b/end-to-end/main_test.go index d14249565..18cb1ea88 100644 --- a/end-to-end/main_test.go +++ b/end-to-end/main_test.go @@ -34,6 +34,16 @@ const ( // overrideSafety is an env variable that, if set, allows the tests to perform potentially destructive actions. overrideSafety = "UP4W_TEST_OVERRIDE_DESTRUCTIVE_CHECKS" + // prebuiltPath is an env variable that, if set, uses a build at a certain path instead of building the project anew. + // The structure is expected to be: + // └──${prebuiltPath} + // ├───wsl-pro-service + // │ └──wsl-pro-service_*.deb + // └───windows-agent + // └──UbuntuProForWindows_*.msixbundle + // + prebuiltPath = "UP4W_TEST_BUILD_PATH" + // referenceDistro is the WSL distro that will be used to generate the test image. referenceDistro = "Ubuntu" @@ -60,7 +70,7 @@ func TestMain(m *testing.M) { log.Fatalf("Setup: %v\n", err) } - wslProServiceDebPath, err := buildProject(ctx) + wslProServiceDebPath, err := ensureProjectIsBuilt(ctx) if err != nil { log.Fatalf("Setup: %v\n", err) } @@ -88,6 +98,35 @@ func TestMain(m *testing.M) { } } +func ensureProjectIsBuilt(ctx context.Context) (debPath string, err error) { + buildPath := os.Getenv(prebuiltPath) + if buildPath == "" { + return buildProject(ctx) + } + + // Remove Appx before installing + cmd := powershellf(ctx, "Get-AppxPackage CanonicalGroupLimited.UbuntuProForWindows | Remove-AppxPackage") + if out, err := cmd.CombinedOutput(); err != nil { + // (Probably because it was not installed) + log.Printf("Could not remove old AppxPackage: %v. %s", err, out) + } + + // Install Appx anew + cmd = powershellf(ctx, "Add-AppxPackage %q", filepath.Join(buildPath, "windows-agent", "UbuntuProForWindows_*.msixbundle")) + if out, err := cmd.CombinedOutput(); err != nil { + return "", fmt.Errorf("could not install pre-built AppxPackage: %v. %s", err, out) + } + + // Locate WSL-Pro-Service (it'll be installed later into the distros) + debPath = filepath.Join(buildPath, "wsl-pro-service") + _, err = locateWslProServiceDeb(ctx, debPath) + if err != nil { + return "", fmt.Errorf("could not localte pre-built WSL-Pro-Service: %v", err) + } + + return debPath, err +} + func buildProject(ctx context.Context) (debPath string, err error) { ctx, cancel := context.WithCancel(ctx) defer cancel() From 12126c45b677925ffb7410075047eb77c09258d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Fri, 15 Sep 2023 09:36:42 +0200 Subject: [PATCH 02/25] Go mod tidy --- end-to-end/go.sum | 1 + 1 file changed, 1 insertion(+) diff --git a/end-to-end/go.sum b/end-to-end/go.sum index 5663837b9..f56bd4f8f 100644 --- a/end-to-end/go.sum +++ b/end-to-end/go.sum @@ -23,6 +23,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/ubuntu/decorate v0.0.0-20230905131025-e968fa48a85c h1:jO41xNLddTDkrfz4w4RCMWCmX8Y+ZHz5jSbJWNLDvqU= +github.com/ubuntu/decorate v0.0.0-20230905131025-e968fa48a85c/go.mod h1:edGgz97NOqS2oqzbKrZqO9YU9neosRrkEZbVJVQynAA= github.com/ubuntu/gowsl v0.0.0-20230710120903-fcfd527a92e4 h1:fci3jnfZQxfb92PRQwJHXR7Mxj5OiIWXVxkkpiXrkQI= github.com/ubuntu/gowsl v0.0.0-20230710120903-fcfd527a92e4/go.mod h1:PBcZk1oAKQn1fwC9d9G2Vu25Ypxab9+UZMaPiPNjDy8= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From bd42840bd05a39f0fc4e596640453f911a778908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Fri, 15 Sep 2023 09:53:33 +0200 Subject: [PATCH 03/25] Improvements in local build scripts --- tools/build/build-appx.ps1 | 14 ++++++++++--- tools/build/build-deb.ps1 | 20 ++++++++++++------- .../debian/update-internal-dependencies | 2 +- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/tools/build/build-appx.ps1 b/tools/build/build-appx.ps1 index 33d166275..87cd5c415 100644 --- a/tools/build/build-appx.ps1 +++ b/tools/build/build-appx.ps1 @@ -44,10 +44,12 @@ function Update-Certificate { # Finding local certificate $certificate_path = "${PSScriptRoot}\.certificate_thumbprint" if (! (Test-Path "${certificate_path}") ) { - Write-Error "You need a certificate to build and install the Appx. ` + Write-Warning "You need a certificate to build and install the Appx. ` Create and install a certificate, and write its thumbprint in ${certificate_path}.` See https://learn.microsoft.com/en-us/windows/win32/appxpkg/how-to-create-a-package-signing-certificate for more details" - exit 1 + + Write-Output "Continuing with default certificate" + return } $certificate_thumbprint = Get-Content ${certificate_path} @@ -62,6 +64,8 @@ function Update-Certificate { } function Install-Appx { + Get-AppxPackage -Name "CanonicalGroupLimited.UbuntuProForWindows" | Remove-AppxPackage + $artifacts = ( Get-ChildItem ".\msix\UbuntuProForWindows\AppPackages\UbuntuProForWindows_*" ` | Sort-Object LastWriteTime ` @@ -84,7 +88,11 @@ Push-Location "${PSScriptRoot}\..\.." Update-Certificate -Start-VsDevShell +try { + msbuild.exe --version +} catch { + Start-VsDevShell +} msbuild.exe ` .\msix\msix.sln ` diff --git a/tools/build/build-deb.ps1 b/tools/build/build-deb.ps1 index c7a872329..8587b57ee 100644 --- a/tools/build/build-deb.ps1 +++ b/tools/build/build-deb.ps1 @@ -4,7 +4,7 @@ #> param( - [Parameter(Mandatory=$False,HelpMessage="The directory where the debian build artifacts will be stored in")] + [Parameter(Mandatory = $False, HelpMessage = "The directory where the debian build artifacts will be stored in")] [string]$OutputDir ) @@ -21,7 +21,7 @@ if ( $appx -eq "" ) { Write-Error "Ubuntu Preview is not installed" } -$env:WSL_UTF8=1 +$env:WSL_UTF8 = 1 if ( "$(wsl --list --verbose | Select-String Ubuntu-Preview)" -eq "" ) { ubuntupreview.exe install --root --ui=none @@ -29,12 +29,14 @@ if ( "$(wsl --list --verbose | Select-String Ubuntu-Preview)" -eq "" ) { Write-Error "could not install Ubuntu-Preview" exit 1 } + + Copy-Item -Path "${HOME}/.gitconfig" -Destination "\\wsl$\Ubuntu-Preview\etc\gitconfig" } # Write script to run -$scriptWindows=New-TemporaryFile +$scriptWindows = New-TemporaryFile -$scriptLinux=( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${scriptWindows}`' ) +$scriptLinux = ( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${scriptWindows}`' ) if ( "${LastExitCode}" -ne "0" ) { Write-Error "could not get build script's linux path" exit 1 @@ -47,9 +49,13 @@ set -eu git config --global --add safe.directory "$(pwd)" -# Update internal dependencies in the repo -# (we need git to work, and .git is not rsync'd) +# Update internal dependencies in the repo because +# we need git to work, and .git is not rsync'd. cd wsl-pro-service +go version || ( + sudo DEBIAN_FRONTEND=noninteractive apt update + sudo DEBIAN_FRONTEND=noninteractive apt install -y golang-go +) ./debian/update-internal-dependencies go mod tidy go mod vendor @@ -79,7 +85,7 @@ cp -f ${build_dir}/wsl-pro-service_* "${OutputDir}" # Set up output directory New-Item -Force -ItemType "Directory" -Path "${OutputDir}" | Out-Null -$outputLinux=( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${OutputDir}`' ) +$outputLinux = ( wsl.exe -d Ubuntu-Preview -- wslpath -ua `'${OutputDir}`' ) if ( "${LastExitCode}" -ne "0" ) { Write-Error "could not get output dir's linux path" exit 1 diff --git a/wsl-pro-service/debian/update-internal-dependencies b/wsl-pro-service/debian/update-internal-dependencies index 59d51f0ff..3b19d2ff8 100755 --- a/wsl-pro-service/debian/update-internal-dependencies +++ b/wsl-pro-service/debian/update-internal-dependencies @@ -2,7 +2,7 @@ set -eu # Add repo as private -go env -w GOPRIVATE=github.com/canonical/ubuntu-pro-for-windows +go env -w "GOPRIVATE=github.com/canonical/ubuntu-pro-for-windows" UP4W_SKIP_INTERNAL_DEPENDENCY_UPDATE=${UP4W_SKIP_INTERNAL_DEPENDENCY_UPDATE:-""} From 4fc72bca8a9a6b1eee4293da117c3f361d842093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Tue, 26 Sep 2023 13:42:35 +0200 Subject: [PATCH 04/25] Create qa-azure workflow --- .github/workflows/qa-azure.yaml | 115 ++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 .github/workflows/qa-azure.yaml diff --git a/.github/workflows/qa-azure.yaml b/.github/workflows/qa-azure.yaml new file mode 100644 index 000000000..f2cc1393a --- /dev/null +++ b/.github/workflows/qa-azure.yaml @@ -0,0 +1,115 @@ +name: QA on Azure +# QA checks on Azure, allowing the use of a real WSL back-en + +concurrency: azure-vm + +on: + pull_request: + workflow_dispatch: + push: + branches: [main] + +env: + az_name: wsl-ci-3 + az_resource_group: wsl + flutter-version: 3.13.x + +jobs: + vm-setup: + name: Set up Azure VM + runs-on: ubuntu-latest + steps: + - name: Azure login + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_VM_CREDS }} + - name: Start the Runner + shell: bash + run: | + az vm start --name ${{ env.az_name }} --resource-group ${{ env.az_resource_group }} + + qa: + name: Run end-to-end tests on the Azure VM + runs-on: [self-hosted, Windows] + needs: vm-setup + steps: + - name: Set up git + uses: canonical/ubuntu-pro-for-windows/.github/actions/setup-git@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Ubuntu + uses: Ubuntu/WSL/.github/actions/wsl-install@main + with: + distro: "Ubuntu" + - name: Set up Go + # actions/setup-go is broken + shell: powershell + run: | + winget install GoLang.Go + Exit(0) + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: ci-artifacts + - name: Set up artifacts + shell: powershell + working-directory: ci-artifacts + run: | + Write-Output "::group::Set up AppxPackage" + Get-AppxPackage -Name "CanonicalGroupLimited.UbuntuProForWindows" | Remove-AppxPackage -ErrorAction Ignore + + New-Item -Name "windows-agent" -ItemType Directory + Move-Item -Path "UbuntuProForWindows+*/UbuntuProForWindows_*/*.msixbundle" -Destination "windows-agent/" + Move-Item -Path "UbuntuProForWindows+*/UbuntuProForWindows_*/*.cer" -Destination "windows-agent/" + Remove-Item -Recurse "UbuntuProForWindows+*/" + + $cert = "$(Get-ChildItem windows-agent/UbuntuProForWindows_*.cer)" + Import-Certificate -FilePath "${cert}" -CertStoreLocation Cert:LocalMachine\TrustedPeople + + Write-Output "::endgroup::" + + Write-Output "::group::Set up WSL Pro Service" + New-Item -Name "wsl-pro-service" -ItemType Directory + Move-Item -Path "wsl-pro-service_*/wsl-pro-service_*.deb" -Destination "wsl-pro-service/" + Remove-Item -Recurse "wsl-pro-service_*/" + Write-Output "::endgroup::" + - name: Test + shell: powershell + env: + GIT_TERMINAL_PROMPT: "0" + UP4W_TEST_OVERRIDE_DESTRUCTIVE_CHECKS: "1" + UP4W_TEST_BUILD_PATH: "../ci-artifacts" + UP4W_TEST_PRO_TOKEN: "${{ secrets.UBUNTU_PRO_TOKEN }}" + run: | + go env -w "GOPRIVATE=github.com/${{ github.repository }}" + + go test .\end-to-end -shuffle=on -timeout 20m + if ( "$LastExitCode" -ne "0" ) { Exit(1) } + - name: Clean up + if: always() + shell: powershell + run: | + # Clean up artifacts + + # Remove .gitconfig so that the github URL overrides do not stack + Remove-Item -Recurse -Path "${HOME}\.gitconfig" -ErrorAction Ignore + + # Uninstall Appx + Get-AppxPackage -Name "CanonicalGroupLimited.UbuntuProForWindows" | Remove-AppxPackage -ErrorAction Ignore + + stop-vm: + name: Clean up the Azure VM + runs-on: ubuntu-latest + needs: [vm-setup, qa] + if: always() + steps: + - name: Azure login + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_VM_CREDS }} + - name: Deallocate the Runner + shell: bash + run: | + az vm deallocate --name ${{ env.az_name }} --resource-group ${{ env.az_resource_group }} From a2b28e646c3e3d2616dbfa587a29adc24e37a52a Mon Sep 17 00:00:00 2001 From: EduardGomezEscandell Date: Fri, 22 Sep 2023 11:48:34 +0200 Subject: [PATCH 05/25] Good old DEBIAN_FRONTEND=noninteractive --- end-to-end/main_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/end-to-end/main_test.go b/end-to-end/main_test.go index 18cb1ea88..b8b9d5833 100644 --- a/end-to-end/main_test.go +++ b/end-to-end/main_test.go @@ -357,7 +357,7 @@ func generateTestImage(ctx context.Context, sourceDistro, wslProServiceDebPath s return "", nil, err } - out, err = d.Command(ctx, fmt.Sprintf("apt install $(wslpath -ua '%s')", debPath)).CombinedOutput() + out, err = d.Command(ctx, fmt.Sprintf("DEBIAN_FRONTEND=noninteractive apt install -y $(wslpath -ua '%s')", debPath)).CombinedOutput() if err != nil { defer cleanup() return "", nil, fmt.Errorf("could not install wsl-pro-service: %v. %s", err, out) From 80645cfd98b48da1d6567f9ef8044edeff8149d7 Mon Sep 17 00:00:00 2001 From: EduardGomezEscandell Date: Fri, 22 Sep 2023 12:03:11 +0200 Subject: [PATCH 06/25] Move artifact build to QA-azure This is necessary in order to set a dependency relationship. They still run on Github runners. --- .github/workflows/qa-azure.yaml | 68 ++++++++++++++++++++++++++++++++- .github/workflows/qa.yaml | 66 -------------------------------- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/.github/workflows/qa-azure.yaml b/.github/workflows/qa-azure.yaml index f2cc1393a..5e24dba81 100644 --- a/.github/workflows/qa-azure.yaml +++ b/.github/workflows/qa-azure.yaml @@ -15,6 +15,72 @@ env: flutter-version: 3.13.x jobs: + build-wsl-pro-service: + name: Build wsl-pro-service debian package + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Build debian package + uses: canonical/desktop-engineering/gh-actions/common/build-debian@main + with: + source-dir: wsl-pro-service + token: ${{ secrets.GITHUB_TOKEN }} + docker-image: ubuntu:devel + env: + UP4W_SKIP_INTERNAL_DEPENDENCY_UPDATE: "1" + + build-ubuntu-pro-for-windows: + name: Build Windows Agent Appx + runs-on: windows-latest + steps: + - name: Set up git + uses: canonical/ubuntu-pro-for-windows/.github/actions/setup-git@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Check out repository + uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version-file: go.work + - uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: ${{ env.flutter-version }} + - name: Setup MSBuild (PATH) + uses: microsoft/setup-msbuild@v1.3.1 + - name: Install certificate + shell: powershell + run: | + New-Item -ItemType directory -Path certificate + Set-Content -Path certificate\certificate.txt -Value '${{ secrets.CERTIFICATE }}' + certutil -decode certificate\certificate.txt certificate\certificate.pfx + + $pwd = ConvertTo-SecureString '${{ secrets.CERTIFICATE_PASSWORD }}' -AsPlainText -Force + Import-PfxCertificate -Password $pwd -CertStoreLocation Cert:LocalMachine\Trust -FilePath certificate\certificate.pfx + Import-PfxCertificate -Password $pwd -CertStoreLocation Cert:CurrentUser\My -FilePath certificate\certificate.pfx + - name: Build Bundle + run: | + msbuild ` + .\msix\msix.sln ` + -target:Build ` + -maxCpuCount ` + -nodeReuse:false ` + -property:Configuration=Release ` + -property:AppxBundle=Always ` + -property:AppxBundlePlatforms=x64 ` + -property:UapAppxPackageBuildMode=SideloadOnly ` + -property:Version=0.0.1+${{ github.sha }} ` + -nologo ` + -verbosity:normal + - name: Upload sideload artifact + uses: actions/upload-artifact@v3 + with: + name: UbuntuProForWindows+${{ github.sha }} + path: | + msix/UbuntuProForWindows/AppPackages/UbuntuProForWindows_*/UbuntuProForWindows_1.0.0.0_x64.cer + msix/UbuntuProForWindows/AppPackages/UbuntuProForWindows_*/UbuntuProForWindows_1.0.0.0_x64.msixbundle + vm-setup: name: Set up Azure VM runs-on: ubuntu-latest @@ -31,7 +97,7 @@ jobs: qa: name: Run end-to-end tests on the Azure VM runs-on: [self-hosted, Windows] - needs: vm-setup + needs: [vm-setup, build-wsl-pro-service, build-ubuntu-pro-for-windows] steps: - name: Set up git uses: canonical/ubuntu-pro-for-windows/.github/actions/setup-git@main diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml index 0fcbee84a..a8c878969 100644 --- a/.github/workflows/qa.yaml +++ b/.github/workflows/qa.yaml @@ -256,69 +256,3 @@ jobs: uses: ./.github/actions/check-diff with: files-to-validate: '${{ matrix.subproject }}/{.,**}/*.{dart,go}' - - build-wsl-pro-service: - name: Build wsl-pro-service debian package - runs-on: ubuntu-latest - steps: - - name: Check out repository - uses: actions/checkout@v4 - - name: Build debian package - uses: canonical/desktop-engineering/gh-actions/common/build-debian@main - with: - source-dir: wsl-pro-service - token: ${{ secrets.GITHUB_TOKEN }} - docker-image: ubuntu:devel - env: - UP4W_SKIP_INTERNAL_DEPENDENCY_UPDATE: "1" - - build-ubuntu-pro-for-windows: - name: Build Windows Agent Appx - runs-on: windows-latest - steps: - - name: Set up git - uses: canonical/ubuntu-pro-for-windows/.github/actions/setup-git@main - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Check out repository - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version-file: go.work - - uses: subosito/flutter-action@v2 - with: - channel: stable - flutter-version: ${{ env.flutter-version }} - - name: Setup MSBuild (PATH) - uses: microsoft/setup-msbuild@v1.3.1 - - name: Install certificate - shell: powershell - run: | - New-Item -ItemType directory -Path certificate - Set-Content -Path certificate\certificate.txt -Value '${{ secrets.CERTIFICATE }}' - certutil -decode certificate\certificate.txt certificate\certificate.pfx - - $pwd = ConvertTo-SecureString '${{ secrets.CERTIFICATE_PASSWORD }}' -AsPlainText -Force - Import-PfxCertificate -Password $pwd -CertStoreLocation Cert:LocalMachine\Trust -FilePath certificate\certificate.pfx - Import-PfxCertificate -Password $pwd -CertStoreLocation Cert:CurrentUser\My -FilePath certificate\certificate.pfx - - name: Build Bundle - run: | - msbuild ` - .\msix\msix.sln ` - -target:Build ` - -maxCpuCount ` - -nodeReuse:false ` - -property:Configuration=Release ` - -property:AppxBundle=Always ` - -property:AppxBundlePlatforms=x64 ` - -property:UapAppxPackageBuildMode=SideloadOnly ` - -property:Version=0.0.1+${{ github.sha }} ` - -nologo ` - -verbosity:normal - - name: Upload sideload artifact - uses: actions/upload-artifact@v3 - with: - name: UbuntuProForWindows+${{ github.sha }} - path: | - msix/UbuntuProForWindows/AppPackages/UbuntuProForWindows_*/UbuntuProForWindows_1.0.0.0_x64.cer - msix/UbuntuProForWindows/AppPackages/UbuntuProForWindows_*/UbuntuProForWindows_1.0.0.0_x64.msixbundle From 5eec63b25ca001de7d88c4ca408b8a263b9f8e3d Mon Sep 17 00:00:00 2001 From: EduardGomezEscandell Date: Fri, 22 Sep 2023 12:26:59 +0200 Subject: [PATCH 07/25] Change wiki article on where to find artifacts They are now in QA-Azure --- doc/02.-Installation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/02.-Installation.md b/doc/02.-Installation.md index 90a715d45..43028de57 100644 --- a/doc/02.-Installation.md +++ b/doc/02.-Installation.md @@ -10,7 +10,7 @@ This guide will show you how to install Ubuntu Pro For Windows for local develop ### Download -1. Go to the [repository actions page](https://github.com/canonical/ubuntu-pro-for-windows/actions/workflows/qa.yaml?query=branch%3Amain+). +1. Go to the [repository actions page](https://github.com/canonical/ubuntu-pro-for-windows/actions/workflows/qa-azure.yaml?query=branch%3Amain+). 2. Click the latest successful workflow run. 3. Scroll down past any warnings or errors, until you reach the Artifacts section. 4. Download: @@ -27,7 +27,7 @@ This is the Windows-side agent that manages the distros. 2. Follow the download steps to download UbuntuProForWindows 3. Unzip the artifact 4. Find the certificate inside. Install it into `Local Machine/Trusted people`. -5. Open Powershell in this directory and run +5. Open Powershell in this directory and run ```powershell Add-AppxPackage .\UbuntuProForWindows_*_x64.msixbundle ``` @@ -91,7 +91,7 @@ You can use a private Landscape instance (different from [landscape.canonical.co 4. Click on "Click to restart it". 9. Stop the distro you installed WSL-Pro-Service in: ```powershell - wsl --terminate DISTRO_NAME + wsl --terminate DISTRO_NAME ``` 10. Start the distro you installed WSL-Pro-Service in. 11. You should see a new "pending computer authorisation" in you Landscape dashboard. \ No newline at end of file From f22cd7c6b045942f02e9ce7d3e53870b8884c129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Tue, 26 Sep 2023 13:20:58 +0200 Subject: [PATCH 08/25] Don't remove artifacts after running --- end-to-end/main_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/end-to-end/main_test.go b/end-to-end/main_test.go index b8b9d5833..e97efd139 100644 --- a/end-to-end/main_test.go +++ b/end-to-end/main_test.go @@ -74,11 +74,6 @@ func TestMain(m *testing.M) { if err != nil { log.Fatalf("Setup: %v\n", err) } - defer func() { - if err := os.RemoveAll(wslProServiceDebPath); err != nil { - log.Printf("could not remove debian artifacts at %q: %v", wslProServiceDebPath, err) - } - }() if err := assertAppxInstalled(ctx, "CanonicalGroupLimited.UbuntuProForWindows"); err != nil { log.Fatalf("Setup: %v\n", err) @@ -96,6 +91,11 @@ func TestMain(m *testing.M) { if err := cleanupRegistry(); err != nil { log.Printf("Cleanup: registry: %v\n", err) } + + cmd := powershellf(ctx, "Get-AppxPackage -Name CanonicalGroupLimited.UbuntuProForWindows | Remove-AppxPackage") + if out, err := cmd.CombinedOutput(); err != nil { + log.Printf("Cleanup: could not remove Appx: %v: %s", err, out) + } } func ensureProjectIsBuilt(ctx context.Context) (debPath string, err error) { From 3dbaebbafd75c3e56dd9fcc9f90f87dce66f9705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Tue, 26 Sep 2023 13:24:27 +0200 Subject: [PATCH 09/25] Kill agent after every subtest --- end-to-end/organization_token_test.go | 6 +++-- end-to-end/utils_test.go | 33 +++++++++++++++++++-------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/end-to-end/organization_token_test.go b/end-to-end/organization_token_test.go index 177155dce..f42263def 100644 --- a/end-to-end/organization_token_test.go +++ b/end-to-end/organization_token_test.go @@ -40,7 +40,8 @@ func TestOrganizationProvidedToken(t *testing.T) { if tc.whenToken == beforeDistroRegistration { activateOrgSubscription(t) - startAgent(t, ctx) + cleanup := startAgent(t, ctx) + defer cleanup() } // Distro setup @@ -57,7 +58,8 @@ func TestOrganizationProvidedToken(t *testing.T) { require.NoError(t, err, "could not restart distro") activateOrgSubscription(t) - startAgent(t, ctx) + cleanup := startAgent(t, ctx) + defer cleanup() out, err := d.Command(ctx, "exit 0").CombinedOutput() require.NoErrorf(t, err, "Setup: could not wake distro up: %v. %s", err, out) diff --git a/end-to-end/utils_test.go b/end-to-end/utils_test.go index becd8269b..77b60daf7 100644 --- a/end-to-end/utils_test.go +++ b/end-to-end/utils_test.go @@ -62,7 +62,7 @@ func registerFromTestImage(t *testing.T, ctx context.Context) string { // startAgent starts the GUI (without interacting with it) and waits for the Agent to start. // //nolint:revive // testing.T must precede the contex -func startAgent(t *testing.T, ctx context.Context) { +func startAgent(t *testing.T, ctx context.Context) (cleanup func()) { t.Helper() t.Log("Starting agent") @@ -71,21 +71,34 @@ func startAgent(t *testing.T, ctx context.Context) { out, err := powershellf(ctx, "(Get-AppxPackage CanonicalGroupLimited.UbuntuProForWindows).InstallLocation").CombinedOutput() require.NoError(t, err, "could not locate ubuntupro.exe: %v. %s", err, out) - ctx, cancel := context.WithCancel(ctx) - ubuntupro := filepath.Join(strings.TrimSpace(string(out)), "gui", "ubuntupro.exe") //nolint:gosec // The executable is located at the Appx directory cmd := exec.CommandContext(ctx, ubuntupro) - t.Cleanup(func() { - cancel() - //nolint:errcheck // This returns a "context cancelled" error. - cmd.Wait() - }) - err = cmd.Start() require.NoError(t, err, "Setup: could not start agent") + cleanup = func() { + t.Log("Cleanup: stopping agent process") + + if err := stopAgent(ctx); err != nil { + // We have to abort because the tests become coupled via the agent + log.Fatalf("Could not kill ubuntu-pro-agent process: %v: %s", err, out) + } + + //nolint:errcheck // Nothing we can do about it + cmd.Process.Kill() + + //nolint:errcheck // We know that the previous "Kill" stopped it + cmd.Wait() + } + + defer func() { + if t.Failed() { + cleanup() + } + }() + require.Eventually(t, func() bool { localAppData := os.Getenv("LocalAppData") require.NotEmpty(t, localAppData, "$env:LocalAppData should not be empty") @@ -98,6 +111,8 @@ func startAgent(t *testing.T, ctx context.Context) { return false }, 5*time.Second, 100*time.Millisecond, "Agent never started serving") + + return cleanup } // stopAgent kills the process for the Windows Agent. From 98f88450fcf256417069ef44c83701655d836541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Tue, 26 Sep 2023 13:25:36 +0200 Subject: [PATCH 10/25] Log agent's log after every test --- end-to-end/utils_test.go | 6 ++++++ gui/packages/ubuntupro/lib/launch_agent.dart | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/end-to-end/utils_test.go b/end-to-end/utils_test.go index 77b60daf7..bd126a040 100644 --- a/end-to-end/utils_test.go +++ b/end-to-end/utils_test.go @@ -1,6 +1,7 @@ package endtoend_test import ( + "bytes" "context" "errors" "fmt" @@ -75,6 +76,10 @@ func startAgent(t *testing.T, ctx context.Context) (cleanup func()) { //nolint:gosec // The executable is located at the Appx directory cmd := exec.CommandContext(ctx, ubuntupro) + var buff bytes.Buffer + cmd.Stdout = &buff + cmd.Stderr = &buff + err = cmd.Start() require.NoError(t, err, "Setup: could not start agent") @@ -91,6 +96,7 @@ func startAgent(t *testing.T, ctx context.Context) (cleanup func()) { //nolint:errcheck // We know that the previous "Kill" stopped it cmd.Wait() + t.Logf("Agent stopped. Stdout+stderr: %s", buff.String()) } defer func() { diff --git a/gui/packages/ubuntupro/lib/launch_agent.dart b/gui/packages/ubuntupro/lib/launch_agent.dart index d33097a6c..aa39197f5 100644 --- a/gui/packages/ubuntupro/lib/launch_agent.dart +++ b/gui/packages/ubuntupro/lib/launch_agent.dart @@ -17,8 +17,9 @@ Future launchAgent(String agentRelativePath) async { try { await Process.start( agentPath, - [], + ['-vv'], environment: Environment.instance.merged, + mode: ProcessStartMode.inheritStdio, ); return true; } on ProcessException catch (err) { From 43c5bc8a84470972db74f00a153120b93895f944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Tue, 26 Sep 2023 15:41:23 +0200 Subject: [PATCH 11/25] Stop the agent build from breaking rsync --- tools/build/build-deb.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build/build-deb.ps1 b/tools/build/build-deb.ps1 index 8587b57ee..3f405d77f 100644 --- a/tools/build/build-deb.ps1 +++ b/tools/build/build-deb.ps1 @@ -69,6 +69,7 @@ rsync \ --quiet \ --exclude=".git" \ --exclude="msix/UbuntuProForWindows" \ + --exclude="gui" \ --exclude="*vcxproj*" \ --exclude="*/x64/*" \ . \ From ccf1ee9927844cf6b186bfca99c7d4daa2805fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Tue, 26 Sep 2023 15:47:23 +0200 Subject: [PATCH 12/25] Add trailing endline to wapprojj Minor thing, but some tool is autocorrecting this all the time causing an anoying diff --- msix/UbuntuProForWindows/UbuntuProForWindows.wapproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msix/UbuntuProForWindows/UbuntuProForWindows.wapproj b/msix/UbuntuProForWindows/UbuntuProForWindows.wapproj index 6949f393b..f6b246e71 100644 --- a/msix/UbuntuProForWindows/UbuntuProForWindows.wapproj +++ b/msix/UbuntuProForWindows/UbuntuProForWindows.wapproj @@ -107,4 +107,4 @@ - \ No newline at end of file + From d52895c5c9e9d8a73ef1cb29b8657024d3241ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Tue, 26 Sep 2023 16:38:50 +0200 Subject: [PATCH 13/25] TestOrganizationProvidedToken: Use Eventually instead of Sleep --- end-to-end/organization_token_test.go | 48 +++++++++++++++++++-------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/end-to-end/organization_token_test.go b/end-to-end/organization_token_test.go index f42263def..7c7465898 100644 --- a/end-to-end/organization_token_test.go +++ b/end-to-end/organization_token_test.go @@ -3,6 +3,7 @@ package endtoend_test import ( "context" "encoding/json" + "fmt" "os" "testing" "time" @@ -65,29 +66,48 @@ func TestOrganizationProvidedToken(t *testing.T) { require.NoErrorf(t, err, "Setup: could not wake distro up: %v. %s", err, out) } - // Give the agent some time to pro-attach - time.Sleep(5 * time.Second) - - // Validate that the distro was attached - out, err = d.Command(ctx, "pro status --format=json").Output() - require.NoErrorf(t, err, "Setup: could not call pro status: %v. %s", err, out) - - var response struct { - Attached bool - } - err = json.Unmarshal(out, &response) - require.NoError(t, err, "could not parse pro status response: %s", out) + const maxTimeout = 5*time.Second if !tc.wantAttached { - require.False(t, response.Attached, "distro should not have been Pro attached") + time.Sleep(maxTimeout) + attached, err := distroIsProAttached(t, d) + require.NoError(t, err, "could not determine if distro is attached") + require.False(t, attached, "distro should not have been Pro attached") return } - require.True(t, response.Attached, "distro should have been Pro attached") + require.Eventually(t, func() bool { + attached, err := distroIsProAttached(t, d) + if err != nil { + t.Logf("could not determine if distro is attached: %v", err) + } + return attached + }, maxTimeout, time.Second, "distro should have been Pro attached") }) } } +func distroIsProAttached(t *testing.T, d wsl.Distro) (bool, error) { + t.Helper() + + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + + out, err := d.Command(ctx, "pro status --format=json").Output() + if err != nil { + return false, fmt.Errorf("could not call pro status: %v. %s", err, out) + } + + var response struct { + Attached bool + } + if err := json.Unmarshal(out, &response); err != nil { + return false, fmt.Errorf("could not parse pro status response: %v: %s", err, out) + } + + return response.Attached, nil +} + func activateOrgSubscription(t *testing.T) { t.Helper() From 62212645f1a02a1e57ffe5edc2f0cdfbadcf6847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Wed, 27 Sep 2023 09:40:07 +0200 Subject: [PATCH 14/25] Don't log "agent started" when it failed to start --- end-to-end/utils_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/end-to-end/utils_test.go b/end-to-end/utils_test.go index bd126a040..ec4c94317 100644 --- a/end-to-end/utils_test.go +++ b/end-to-end/utils_test.go @@ -67,7 +67,6 @@ func startAgent(t *testing.T, ctx context.Context) (cleanup func()) { t.Helper() t.Log("Starting agent") - defer t.Log("Started agent") out, err := powershellf(ctx, "(Get-AppxPackage CanonicalGroupLimited.UbuntuProForWindows).InstallLocation").CombinedOutput() require.NoError(t, err, "could not locate ubuntupro.exe: %v. %s", err, out) @@ -118,6 +117,7 @@ func startAgent(t *testing.T, ctx context.Context) (cleanup func()) { return false }, 5*time.Second, 100*time.Millisecond, "Agent never started serving") + t.Log("Started agent") return cleanup } From 6e72d7870a296b13eb54863c0d48b86442b3e9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Wed, 27 Sep 2023 09:40:47 +0200 Subject: [PATCH 15/25] Don't make assertions outside of main goroutine Otherwise the tests panic --- end-to-end/utils_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/end-to-end/utils_test.go b/end-to-end/utils_test.go index ec4c94317..56de06e4f 100644 --- a/end-to-end/utils_test.go +++ b/end-to-end/utils_test.go @@ -106,15 +106,20 @@ func startAgent(t *testing.T, ctx context.Context) (cleanup func()) { require.Eventually(t, func() bool { localAppData := os.Getenv("LocalAppData") - require.NotEmpty(t, localAppData, "$env:LocalAppData should not be empty") + if localAppData == "" { + t.Logf("Agent setup: $env:LocalAppData should not be empty") + return false + } _, err := os.Stat(filepath.Join(localAppData, "Ubuntu Pro", "addr")) - if err == nil { - return true + if errors.Is(err, fs.ErrNotExist) { + return false } - require.ErrorIsf(t, err, fs.ErrNotExist, "could not read addr file") - - return false + if err != nil { + t.Logf("Agent setup: could not read addr file: %v", err) + return false + } + return true }, 5*time.Second, 100*time.Millisecond, "Agent never started serving") t.Log("Started agent") From 9959588c525391dfdaa5bbbb58a8fbff34be0a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Tue, 26 Sep 2023 16:39:51 +0200 Subject: [PATCH 16/25] Increase timeouts --- end-to-end/organization_token_test.go | 2 +- end-to-end/utils_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/end-to-end/organization_token_test.go b/end-to-end/organization_token_test.go index 7c7465898..dbb7e9cc2 100644 --- a/end-to-end/organization_token_test.go +++ b/end-to-end/organization_token_test.go @@ -66,7 +66,7 @@ func TestOrganizationProvidedToken(t *testing.T) { require.NoErrorf(t, err, "Setup: could not wake distro up: %v. %s", err, out) } - const maxTimeout = 5*time.Second + const maxTimeout = 30 * time.Second if !tc.wantAttached { time.Sleep(maxTimeout) diff --git a/end-to-end/utils_test.go b/end-to-end/utils_test.go index 56de06e4f..6f310d999 100644 --- a/end-to-end/utils_test.go +++ b/end-to-end/utils_test.go @@ -120,7 +120,7 @@ func startAgent(t *testing.T, ctx context.Context) (cleanup func()) { return false } return true - }, 5*time.Second, 100*time.Millisecond, "Agent never started serving") + }, 10*time.Second, 100*time.Millisecond, "Agent never started serving") t.Log("Started agent") return cleanup From 352d9b4d08eb73e007f366e4ff722515acb2aed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Thu, 28 Sep 2023 10:11:45 +0200 Subject: [PATCH 17/25] More explanation as to why we ignore winget's output --- .github/workflows/qa-azure.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/qa-azure.yaml b/.github/workflows/qa-azure.yaml index 5e24dba81..3fd4db2b2 100644 --- a/.github/workflows/qa-azure.yaml +++ b/.github/workflows/qa-azure.yaml @@ -114,7 +114,12 @@ jobs: shell: powershell run: | winget install GoLang.Go - Exit(0) + # Cannot check for error: there is no way to distinguish the two: + # - Legitimate error + # - Error because no updates found (Golang.Go is already up to date) + # + # We can check that Go works, though. + go version - name: Download artifacts uses: actions/download-artifact@v3 with: From cf0edd33ae46ede41e9b45d02307a0bb7172eacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Thu, 28 Sep 2023 10:16:39 +0200 Subject: [PATCH 18/25] Add flags to winget to ensure it is non-interactive --- .github/workflows/qa-azure.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/qa-azure.yaml b/.github/workflows/qa-azure.yaml index 3fd4db2b2..0b67b2949 100644 --- a/.github/workflows/qa-azure.yaml +++ b/.github/workflows/qa-azure.yaml @@ -113,7 +113,7 @@ jobs: # actions/setup-go is broken shell: powershell run: | - winget install GoLang.Go + winget install GoLang.Go --accept-source-agreements --accept-package-agreements --silent --verbose # Cannot check for error: there is no way to distinguish the two: # - Legitimate error # - Error because no updates found (Golang.Go is already up to date) From c79543bb8145ab39896941fc9d0a0978757d59b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Thu, 28 Sep 2023 10:33:27 +0200 Subject: [PATCH 19/25] Uninstall certificate during cleanup --- .github/workflows/qa-azure.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/qa-azure.yaml b/.github/workflows/qa-azure.yaml index 0b67b2949..c01f78a38 100644 --- a/.github/workflows/qa-azure.yaml +++ b/.github/workflows/qa-azure.yaml @@ -169,6 +169,10 @@ jobs: # Uninstall Appx Get-AppxPackage -Name "CanonicalGroupLimited.UbuntuProForWindows" | Remove-AppxPackage -ErrorAction Ignore + + # Uninstall certificate + $thumbprint = (Get-PfxCertificate -FilePath "ci-artifacts\windows-agent\UbuntuProForWindows_*.cer").Thumbprint + Remove-Item -Path "Cert:LocalMachine\TrustedPeople\${thumbprint}" stop-vm: name: Clean up the Azure VM From c5ba8fba1c589a27ddc9c7b2270583f854268dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Thu, 28 Sep 2023 10:36:30 +0200 Subject: [PATCH 20/25] Clarify why we don't specify name: in artifact download --- .github/workflows/qa-azure.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/qa-azure.yaml b/.github/workflows/qa-azure.yaml index c01f78a38..68031f95c 100644 --- a/.github/workflows/qa-azure.yaml +++ b/.github/workflows/qa-azure.yaml @@ -123,6 +123,7 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v3 with: + # name: is left blank so that all artifacts are downloaded path: ci-artifacts - name: Set up artifacts shell: powershell From 07492964118b6d136d5291a70d097cb1db9ae870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Thu, 28 Sep 2023 10:40:08 +0200 Subject: [PATCH 21/25] Use wildcards in Appx package upload --- .github/workflows/qa-azure.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/qa-azure.yaml b/.github/workflows/qa-azure.yaml index 68031f95c..84aa34c8f 100644 --- a/.github/workflows/qa-azure.yaml +++ b/.github/workflows/qa-azure.yaml @@ -78,8 +78,8 @@ jobs: with: name: UbuntuProForWindows+${{ github.sha }} path: | - msix/UbuntuProForWindows/AppPackages/UbuntuProForWindows_*/UbuntuProForWindows_1.0.0.0_x64.cer - msix/UbuntuProForWindows/AppPackages/UbuntuProForWindows_*/UbuntuProForWindows_1.0.0.0_x64.msixbundle + msix/UbuntuProForWindows/AppPackages/UbuntuProForWindows_*/UbuntuProForWindows_*_x64.cer + msix/UbuntuProForWindows/AppPackages/UbuntuProForWindows_*/UbuntuProForWindows_*_x64.msixbundle vm-setup: name: Set up Azure VM From e644653b2a1e34acc708cae96c91919e90471bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Thu, 28 Sep 2023 10:42:13 +0200 Subject: [PATCH 22/25] Improve workflow title and description --- .github/workflows/qa-azure.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/qa-azure.yaml b/.github/workflows/qa-azure.yaml index 84aa34c8f..b23cacfaf 100644 --- a/.github/workflows/qa-azure.yaml +++ b/.github/workflows/qa-azure.yaml @@ -1,5 +1,5 @@ -name: QA on Azure -# QA checks on Azure, allowing the use of a real WSL back-en +name: Build and run end-to-end tests +# Builds the project, and runs end-to-end tests using the generated artifacts. concurrency: azure-vm From 7d9608bac2ad14118ab529c2b48ec6e25fde02e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Thu, 28 Sep 2023 10:45:25 +0200 Subject: [PATCH 23/25] Clarify that startAgent may stop the tests --- end-to-end/utils_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/end-to-end/utils_test.go b/end-to-end/utils_test.go index 6f310d999..8d872041d 100644 --- a/end-to-end/utils_test.go +++ b/end-to-end/utils_test.go @@ -61,6 +61,7 @@ func registerFromTestImage(t *testing.T, ctx context.Context) string { } // startAgent starts the GUI (without interacting with it) and waits for the Agent to start. +// It stops the agent upon cleanup. If the cleanup fails, the testing will be stopped. // //nolint:revive // testing.T must precede the contex func startAgent(t *testing.T, ctx context.Context) (cleanup func()) { From 02beb1431999bcf0d494d65cbc568998adc82f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Thu, 28 Sep 2023 11:21:36 +0200 Subject: [PATCH 24/25] Simplify ensureProjectIsBuilt --- end-to-end/main_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/end-to-end/main_test.go b/end-to-end/main_test.go index e97efd139..81ccfb941 100644 --- a/end-to-end/main_test.go +++ b/end-to-end/main_test.go @@ -70,7 +70,12 @@ func TestMain(m *testing.M) { log.Fatalf("Setup: %v\n", err) } - wslProServiceDebPath, err := ensureProjectIsBuilt(ctx) + f := buildProject + if buildPath := os.Getenv(prebuiltPath); buildPath != "" { + f = usePrebuiltProject + } + + wslProServiceDebPath, err := f(ctx) if err != nil { log.Fatalf("Setup: %v\n", err) } @@ -98,11 +103,8 @@ func TestMain(m *testing.M) { } } -func ensureProjectIsBuilt(ctx context.Context) (debPath string, err error) { +func usePrebuiltProject(ctx context.Context) (debPath string, err error) { buildPath := os.Getenv(prebuiltPath) - if buildPath == "" { - return buildProject(ctx) - } // Remove Appx before installing cmd := powershellf(ctx, "Get-AppxPackage CanonicalGroupLimited.UbuntuProForWindows | Remove-AppxPackage") From 22c05a65da54acd0d7926003ea1bd7c3a50fc82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Thu, 28 Sep 2023 12:25:02 +0200 Subject: [PATCH 25/25] Increase timeout for agent startup --- end-to-end/utils_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/end-to-end/utils_test.go b/end-to-end/utils_test.go index 8d872041d..a87a94cc4 100644 --- a/end-to-end/utils_test.go +++ b/end-to-end/utils_test.go @@ -121,7 +121,7 @@ func startAgent(t *testing.T, ctx context.Context) (cleanup func()) { return false } return true - }, 10*time.Second, 100*time.Millisecond, "Agent never started serving") + }, 30*time.Second, 100*time.Millisecond, "Agent never started serving") t.Log("Started agent") return cleanup