-
Notifications
You must be signed in to change notification settings - Fork 315
/
Copy pathtest_self_keep_latest_packages.ps1
41 lines (34 loc) · 1.47 KB
/
test_self_keep_latest_packages.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Test Supervisor package cleanup using the `--keep-latest-packages` option
$pkg="core/hab-sup"
Describe "Supervisor package cleanup" {
It "loads old Supervisor versions" {
hab pkg install "core/hab-sup/1.5.30" --channel unstable
hab pkg install "core/hab-sup/1.5.42" --channel unstable
hab pkg install "core/hab-sup/1.5.50" --channel unstable
hab pkg install "core/hab-sup/1.5.60" --channel unstable
Wait-CommandLinesOfOutput "hab pkg list $pkg" 4
}
Context "start the Supervisor without package cleanup" {
$supLog = New-SupervisorLogFile("start_the_supervisor_without_package_cleanup")
Start-Supervisor -LogFile $supLog -Timeout 45 | Out-Null
It "does not remove old Supervisor packages" {
Wait-CommandLinesOfOutput "hab pkg list $pkg" 5
}
Stop-Supervisor
Start-Sleep 3 # Wait for the supervisor to actually stop
}
Context "start the Supervisor with package cleanup" {
$supLog = New-SupervisorLogFile("start_the_supervisor_with_package_cleanup")
$expected = hab pkg list core/hab-sup | Select-Object -Last 2
Start-Supervisor -LogFile $supLog -Timeout 45 -SupArgs @( `
"--keep-latest-packages=2"
) | Out-Null
It "removes old Supervisor packages" {
Wait-CommandLinesOfOutput "hab pkg list $pkg" 2
hab pkg list $pkg | Should -Be $expected
}
}
AfterAll {
Stop-Supervisor
}
}