Skip to content

Commit 5641ff0

Browse files
[Windows,Ubuntu] Update disk space pester test (#13128)
1 parent ba87e27 commit 5641ff0

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

images/ubuntu/scripts/tests/System.Tests.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
# If the test is running on the ADO pipeline or on the GitHub actions, the test will be skipped
33
Describe "Disk free space" -Skip:(-not [String]::IsNullOrEmpty($env:AGENT_NAME) -or -not [String]::IsNullOrEmpty($env:RUNNER_NAME)) {
44
It "Image has enough free space" {
5-
$freeSpace = (Get-PSDrive "/").Free
6-
$freeSpace | Should -BeGreaterOrEqual 17GB
5+
$diskInfo = Get-PSDrive "/"
6+
$totalSpaceGB = [math]::Floor(($diskInfo.Used + $diskInfo.Free) / 1GB)
7+
$freeSpaceGB = [math]::Floor($diskInfo.Free / 1GB)
8+
Write-Host " [i] Disk size: ${totalSpaceGB} GB; Free space: ${freeSpaceGB} GB"
9+
$freeSpaceGB | Should -BeGreaterOrEqual 17
710
}
811
}
912

images/windows/scripts/tests/WindowsFeatures.Tests.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ Describe "WindowsFeatures" {
2020
}
2121

2222
Describe "DiskSpace" {
23-
It "The image has enough disk space"{
24-
$availableSpaceMB = [math]::Round((Get-PSDrive -Name C).Free / 1MB)
25-
$minimumFreeSpaceMB = 18 * 1024
26-
27-
$availableSpaceMB | Should -BeGreaterThan $minimumFreeSpaceMB
23+
It "The image has enough disk space" {
24+
$diskInfo = Get-PSDrive -Name C
25+
$totalSpaceGB = [math]::Floor(($diskInfo.Used + $diskInfo.Free) / 1GB)
26+
$freeSpaceGB = [math]::Floor($diskInfo.Free / 1GB)
27+
Write-Host " [i] Disk size: ${totalSpaceGB} GB; Free space: ${freeSpaceGB} GB"
28+
$freeSpaceGB | Should -BeGreaterOrEqual 18
2829
}
2930
}
3031

0 commit comments

Comments
 (0)