[Windows,Ubuntu] Update disk space pester test (#13128)

This commit is contained in:
Shamil Mubarakshin
2025-10-03 11:25:31 +02:00
committed by GitHub
parent ba87e27210
commit 5641ff0eb6
2 changed files with 11 additions and 7 deletions

View File

@@ -2,8 +2,11 @@
# If the test is running on the ADO pipeline or on the GitHub actions, the test will be skipped # 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)) { Describe "Disk free space" -Skip:(-not [String]::IsNullOrEmpty($env:AGENT_NAME) -or -not [String]::IsNullOrEmpty($env:RUNNER_NAME)) {
It "Image has enough free space" { It "Image has enough free space" {
$freeSpace = (Get-PSDrive "/").Free $diskInfo = Get-PSDrive "/"
$freeSpace | Should -BeGreaterOrEqual 17GB $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
} }
} }

View File

@@ -20,11 +20,12 @@ Describe "WindowsFeatures" {
} }
Describe "DiskSpace" { Describe "DiskSpace" {
It "The image has enough disk space"{ It "The image has enough disk space" {
$availableSpaceMB = [math]::Round((Get-PSDrive -Name C).Free / 1MB) $diskInfo = Get-PSDrive -Name C
$minimumFreeSpaceMB = 18 * 1024 $totalSpaceGB = [math]::Floor(($diskInfo.Used + $diskInfo.Free) / 1GB)
$freeSpaceGB = [math]::Floor($diskInfo.Free / 1GB)
$availableSpaceMB | Should -BeGreaterThan $minimumFreeSpaceMB Write-Host " [i] Disk size: ${totalSpaceGB} GB; Free space: ${freeSpaceGB} GB"
$freeSpaceGB | Should -BeGreaterOrEqual 18
} }
} }