From 5641ff0eb6f410f8d2f37d2cb525a789133a35ba Mon Sep 17 00:00:00 2001 From: Shamil Mubarakshin <127750046+shamil-mubarakshin@users.noreply.github.com> Date: Fri, 3 Oct 2025 11:25:31 +0200 Subject: [PATCH] [Windows,Ubuntu] Update disk space pester test (#13128) --- images/ubuntu/scripts/tests/System.Tests.ps1 | 7 +++++-- .../windows/scripts/tests/WindowsFeatures.Tests.ps1 | 11 ++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/images/ubuntu/scripts/tests/System.Tests.ps1 b/images/ubuntu/scripts/tests/System.Tests.ps1 index 1536a5798..b25ed75f0 100644 --- a/images/ubuntu/scripts/tests/System.Tests.ps1 +++ b/images/ubuntu/scripts/tests/System.Tests.ps1 @@ -2,8 +2,11 @@ # If the test is running on the ADO pipeline or on the GitHub actions, the test will be skipped Describe "Disk free space" -Skip:(-not [String]::IsNullOrEmpty($env:AGENT_NAME) -or -not [String]::IsNullOrEmpty($env:RUNNER_NAME)) { It "Image has enough free space" { - $freeSpace = (Get-PSDrive "/").Free - $freeSpace | Should -BeGreaterOrEqual 17GB + $diskInfo = Get-PSDrive "/" + $totalSpaceGB = [math]::Floor(($diskInfo.Used + $diskInfo.Free) / 1GB) + $freeSpaceGB = [math]::Floor($diskInfo.Free / 1GB) + Write-Host " [i] Disk size: ${totalSpaceGB} GB; Free space: ${freeSpaceGB} GB" + $freeSpaceGB | Should -BeGreaterOrEqual 17 } } diff --git a/images/windows/scripts/tests/WindowsFeatures.Tests.ps1 b/images/windows/scripts/tests/WindowsFeatures.Tests.ps1 index 528ae762b..9b8134a32 100644 --- a/images/windows/scripts/tests/WindowsFeatures.Tests.ps1 +++ b/images/windows/scripts/tests/WindowsFeatures.Tests.ps1 @@ -20,11 +20,12 @@ Describe "WindowsFeatures" { } Describe "DiskSpace" { - It "The image has enough disk space"{ - $availableSpaceMB = [math]::Round((Get-PSDrive -Name C).Free / 1MB) - $minimumFreeSpaceMB = 18 * 1024 - - $availableSpaceMB | Should -BeGreaterThan $minimumFreeSpaceMB + It "The image has enough disk space" { + $diskInfo = Get-PSDrive -Name C + $totalSpaceGB = [math]::Floor(($diskInfo.Used + $diskInfo.Free) / 1GB) + $freeSpaceGB = [math]::Floor($diskInfo.Free / 1GB) + Write-Host " [i] Disk size: ${totalSpaceGB} GB; Free space: ${freeSpaceGB} GB" + $freeSpaceGB | Should -BeGreaterOrEqual 18 } }