-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest-Uninstaller.ps1
62 lines (47 loc) · 2.52 KB
/
Test-Uninstaller.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# This script tests the uninstaller of eryph-zero. These tests are run
# separately for sequencing reasons. Also, we do not want to accidentally
# uninstall eryph on a developer's machine.
#Requires -Version 7.4
#Requires -Module Pester
#Requires -Module Assert
$PSNativeCommandUseErrorActionPreference = $true
$ErrorActionPreference = 'Stop'
Write-Output "Testing the uninstaller of eryph-zero..."
# Verify that the expected data exists before uninstalling eryph-zero.
"C:\ProgramData\eryph" | Should -Exist
"C:\ProgramData\openvswitch" | Should -Exist
# Checking for any service with eryph in its name does not work,
# as the VSTS agent service might also contain eryph in its name.
$service = Get-Service -Name "eryph-zero"
$service | Should -HaveCount 1
$driver = Get-WindowsDriver -Online | Where-Object { $_.OriginalFileName -ilike "*dbo_ovse*" }
$driver | Should -HaveCount 1
$rootCertificates = Get-Item Cert:\LocalMachine\Root\* | Where-Object { $_.Issuer -ilike "*eryph*" }
$rootCertificates | Should -HaveCount 1
$myCertificates = Get-Item Cert:\LocalMachine\My\* | Where-Object { $_.Issuer -ilike "*eryph*" }
$myCertificates | Should -HaveCount 3
$catletName = "catlet-$(Get-Date -Format 'yyyyMMddHHmmss')"
New-Catlet -Parent "dbosoft/e2etests-os/base" -Name $catletName
Get-VM | Assert-Any { $_.Name -eq $catletName }
$diskName = "disk-$(Get-Date -Format 'yyyyMMddHHmmss')"
$disk = New-CatletDisk -Name $diskName -ProjectName "default" -Size 5 -Location test
$disk.Path | Should -Exist
Write-Output "Uninstalling eryph-zero..."
$output = & "C:\Program Files\eryph\zero\bin\eryph-zero.exe" uninstall --delete-app-data --delete-catlets
Write-Output $output
# Verify that the uninstaller has not logged any warnings.
$output | Should -Not -BeLike "*WRN]*"
# Verify that the data no longer exists after uninstalling eryph-zero.
"C:\ProgramData\eryph" | Should -Not -Exist
"C:\ProgramData\openvswitch" | Should -Not -Exist
# Get-Service returns an emtpy list instead of an error when using a wildcard.
$service = Get-Service -Name "*eryph-zero*"
$service | Should -HaveCount 0
$driver = Get-WindowsDriver -Online | Where-Object { $_.OriginalFileName -ilike "*dbo_ovse*" }
$driver | Should -HaveCount 0
$rootCertificates = Get-Item Cert:\LocalMachine\Root\* | Where-Object { $_.Issuer -ilike "*eryph*" }
$rootCertificates | Should -HaveCount 0
$myCertificates = Get-Item Cert:\LocalMachine\My\* | Where-Object { $_.Issuer -ilike "*eryph*" }
$myCertificates | Should -HaveCount 0
Get-VM | Assert-All { $_.Name -ne $catletName }
$disk.Path | Should -Not -Exist